@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
22import { plansApi , useSubscription } from 'subos-frontend' ;
33import { Card , Text , Badge , Stack , Divider , LoadingOverlay } from '@mantine/core' ;
44import { Button } from '@ui/button' ;
5- import { colors , PLANCODEENUM , ROUTES } from '@config' ;
5+ import { colors , NOTIFICATION_KEYS , PLANCODEENUM , ROUTES } from '@config' ;
66import { Plan } from './Plans' ;
77import { PlanFeature } from './PlanFeature' ;
88import useStyles from './Plans.styles' ;
@@ -28,8 +28,11 @@ export function PlanCard({ plan, isYearly }: PlanCardProps) {
2828 try {
2929 setIsLoading ( true ) ;
3030 await fetchSubscription ( profileInfo . email ) ;
31- } catch ( err ) {
32- notify ( 'Failed to fetch subscription' ) ;
31+ } catch ( err : any ) {
32+ notify ( NOTIFICATION_KEYS . ERROR_FETCHING_SUBSCRIPTION_DETAILS , {
33+ title : 'Failed to fetch subscription' ,
34+ message : err ?. message ,
35+ } ) ;
3336 } finally {
3437 setIsLoading ( false ) ;
3538 }
@@ -42,9 +45,9 @@ export function PlanCard({ plan, isYearly }: PlanCardProps) {
4245 setIsLoading ( true ) ;
4346 try {
4447 const response = await createPaymentSession ( plan . code , {
45- returnUrl : `${ window . location . origin } / ${ ROUTES . SUBSCRIPTION_STATUS } ` ,
48+ returnUrl : `${ window . location . origin } ${ ROUTES . SUBSCRIPTION_STATUS } ` ,
4649 externalId : profileInfo ?. email ,
47- cancelUrl : `${ window . location . origin } / ${ ROUTES . PAYMENT_CANCEL } ` ,
50+ cancelUrl : `${ window . location . origin } ${ ROUTES . PAYMENT_CANCEL } ` ,
4851 } ) ;
4952 if ( response ?. success && response ?. data ?. checkoutUrl ) {
5053 window . location . href = response ?. data ?. checkoutUrl ;
@@ -54,7 +57,10 @@ export function PlanCard({ plan, isYearly }: PlanCardProps) {
5457
5558 return null ;
5659 } catch ( err : any ) {
57- notify ( 'Failed to create payment session' ) ;
60+ notify ( NOTIFICATION_KEYS . ERROR_CREATE_CHECKOUT_SESSION , {
61+ title : 'Failed to create the checkout session' ,
62+ message : err ?. message ,
63+ } ) ;
5864 } finally {
5965 setIsLoading ( false ) ;
6066 }
0 commit comments