Skip to content

Commit e30fd65

Browse files
authored
Merge pull request #7439 from alkem-io/hotfix-create-space-entitlements
Create Space Link - entitlements check added
2 parents 8b41210 + 7ec232c commit e30fd65

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alkemio/client-web",
3-
"version": "0.79.6",
3+
"version": "0.79.7",
44
"description": "Alkemio client, enabling users to interact with Challenges hosted on the Alkemio platform.",
55
"repository": {
66
"type": "git",
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { useTranslation } from 'react-i18next';
22
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';
44
import { TopLevelRoutePath } from '@/main/routing/TopLevelRoutePath';
55
import { useMemo } from 'react';
66

77
export const useCreateSpaceLink = () => {
88
const { t } = useTranslation();
9-
const { accountPrivileges, loading } = useUserContext();
9+
const { accountPrivileges, loading, accountEntitlements } = useUserContext();
1010

1111
const STATIC_PAGE_LINK = t('pages.home.sections.startingSpace.url');
1212

@@ -15,12 +15,18 @@ export const useCreateSpaceLink = () => {
1515
return STATIC_PAGE_LINK;
1616
}
1717

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) {
1925
return `/${TopLevelRoutePath.CreateSpace}`;
2026
}
2127

2228
return STATIC_PAGE_LINK;
23-
}, [accountPrivileges, loading, t]);
29+
}, [accountPrivileges, accountEntitlements, loading, t]);
2430

2531
return { loading, link };
2632
};

0 commit comments

Comments
 (0)