From 780e97c12110ba93f162b6acc7052d8a23108bb5 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sun, 25 Sep 2022 18:14:24 +0530 Subject: [PATCH 1/3] fix renew button click --- .../Sidebar/SubscriptionStatus/index.tsx | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/components/Sidebar/SubscriptionStatus/index.tsx b/src/components/Sidebar/SubscriptionStatus/index.tsx index d62739a29..4b7206c60 100644 --- a/src/components/Sidebar/SubscriptionStatus/index.tsx +++ b/src/components/Sidebar/SubscriptionStatus/index.tsx @@ -1,5 +1,5 @@ import { GalleryContext } from 'pages/gallery'; -import React, { useContext, useMemo } from 'react'; +import React, { MouseEventHandler, useContext, useMemo } from 'react'; import { hasPaidSubscription, isFamilyAdmin, @@ -43,19 +43,23 @@ export default function SubscriptionStatus({ }, [userDetails]); const handleClick = useMemo(() => { - if (userDetails) { - if (isSubscriptionActive(userDetails.subscription)) { - if (hasExceededStorageQuota(userDetails)) { - return showPlanSelectorModal; - } - } else { - if (hasStripeSubscription(userDetails.subscription)) { - return billingService.redirectToCustomerPortal; + const eventHandler: MouseEventHandler = (e) => { + e.stopPropagation(); + if (userDetails) { + if (isSubscriptionActive(userDetails.subscription)) { + if (hasExceededStorageQuota(userDetails)) { + showPlanSelectorModal(); + } } else { - return showPlanSelectorModal; + if (hasStripeSubscription(userDetails.subscription)) { + billingService.redirectToCustomerPortal(); + } else { + showPlanSelectorModal(); + } } } - } + }; + return eventHandler; }, [userDetails]); if (!hasAMessage) { @@ -80,13 +84,9 @@ export default function SubscriptionStatus({ ) : hasExceededStorageQuota(userDetails) && constants.STORAGE_QUOTA_EXCEEDED_SUBSCRIPTION_INFO( - showPlanSelectorModal + handleClick ) - : constants.SUBSCRIPTION_EXPIRED_MESSAGE( - hasStripeSubscription(userDetails.subscription) - ? billingService.redirectToCustomerPortal - : showPlanSelectorModal - )} + : constants.SUBSCRIPTION_EXPIRED_MESSAGE(handleClick)} ); From a31acbfa5f2cfb5ec1b3a94eeb403b706fceb517 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sun, 25 Sep 2022 18:15:04 +0530 Subject: [PATCH 2/3] fix this not passed to open customer portal --- src/components/Upload/Uploader.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Upload/Uploader.tsx b/src/components/Upload/Uploader.tsx index 3bf574f1d..4162f9021 100644 --- a/src/components/Upload/Uploader.tsx +++ b/src/components/Upload/Uploader.tsx @@ -454,7 +454,8 @@ export default function Uploader(props: Props) { message: constants.SUBSCRIPTION_EXPIRED, action: { text: constants.RENEW_NOW, - callback: billingService.redirectToCustomerPortal, + callback: () => + billingService.redirectToCustomerPortal(), }, }; break; From ae3bb1040aa3ae5e492cdb1b7b3e2b4e8e6d564a Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sun, 25 Sep 2022 18:15:44 +0530 Subject: [PATCH 3/3] just check if it is stripeSubscription and not combined validity check --- src/utils/billing/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/billing/index.ts b/src/utils/billing/index.ts index 2394eb487..84308a074 100644 --- a/src/utils/billing/index.ts +++ b/src/utils/billing/index.ts @@ -153,7 +153,6 @@ export function isUserSubscribedPlan(plan: Plan, subscription: Subscription) { } export function hasStripeSubscription(subscription: Subscription) { return ( - hasPaidSubscription(subscription) && subscription.paymentProvider.length > 0 && subscription.paymentProvider === PAYMENT_PROVIDER_STRIPE );