1
1
import { useTranslation } from 'react-i18next' ;
2
2
import { useUserContext } from '@/domain/community/user' ;
3
- import { AuthorizationPrivilege } from '@/core/apollo/generated/graphql-schema' ;
3
+ import { AuthorizationPrivilege , LicenseEntitlementType } from '@/core/apollo/generated/graphql-schema' ;
4
4
import { TopLevelRoutePath } from '@/main/routing/TopLevelRoutePath' ;
5
5
import { useMemo } from 'react' ;
6
6
7
7
export const useCreateSpaceLink = ( ) => {
8
8
const { t } = useTranslation ( ) ;
9
- const { accountPrivileges, loading } = useUserContext ( ) ;
9
+ const { accountPrivileges, loading, accountEntitlements } = useUserContext ( ) ;
10
10
11
11
const STATIC_PAGE_LINK = t ( 'pages.home.sections.startingSpace.url' ) ;
12
12
@@ -15,12 +15,18 @@ export const useCreateSpaceLink = () => {
15
15
return STATIC_PAGE_LINK ;
16
16
}
17
17
18
- if ( accountPrivileges . includes ( AuthorizationPrivilege . CreateSpace ) ) {
18
+ const isEntitledToCreateSpace = [
19
+ LicenseEntitlementType . AccountSpaceFree ,
20
+ LicenseEntitlementType . AccountSpacePlus ,
21
+ LicenseEntitlementType . AccountSpacePremium ,
22
+ ] . some ( entitlement => accountEntitlements . includes ( entitlement ) ) ;
23
+
24
+ if ( accountPrivileges . includes ( AuthorizationPrivilege . CreateSpace ) && isEntitledToCreateSpace ) {
19
25
return `/${ TopLevelRoutePath . CreateSpace } ` ;
20
26
}
21
27
22
28
return STATIC_PAGE_LINK ;
23
- } , [ accountPrivileges , loading , t ] ) ;
29
+ } , [ accountPrivileges , accountEntitlements , loading , t ] ) ;
24
30
25
31
return { loading, link } ;
26
32
} ;
0 commit comments