Refactor billing gateway and enhance localization

Refactored the 'plan-picker' component in the billing gateway to remove unwanted line items and improve checkout session and subscription handling. Enhanced the localization support by adding translations in the plan picker and introduced a new function to check trial eligibility so that existing customers can't start a new trial period. These changes enhance the usability of the application across different regions and provide accurate trial period conditions.
This commit is contained in:
giancarlo
2024-04-01 11:52:35 +08:00
parent 248ab7ef72
commit d6004f2f7e
15 changed files with 877 additions and 346 deletions

View File

@@ -52,31 +52,33 @@ async function TeamAccountBillingPage({ params }: Params) {
<CannotManageBillingAlert />
</If>
<div className={'flex flex-col space-y-4'}>
<If
condition={subscription}
fallback={
<If condition={canManageBilling}>
<TeamAccountCheckoutForm
customerId={customerId}
accountId={accountId}
/>
</If>
}
>
{(data) => (
<CurrentPlanCard subscription={data} config={billingConfig} />
)}
</If>
<div>
<div className={'flex flex-col space-y-2'}>
<If
condition={subscription}
fallback={
<If condition={canManageBilling}>
<TeamAccountCheckoutForm
customerId={customerId}
accountId={accountId}
/>
</If>
}
>
{(data) => (
<CurrentPlanCard subscription={data} config={billingConfig} />
)}
</If>
<If condition={customerId && canManageBilling}>
<form action={createBillingPortalSession}>
<input type="hidden" name={'accountId'} value={accountId} />
<input type="hidden" name={'slug'} value={params.account} />
<If condition={customerId && canManageBilling}>
<form action={createBillingPortalSession}>
<input type="hidden" name={'accountId'} value={accountId} />
<input type="hidden" name={'slug'} value={params.account} />
<BillingPortalCard />
</form>
</If>
<BillingPortalCard />
</form>
</If>
</div>
</div>
</div>
</PageBody>