@@ -19,7 +19,7 @@ import Alert from "../primitives/Alert";
19
19
import { appInfo } from "../constant/appinfo" ;
20
20
import { fetchAppInfo } from "../redux/reducers/infoReducer" ;
21
21
import { showTenant } from "../redux/reducers/ShowTenant" ;
22
- import { getAppLogo } from "../constant/Utils" ;
22
+ import { fetchSubscription , getAppLogo } from "../constant/Utils" ;
23
23
function Login ( ) {
24
24
const navigate = useNavigate ( ) ;
25
25
const location = useLocation ( ) ;
@@ -169,7 +169,7 @@ function Login() {
169
169
await Parse . Cloud . run ( "getUserDetails" , {
170
170
email : currentUser . get ( "email" )
171
171
} ) . then (
172
- ( result ) => {
172
+ async ( result ) => {
173
173
let tenentInfo = [ ] ;
174
174
const results = [ result ] ;
175
175
if ( results ) {
@@ -270,16 +270,15 @@ function Login() {
270
270
"userDetails" ,
271
271
JSON . stringify ( LocalUserDetails )
272
272
) ;
273
- const freeplan =
274
- results [ 0 ] . get ( "Plan" ) &&
275
- results [ 0 ] . get ( "Plan" ) . plan_code ;
276
- const billingDate =
277
- results [ 0 ] . get ( "Next_billing_date" ) &&
278
- results [ 0 ] . get ( "Next_billing_date" ) ;
273
+ const res = await fetchSubscription ( ) ;
274
+ const freeplan = res . plan ;
275
+ const billingDate = res . billingDate ;
279
276
if ( freeplan === "freeplan" ) {
280
277
navigate ( redirectUrl ) ;
281
278
} else if ( billingDate ) {
282
- if ( billingDate > new Date ( ) ) {
279
+ if (
280
+ new Date ( billingDate ) > new Date ( )
281
+ ) {
283
282
localStorage . removeItem (
284
283
"userDetails"
285
284
) ;
@@ -814,7 +813,7 @@ function Login() {
814
813
await Parse . Cloud . run ( "getUserDetails" , {
815
814
email : currentUser . get ( "email" )
816
815
} ) . then (
817
- ( result ) => {
816
+ async ( result ) => {
818
817
let tenentInfo = [ ] ;
819
818
const results = [ result ] ;
820
819
if ( results ) {
@@ -866,17 +865,13 @@ function Login() {
866
865
"userDetails" ,
867
866
JSON . stringify ( LocalUserDetails )
868
867
) ;
869
- const billingDate =
870
- results [ 0 ] . get ( "Next_billing_date" ) &&
871
- results [ 0 ] . get ( "Next_billing_date" ) ;
872
- const freeplan =
873
- results [ 0 ] ?. get ( "Plan" ) &&
874
- results [ 0 ] ?. get ( "Plan" ) . plan_code ;
875
-
868
+ const res = await fetchSubscription ( ) ;
869
+ const billingDate = res . billingDate ;
870
+ const freeplan = res . plan ;
876
871
if ( freeplan === "freeplan" ) {
877
872
navigate ( redirectUrl ) ;
878
873
} else if ( billingDate ) {
879
- if ( billingDate > new Date ( ) ) {
874
+ if ( new Date ( billingDate ) > new Date ( ) ) {
880
875
localStorage . removeItem ( "userDetails" ) ;
881
876
// Redirect to the appropriate URL after successful login
882
877
navigate ( redirectUrl ) ;
0 commit comments