Added redirection to stripe dashboard
This commit is contained in:
parent
0e123f6459
commit
2e9d50f62e
@ -22,14 +22,34 @@ export default function SubscriptionFacturation() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [subscription, setSubscription] = useState<Subscription | null>(null);
|
const [subscription, setSubscription] = useState<Subscription | null>(null);
|
||||||
|
|
||||||
const { close: closeCancelSubscription, isOpen: isCancelSubscriptionOpen, open: openCancelSubscription } = useOpenable();
|
const { close: closeCancelSubscription, isOpen: isCancelSubscriptionOpen } = useOpenable();
|
||||||
const { close: closeConfirmation, isOpen: isConfirmationOpen, open: openConfirmation } = useOpenable();
|
const { close: closeConfirmation, isOpen: isConfirmationOpen } = useOpenable();
|
||||||
|
|
||||||
const cancelSubscription = useCallback(() => {
|
// const cancelSubscription = useCallback(() => {
|
||||||
closeCancelSubscription();
|
// closeCancelSubscription();
|
||||||
openConfirmation();
|
// openConfirmation();
|
||||||
return;
|
// return;
|
||||||
}, [closeCancelSubscription, openConfirmation]);
|
// }, [closeCancelSubscription, openConfirmation]);
|
||||||
|
|
||||||
|
const manageSubscription = async () => {
|
||||||
|
try {
|
||||||
|
const jwt = JwtService.getInstance().decodeJwt();
|
||||||
|
const subscription = await Subscriptions.getInstance().get({ where: { office: { uid: jwt?.office_Id } } });
|
||||||
|
if (!subscription[0]) return;
|
||||||
|
const stripe_client_portal = await Stripe.getInstance().getClientPortalSession(subscription[0].stripe_subscription_id!);
|
||||||
|
router.push(stripe_client_portal.url + "/subscriptions/" + subscription[0].stripe_subscription_id + "/update");
|
||||||
|
} catch (error) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancelSubscription = async () => {
|
||||||
|
try {
|
||||||
|
const jwt = JwtService.getInstance().decodeJwt();
|
||||||
|
const subscription = await Subscriptions.getInstance().get({ where: { office: { uid: jwt?.office_Id } } });
|
||||||
|
if (!subscription[0]) return;
|
||||||
|
const stripe_client_portal = await Stripe.getInstance().getClientPortalSession(subscription[0].stripe_subscription_id!);
|
||||||
|
router.push(stripe_client_portal.url + "/subscriptions/" + subscription[0].stripe_subscription_id + "/cancel");
|
||||||
|
} catch (error) {}
|
||||||
|
};
|
||||||
|
|
||||||
const manageBilling = async () => {
|
const manageBilling = async () => {
|
||||||
try {
|
try {
|
||||||
@ -108,7 +128,7 @@ export default function SubscriptionFacturation() {
|
|||||||
{subscription.type === "UNLIMITED" && (
|
{subscription.type === "UNLIMITED" && (
|
||||||
// <Link
|
// <Link
|
||||||
// href={Module.getInstance().get().modules.pages.Subscription.pages.Manage.pages.Standard.props.path}>
|
// href={Module.getInstance().get().modules.pages.Subscription.pages.Manage.pages.Standard.props.path}>
|
||||||
<Button onClick={manageBilling} fullwidth variant={EButtonVariant.GHOST}>
|
<Button onClick={manageSubscription} fullwidth variant={EButtonVariant.GHOST}>
|
||||||
Rétrograder mon abonnement
|
Rétrograder mon abonnement
|
||||||
</Button>
|
</Button>
|
||||||
// </Link>
|
// </Link>
|
||||||
@ -177,7 +197,7 @@ export default function SubscriptionFacturation() {
|
|||||||
{subscription.type === "STANDARD" && (
|
{subscription.type === "STANDARD" && (
|
||||||
// <Link
|
// <Link
|
||||||
// href={Module.getInstance().get().modules.pages.Subscription.pages.Manage.pages.Illimity.props.path}>
|
// href={Module.getInstance().get().modules.pages.Subscription.pages.Manage.pages.Illimity.props.path}>
|
||||||
<Button onClick={manageBilling} fullwidth variant={EButtonVariant.GHOST}>
|
<Button onClick={manageSubscription} fullwidth variant={EButtonVariant.GHOST}>
|
||||||
Améliorer mon abonnement
|
Améliorer mon abonnement
|
||||||
</Button>
|
</Button>
|
||||||
// </Link>
|
// </Link>
|
||||||
@ -186,7 +206,7 @@ export default function SubscriptionFacturation() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={classes["actions-container"]}>
|
<div className={classes["actions-container"]}>
|
||||||
<Button variant={EButtonVariant.LINE} onClick={openCancelSubscription}>
|
<Button variant={EButtonVariant.LINE} onClick={cancelSubscription}>
|
||||||
<Typography typo={ITypo.P_18} color={ITypoColor.RED_FLASH}>
|
<Typography typo={ITypo.P_18} color={ITypoColor.RED_FLASH}>
|
||||||
Arrêter l'abonnement
|
Arrêter l'abonnement
|
||||||
</Typography>
|
</Typography>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user