diff --git a/src/components/Billing/BillingPage.tsx b/src/components/Billing/BillingPage.tsx
index dcdd0c074..e977ee5dd 100644
--- a/src/components/Billing/BillingPage.tsx
+++ b/src/components/Billing/BillingPage.tsx
@@ -41,13 +41,15 @@ export function BillingPage() {
queryClient,
);
- const isCanceled =
- billingDetails?.status === 'canceled' ||
- billingDetails?.status === 'incomplete_expired' ||
- billingDetails?.cancelAtPeriodEnd;
+ console.log(billingDetails);
+
+ const willBeCanceled = billingDetails?.cancelAtPeriodEnd;
+
+ const isCanceled = billingDetails?.status === 'canceled';
const isPastDue = billingDetails?.status === 'past_due';
const isIncomplete = billingDetails?.status === 'incomplete';
+ const isIncompleteExpired = billingDetails?.status === 'incomplete_expired';
const {
mutate: createCustomerPortal,
@@ -101,7 +103,7 @@ export function BillingPage() {
day: 'numeric',
});
- return (
+ const modals = (
<>
{showUpgradeModal && (
}
+ >
+ );
- {billingDetails?.status === 'none' && !isLoadingBillingDetails && (
+ if (!priceDetails) {
+ return (
+
+
Uh oh!
+
+ We couldn't find your subscription details. Please contact support at
+
+ info@roadmap.sh
+
+ .
+
+
+ );
+ }
+
+ if (billingDetails?.status === 'none' || isIncompleteExpired) {
+ return (
+ <>
+ {modals}
setShowUpgradeModal(true)} />
- )}
+ >
+ );
+ }
- {billingDetails?.status !== 'none' &&
- !isLoadingBillingDetails &&
- priceDetails && (
-
- {isIncomplete && (
-
{
- createCustomerPortal({});
- }}
- isLoading={
- isCreatingCustomerPortal || isCreatingCustomerPortalSuccess
- }
- />
- )}
- {isCanceled && (
- {
- createCustomerPortal({});
- }}
- isLoading={
- isCreatingCustomerPortal || isCreatingCustomerPortalSuccess
- }
- />
- )}
- {isPastDue && (
- {
- createCustomerPortal({});
- }}
- isLoading={
- isCreatingCustomerPortal || isCreatingCustomerPortalSuccess
- }
- />
- )}
+ if (isCanceled) {
+ return (
+ <>
+ {modals}
+ {
+ if (willBeCanceled) {
+ createCustomerPortal({});
+ } else {
+ setShowUpgradeModal(true);
+ }
+ }}
+ isLoading={
+ isCreatingCustomerPortal || isCreatingCustomerPortalSuccess
+ }
+ />
-
- Current Subscription
-
+ setShowUpgradeModal(true)} />
+ >
+ );
+ }
-
- Thank you for being a pro member. Your plan details are below.
-
+ if (isIncomplete) {
+ return (
+ <>
+ {modals}
+ {
+ createCustomerPortal({});
+ }}
+ isLoading={
+ isCreatingCustomerPortal || isCreatingCustomerPortalSuccess
+ }
+ />
-
-
-
-
-
-
-
- Payment
-
-
- ${priceDetails.amount}
-
- / {priceDetails.interval}
-
-
-
-
+
setShowUpgradeModal(true)} />
+ >
+ );
+ }
+
+ return (
+ <>
+ {modals}
+
+
+ {isPastDue && (
+
{
+ createCustomerPortal({});
+ }}
+ isLoading={
+ isCreatingCustomerPortal || isCreatingCustomerPortalSuccess
+ }
+ />
+ )}
+
+ {willBeCanceled && (
+ {
+ createCustomerPortal({});
+ }}
+ isLoading={
+ isCreatingCustomerPortal || isCreatingCustomerPortalSuccess
+ }
+ />
+ )}
+
+
+ Current Subscription
+
+
+
+ Thank you for being a pro member. Your plan details are below.
+
+
+
+
+
+
-
-
- {!isIncomplete && (
-
-
-
-
-
-
- {billingDetails?.cancelAtPeriodEnd
- ? 'Expires On'
- : 'Renews On'}
-
-
- {formattedNextBillDate}
-
-
-
- )}
-
-
- {!isCanceled && !isIncomplete && (
-
- )}
-
-
-
+
+
+ Payment
+
+
+ ${priceDetails.amount}
+
+ / {priceDetails.interval}
+
+
- )}
+
+
+
+
+
+
+
+
+
+ {willBeCanceled ? 'Expires On' : 'Renews On'}
+
+
+ {formattedNextBillDate}
+
+
+
+
+
+ {!willBeCanceled && (
+
+ )}
+
+
+
+
>
);
}