File tree Expand file tree Collapse file tree 2 files changed +32
-8
lines changed
src/components/billing/pricing-modal Expand file tree Collapse file tree 2 files changed +32
-8
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,23 @@ function Plans({ products, subscription }: PricingProps) {
90
90
</ div >
91
91
92
92
< section className = "flex flex-col sm:flex-row sm:flex-wrap gap-8 pt-8" >
93
+ < PricingCard
94
+ title = "Free"
95
+ description = ""
96
+ price = "$0"
97
+ interval = "month"
98
+ subscribedUnitAmount = { subscription ?. price . unitAmount }
99
+ unitAmount = { 0 }
100
+ isSubmitting = { isSubmitting }
101
+ { ...( subscription && {
102
+ handleClick : ( ) => {
103
+ return handleBillingPortal ( {
104
+ type : "cancel" ,
105
+ subscription : subscription . id ,
106
+ } ) ;
107
+ } ,
108
+ } ) }
109
+ />
93
110
{ products . map ( ( product ) => {
94
111
const price = product ?. prices ?. find (
95
112
( price ) => price . interval === billingInterval ,
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ interface PricingCardProps {
18
18
subscribedUnitAmount ?: bigint | null ;
19
19
unitAmount : number ;
20
20
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
21
- handleClick : ( ) => Promise < any > ;
21
+ handleClick ? : ( ) => Promise < any > ;
22
22
isSubmitting : boolean ;
23
23
}
24
24
@@ -52,9 +52,11 @@ export function PricingCard({
52
52
< CardTitle className = "text-lg" > { title } </ CardTitle >
53
53
< div className = "flex gap-0.5" >
54
54
< h3 className = "text-3xl font-bold" > { price } </ h3 >
55
- < span className = "flex flex-col justify-end text-sm mb-1" >
56
- /{ humanizedInterval [ interval ] }
57
- </ span >
55
+ { unitAmount !== 0 && (
56
+ < span className = "flex flex-col justify-end text-sm mb-1" >
57
+ /{ humanizedInterval [ interval ] }
58
+ </ span >
59
+ ) }
58
60
</ div >
59
61
< CardDescription > { description } </ CardDescription >
60
62
</ CardHeader >
@@ -63,20 +65,25 @@ export function PricingCard({
63
65
className = { cn ( ! active && "bg-teal-500 hover:bg-teal-500/80" ) }
64
66
{ ...( active && { variant : "destructive" } ) }
65
67
onClick = { async ( ) => {
66
- setIsLoading ( true ) ;
67
- await handleClick ( ) ;
68
- setIsLoading ( false ) ;
68
+ if ( handleClick ) {
69
+ setIsLoading ( true ) ;
70
+ await handleClick ( ) ;
71
+ setIsLoading ( false ) ;
72
+ }
69
73
} }
70
74
loading = { isLoading }
71
75
{ ...( ! isLoading && { disabled : isSubmitting } ) }
76
+ { ...( unitAmount === 0 && ! subscribedUnitAmount && { disabled : true } ) }
72
77
>
73
78
{ subscribedUnitAmount
74
79
? unitAmount < subscribedUnitAmount
75
80
? "Downgrade Plan"
76
81
: unitAmount > subscribedUnitAmount
77
82
? "Upgrade Plan"
78
83
: "Cancel Current Plan"
79
- : "Subscribe" }
84
+ : ! subscribedUnitAmount && unitAmount === 0
85
+ ? "Active plan"
86
+ : "Subscribe" }
80
87
</ Button >
81
88
</ CardFooter >
82
89
</ Card >
You can’t perform that action at this time.
0 commit comments