-
-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(console): update cloud API calls
- Loading branch information
Showing
58 changed files
with
1,865 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...mponents/CreateTenantModal/SelectTenantPlanModal/SkuCardItem/FeaturedSkuContent/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import classNames from 'classnames'; | ||
|
||
import Failed from '@/assets/icons/failed.svg'; | ||
import Success from '@/assets/icons/success.svg'; | ||
|
||
import * as styles from '../../PlanCardItem/FeaturedPlanContent/index.module.scss'; | ||
|
||
import useFeaturedSkuContent from './use-featured-sku-content'; | ||
|
||
type Props = { | ||
readonly skuId: string; | ||
}; | ||
|
||
function FeaturedSkuContent({ skuId }: Props) { | ||
const contentData = useFeaturedSkuContent(skuId); | ||
|
||
return ( | ||
<ul className={styles.list}> | ||
{contentData.map(({ title, isAvailable }) => { | ||
return ( | ||
<li key={title}> | ||
{isAvailable ? ( | ||
<Success className={classNames(styles.icon, styles.success)} /> | ||
) : ( | ||
<Failed className={classNames(styles.icon, styles.failed)} /> | ||
)} | ||
{title} | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
); | ||
} | ||
|
||
export default FeaturedSkuContent; |
77 changes: 77 additions & 0 deletions
77
...antModal/SelectTenantPlanModal/SkuCardItem/FeaturedSkuContent/use-featured-sku-content.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { ReservedPlanId } from '@logto/schemas'; | ||
import { cond } from '@silverhand/essentials'; | ||
import { useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
freePlanAuditLogsRetentionDays, | ||
freePlanM2mLimit, | ||
freePlanMauLimit, | ||
freePlanPermissionsLimit, | ||
freePlanRoleLimit, | ||
proPlanAuditLogsRetentionDays, | ||
} from '@/consts/subscriptions'; | ||
|
||
type ContentData = { | ||
title: string; | ||
isAvailable: boolean; | ||
}; | ||
|
||
const useFeaturedSkuContent = (skuId: string) => { | ||
const { t } = useTranslation(undefined, { | ||
keyPrefix: 'admin_console.upsell.featured_plan_content', | ||
}); | ||
|
||
const contentData: ContentData[] = useMemo(() => { | ||
const isFreePlan = skuId === ReservedPlanId.Free; | ||
const planPhraseKey = isFreePlan ? 'free_plan' : 'pro_plan'; | ||
|
||
return [ | ||
{ | ||
title: t(`mau.${planPhraseKey}`, { ...cond(isFreePlan && { count: freePlanMauLimit }) }), | ||
isAvailable: true, | ||
}, | ||
{ | ||
title: t(`m2m.${planPhraseKey}`, { ...cond(isFreePlan && { count: freePlanM2mLimit }) }), | ||
isAvailable: true, | ||
}, | ||
{ | ||
title: t('third_party_apps'), | ||
isAvailable: !isFreePlan, | ||
}, | ||
{ | ||
title: t('mfa'), | ||
isAvailable: !isFreePlan, | ||
}, | ||
{ | ||
title: t('sso'), | ||
isAvailable: !isFreePlan, | ||
}, | ||
{ | ||
title: t(`role_and_permissions.${planPhraseKey}`, { | ||
...cond( | ||
isFreePlan && { | ||
roleCount: freePlanRoleLimit, | ||
permissionCount: freePlanPermissionsLimit, | ||
} | ||
), | ||
}), | ||
isAvailable: true, | ||
}, | ||
{ | ||
title: t('organizations'), | ||
isAvailable: !isFreePlan, | ||
}, | ||
{ | ||
title: t('audit_logs', { | ||
count: isFreePlan ? freePlanAuditLogsRetentionDays : proPlanAuditLogsRetentionDays, | ||
}), | ||
isAvailable: true, | ||
}, | ||
]; | ||
}, [t, skuId]); | ||
|
||
return contentData; | ||
}; | ||
|
||
export default useFeaturedSkuContent; |
Oops, something went wrong.