@@ -17,7 +17,7 @@ export default function BillingComponent({ billingState }: { billingState: Billi
1717 purchaseUrl : string
1818 }
1919
20- const [ billing , setBilling ] = useState < Billing | null > ( billingState )
20+ const [ billing , setBilling ] = useState < Billing > ( billingState )
2121 const [ plans , setPlans ] = useState < Plan [ ] > ( [ ] )
2222 const { toast } = useToast ( )
2323 const router = useRouter ( )
@@ -33,7 +33,9 @@ export default function BillingComponent({ billingState }: { billingState: Billi
3333
3434 const fetchBilling = async ( ) => {
3535 const billing = await getBillingAndCreateIfNotExists ( )
36- setBilling ( billing )
36+ if ( billing ) {
37+ setBilling ( billing )
38+ }
3739 }
3840
3941 const planButtonText = ( plan : Plan ) => {
@@ -88,19 +90,29 @@ export default function BillingComponent({ billingState }: { billingState: Billi
8890
8991 return (
9092 < div >
91- { /* TODO: Billing goes here */ }
92- { plans . map ( ( plan , index ) => (
93- < div key = { `plan-${ index } ` } className = "flex justify-between items-center p-2 rounded-md border-b-[1px] border-gray-200" >
94- < div className = "flex items-center gap-3" >
95- < p className = "text-xl flex items-center gap-2 font-bold" > { plan . price } / { plan . for } </ p >
93+ < p className = "text-lg font-bold mt-5" > Available Credits: { billing . credits } </ p >
94+ < div className = "space-y-3 mt-2" >
95+ { plans . map ( ( plan , index ) => (
96+ < div key = { `plan-${ index } ` } className = "flex justify-between items-center p-5 rounded-md border-[1px] border-gray-200" >
9697 < div className = "flex flex-col gap-1" >
97- < p className = "text-lg" > { plan . name } </ p >
98- < p className = "text-sm" > { plan . credits } /month</ p >
98+ < p className = "flex items-center gap-2 font-bold" > { plan . price } / { plan . for } </ p >
99+ < p > { plan . name } </ p >
100+ < p className = "text-sm" > { plan . credits } Credits / month</ p >
99101 </ div >
102+ < Button
103+ className = "w-[150px]"
104+ disabled = { planButtonText ( plan ) === "Current Plan" }
105+ onClick = {
106+ ( ) => planButtonText ( plan ) === "Contact Support" ?
107+ window . location . href = "mailto:support@rowfill.com" :
108+ handlePlanButton ( plan )
109+ }
110+ >
111+ { planButtonText ( plan ) }
112+ </ Button >
100113 </ div >
101- < Button disabled = { planButtonText ( plan ) === "Current Plan" || planButtonText ( plan ) === "Contact Support" } onClick = { ( ) => handlePlanButton ( plan ) } > { planButtonText ( plan ) } </ Button >
102- </ div >
103- ) ) }
114+ ) ) }
115+ </ div >
104116 </ div >
105117 )
106118}
0 commit comments