@@ -4,7 +4,6 @@ import { useNavigate } from "react-router-dom";
44import { IS_CLERK_AUTH } from "@/clerk/auth" ;
55import ForwardedIconComponent from "@/components/common/genericIconComponent" ;
66import { Button } from "@/components/ui/button" ;
7- import { Checkbox } from "@/components/ui/checkbox" ;
87import {
98 Dialog ,
109 DialogContent ,
@@ -60,9 +59,7 @@ function SelectedPlan({ billing }: { billing: BillingAccessResponse | null }) {
6059 return (
6160 < div className = "rounded-xl border bg-background p-4" >
6261 < p className = "text-sm text-muted-foreground" > Selected plan</ p >
63- < p className = "mt-1 text-xl font-semibold" >
64- { selectedPlan }
65- </ p >
62+ < p className = "mt-1 text-xl font-semibold" > { selectedPlan } </ p >
6663 < div className = "mt-3 space-y-1 text-sm text-muted-foreground" >
6764 < p > Subscription status: { billing ?. subscription_status ?? "not available" } </ p >
6865 < p > Subscription ID: { billing ?. paddle_subscription_id ?? "not available" } </ p >
@@ -79,7 +76,6 @@ export default function PricingPlansPage() {
7976 const [ billing , setBilling ] = useState < BillingAccessResponse | null > ( null ) ;
8077
8178 const [ cancelModalOpen , setCancelModalOpen ] = useState ( false ) ;
82- const [ cancelImmediately , setCancelImmediately ] = useState ( false ) ;
8379 const [ cancelLoading , setCancelLoading ] = useState ( false ) ;
8480
8581 const [ cancelError , setCancelError ] = useState < string | null > ( null ) ;
@@ -106,10 +102,11 @@ export default function PricingPlansPage() {
106102
107103 const isCancelScheduled = Boolean ( billing ?. cancel_scheduled ) ;
108104
109- // ✅ FIXED: allow button even if scheduled (so user can "Cancel Now")
110105 const canCancelSubscription =
111106 Boolean ( billing ?. paddle_subscription_id ) &&
112- ! isCancelledState ;
107+ ! isCancelledState &&
108+ ! isCancelScheduled &&
109+ ! alreadyCancelled ;
113110
114111 useEffect ( ( ) => {
115112 if ( ! IS_CLERK_AUTH ) {
@@ -143,7 +140,9 @@ export default function PricingPlansPage() {
143140 } ;
144141
145142 void load ( ) ;
146- return ( ) => { mounted = false ; } ;
143+ return ( ) => {
144+ mounted = false ;
145+ } ;
147146 } , [ getToken ] ) ;
148147
149148 useEffect ( ( ) => {
@@ -165,9 +164,9 @@ export default function PricingPlansPage() {
165164 ] ) ;
166165
167166 const handleCancelSubscription = async ( ) => {
168- if ( ( alreadyCancelled || isCancelScheduled ) && ! cancelImmediately ) {
167+ if ( alreadyCancelled || isCancelScheduled ) {
169168 setCancelError (
170- `You already cancelled your subscription . Access continues ${ accessEndsMessage } .` ,
169+ `Subscription Cancelled Successfully . Access continues ${ accessEndsMessage } .` ,
171170 ) ;
172171 setCancelModalOpen ( false ) ;
173172 return ;
@@ -182,28 +181,18 @@ export default function PricingPlansPage() {
182181
183182 await api . post (
184183 getURL ( "CANCEL_PADDLE_SUBSCRIPTION" ) ,
185- { effective_from_immediately : cancelImmediately } ,
184+ { effective_from_immediately : false } ,
186185 { headers : { Authorization : `Bearer ${ token } ` } } ,
187186 ) ;
188187
189- // ✅ IMMEDIATE CANCEL → redirect instantly
190- if ( cancelImmediately ) {
191- navigate ( "/pricing" , { replace : true } ) ;
192- return ;
193- }
194-
195- // scheduled cancel
196188 setAlreadyCancelled ( true ) ;
197-
198189 setCancelModalOpen ( false ) ;
199- setCancelImmediately ( false ) ;
200190
201191 const res = await api . get ( getURL ( "BILLING_ACCESS" ) , {
202192 headers : { Authorization : `Bearer ${ token } ` } ,
203193 } ) ;
204194
205195 setBilling ( res . data ?? null ) ;
206-
207196 } catch ( error : any ) {
208197 const msg =
209198 error ?. response ?. data ?. detail ??
@@ -280,21 +269,6 @@ export default function PricingPlansPage() {
280269 You have access { accessEndsMessage }
281270 </ DialogDescription >
282271 </ DialogHeader >
283- < div className = "flex items-center space-x-2" >
284- < Checkbox
285- id = "cancel-now"
286- checked = { cancelImmediately }
287- onCheckedChange = { ( checked ) =>
288- setCancelImmediately ( Boolean ( checked ) )
289- }
290- />
291- < label
292- htmlFor = "cancel-now"
293- className = "text-sm text-muted-foreground cursor-pointer"
294- >
295- Cancel now (no refund)
296- </ label >
297- </ div >
298272 < DialogFooter >
299273 < Button onClick = { ( ) => setCancelModalOpen ( false ) } >
300274 Keep subscription
0 commit comments