Add cancellation alert and refactor subscription handling

Added a 'Subscription Cancelled' alert in the billing component to improve visibility of subscription status. Also, removed an unnecessary check for target_account_id in billing-event-handler service as it lead to early exits. Fixed a typo in stripe-webhook-handler service for better consistency in naming conventions.
This commit is contained in:
giancarlo
2024-04-14 19:16:18 +08:00
parent 6271e6a4f7
commit d8e44772f2
4 changed files with 14 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ import { BadgeCheck } from 'lucide-react';
import { BillingConfig, getProductPlanPairByVariantId } from '@kit/billing';
import { Database } from '@kit/supabase/database';
import { Alert, AlertDescription, AlertTitle } from '@kit/ui/alert';
import {
Card,
CardContent,
@@ -108,15 +109,18 @@ export function CurrentSubscriptionCard({
</If>
<If condition={subscription.cancel_at_period_end}>
<div className="flex flex-col space-y-0.5">
<span className="font-semibold">
<Trans i18nKey="billing:cancelSubscriptionDate" />
</span>
<Alert variant={'warning'}>
<AlertTitle>
<Trans i18nKey="billing:subscriptionCancelled" />
</AlertTitle>
<div className={'text-muted-foreground'}>
<span>{formatDate(subscription.period_ends_at ?? '', 'P')}</span>
</div>
</div>
<AlertDescription>
<Trans i18nKey="billing:cancelSubscriptionDate" />:
<span className={'ml-1'}>
{formatDate(subscription.period_ends_at ?? '', 'P')}
</span>
</AlertDescription>
</Alert>
</If>
<div className="flex flex-col space-y-0.5">