Perf improvements and billing updates

This commit is contained in:
giancarlo
2024-03-26 16:49:11 +08:00
parent 8626ea30c7
commit 4032aed827
39 changed files with 1261 additions and 1090 deletions

View File

@@ -0,0 +1,48 @@
import { Database } from '@kit/supabase/database';
import { Badge } from '@kit/ui/badge';
export function CurrentPlanBadge(
props: React.PropsWithoutRef<{
status: Database['public']['Enums']['subscription_status'];
}>,
) {
let variant: 'success' | 'warning' | 'destructive';
let text: string;
switch (props.status) {
case 'active':
variant = 'success';
text = 'Active';
break;
case 'trialing':
variant = 'success';
text = 'Trialing';
break;
case 'past_due':
variant = 'destructive';
text = 'Past due';
break;
case 'canceled':
variant = 'destructive';
text = 'Canceled';
break;
case 'unpaid':
variant = 'destructive';
text = 'Unpaid';
break;
case 'incomplete':
variant = 'warning';
text = 'Incomplete';
break;
case 'incomplete_expired':
variant = 'destructive';
text = 'Incomplete expired';
break;
case 'paused':
variant = 'warning';
text = 'Paused';
break;
}
return <Badge variant={variant}>{text}</Badge>;
}