@@ -395,6 +395,18 @@ function Login() {
395
395
const setThirdpartyLoader = ( value ) => {
396
396
setState ( { ...state , thirdpartyLoader : value } ) ;
397
397
} ;
398
+ const handleFreePlan = async ( id ) => {
399
+ try {
400
+ const params = { userId : id } ;
401
+ const res = await Parse . Cloud . run ( "freesubscription" , params ) ;
402
+ if ( res . status === "error" ) {
403
+ alert ( res . result ) ;
404
+ }
405
+ } catch ( err ) {
406
+ console . log ( "err in free subscribe" , err . message ) ;
407
+ alert ( "Somenthing went wrong, please try again later!" ) ;
408
+ }
409
+ } ;
398
410
const thirdpartyLoginfn = async ( sessionToken , billingDate ) => {
399
411
const baseUrl = localStorage . getItem ( "baseUrl" ) ;
400
412
const parseAppId = localStorage . getItem ( "parseAppId" ) ;
@@ -404,6 +416,11 @@ function Login() {
404
416
"X-Parse-Application-Id" : parseAppId
405
417
}
406
418
} ) ;
419
+ const param = new URLSearchParams ( location . search ) ;
420
+ const isFreeplan = param ?. get ( "subscription" ) === "freeplan" ;
421
+ if ( isFreeplan ) {
422
+ await handleFreePlan ( res . data . objectId ) ;
423
+ }
407
424
await Parse . User . become ( sessionToken ) . then ( ( ) => {
408
425
window . localStorage . setItem ( "accesstoken" , sessionToken ) ;
409
426
} ) ;
@@ -580,13 +597,23 @@ function Login() {
580
597
if ( billingDate > new Date ( ) ) {
581
598
localStorage . removeItem ( "userDetails" ) ;
582
599
navigate ( redirectUrl ) ;
600
+ } else {
601
+ if ( isFreeplan ) {
602
+ navigate ( redirectUrl ) ;
603
+ } else {
604
+ navigate ( `/subscription` , {
605
+ replace : true
606
+ } ) ;
607
+ }
608
+ }
609
+ } else {
610
+ if ( isFreeplan ) {
611
+ navigate ( redirectUrl ) ;
583
612
} else {
584
613
navigate ( `/subscription` , {
585
614
replace : true
586
615
} ) ;
587
616
}
588
- } else {
589
- navigate ( `/subscription` , { replace : true } ) ;
590
617
}
591
618
} else {
592
619
navigate ( redirectUrl ) ;
@@ -608,10 +635,22 @@ function Login() {
608
635
// Redirect to the appropriate URL after successful login
609
636
navigate ( redirectUrl ) ;
610
637
} else {
611
- navigate ( `/subscription` , { replace : true } ) ;
638
+ if ( isFreeplan ) {
639
+ navigate ( redirectUrl ) ;
640
+ } else {
641
+ navigate ( `/subscription` , {
642
+ replace : true
643
+ } ) ;
644
+ }
612
645
}
613
646
} else {
614
- navigate ( `/subscription` , { replace : true } ) ;
647
+ if ( isFreeplan ) {
648
+ navigate ( redirectUrl ) ;
649
+ } else {
650
+ navigate ( `/subscription` , {
651
+ replace : true
652
+ } ) ;
653
+ }
615
654
}
616
655
} else {
617
656
navigate ( redirectUrl ) ;
@@ -1112,7 +1151,11 @@ function Login() {
1112
1151
</ button >
1113
1152
< NavLink
1114
1153
className = "rounded-sm cursor-pointer bg-white border-[1px] border-[#15b4e9] text-[#15b4e9] w-full py-3 shadow uppercase"
1115
- to = "/signup"
1154
+ to = {
1155
+ location . search
1156
+ ? "/signup" + location . search
1157
+ : "/signup"
1158
+ }
1116
1159
style = { width < 768 ? { textAlign : "center" } : { } }
1117
1160
>
1118
1161
Create Account
0 commit comments