0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console): fix app creation modal footer

This commit is contained in:
Darcy Ye 2024-10-22 00:20:34 +08:00
parent 3022d2eba1
commit 1488665499
No known key found for this signature in database
GPG key ID: B46F4C07EDEFC610

View file

@ -42,83 +42,83 @@ function Footer({ selectedType, isLoading, onClickCreate, isThirdParty }: Props)
} = useUserPreferences();
if (selectedType) {
if (
selectedType === ApplicationType.MachineToMachine &&
hasMachineToMachineAppsReachedLimit &&
// Just in case the enterprise plan has reached the resource limit, we still need to show charge notice.
isPaidPlan(planId, isEnterprisePlan) &&
!m2mUpsellNoticeAcknowledged
) {
return (
<AddOnNoticeFooter
isLoading={isLoading}
buttonTitle="applications.create"
onClick={() => {
void update({ m2mUpsellNoticeAcknowledged: true });
onClickCreate();
}}
>
<Trans
components={{
span: <span className={styles.strong} />,
a: <TextLink to={addOnPricingExplanationLink} />,
}}
>
{t('add_on.footer.machine_to_machine_app', {
price: machineToMachineAddOnUnitPrice,
})}
</Trans>
</AddOnNoticeFooter>
);
}
if (selectedType === ApplicationType.MachineToMachine) {
if (hasMachineToMachineAppsReachedLimit) {
if (
// Just in case the enterprise plan has reached the resource limit, we still need to show charge notice.
isPaidPlan(planId, isEnterprisePlan) &&
!m2mUpsellNoticeAcknowledged
) {
return (
<AddOnNoticeFooter
isLoading={isLoading}
buttonTitle="applications.create"
onClick={() => {
void update({ m2mUpsellNoticeAcknowledged: true });
onClickCreate();
}}
>
<Trans
components={{
span: <span className={styles.strong} />,
a: <TextLink to={addOnPricingExplanationLink} />,
}}
>
{t('add_on.footer.machine_to_machine_app', {
price: machineToMachineAddOnUnitPrice,
})}
</Trans>
</AddOnNoticeFooter>
);
}
if (
selectedType === ApplicationType.MachineToMachine &&
hasMachineToMachineAppsReachedLimit &&
// For paid plan (pro plan), we don't guard the m2m app creation since it's an add-on feature.
currentSku.id === ReservedPlanId.Free
) {
return (
<QuotaGuardFooter>
<Trans
components={{
a: <ContactUsPhraseLink />,
}}
>
{t('paywall.machine_to_machine_feature')}
</Trans>
</QuotaGuardFooter>
);
}
// For paid plan (pro plan), we don't guard the m2m app creation since it's an add-on feature.
if (currentSku.id === ReservedPlanId.Free) {
return (
<QuotaGuardFooter>
<Trans
components={{
a: <ContactUsPhraseLink />,
}}
>
{t('paywall.machine_to_machine_feature')}
</Trans>
</QuotaGuardFooter>
);
}
}
} else {
// Third party app is only available for paid plan (pro plan).
if (isThirdParty && hasThirdPartyAppsReachedLimit) {
return (
<QuotaGuardFooter>
<Trans
components={{
a: <ContactUsPhraseLink />,
}}
>
{t('paywall.third_party_apps')}
</Trans>
</QuotaGuardFooter>
);
}
// Third party app is only available for paid plan (pro plan).
if (isThirdParty && hasThirdPartyAppsReachedLimit) {
return (
<QuotaGuardFooter>
<Trans
components={{
a: <ContactUsPhraseLink />,
}}
>
{t('paywall.third_party_apps')}
</Trans>
</QuotaGuardFooter>
);
}
if (hasAppsReachedLimit) {
return (
<QuotaGuardFooter>
<Trans
components={{
a: <ContactUsPhraseLink />,
planName: <SkuName skuId={planId} isEnterprisePlan={isEnterprisePlan} />,
}}
>
{t('paywall.applications', { count: currentSubscriptionQuota.applicationsLimit ?? 0 })}
</Trans>
</QuotaGuardFooter>
);
if (hasAppsReachedLimit) {
return (
<QuotaGuardFooter>
<Trans
components={{
a: <ContactUsPhraseLink />,
planName: <SkuName skuId={planId} isEnterprisePlan={isEnterprisePlan} />,
}}
>
{t('paywall.applications', {
count: currentSubscriptionQuota.applicationsLimit ?? 0,
})}
</Trans>
</QuotaGuardFooter>
);
}
}
}