Set optional checkout.session.url (#4569)
* Set optional checkout.session.url * Lint * Edit .env.example * Vale CI --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
@ -27,4 +27,4 @@ const getDefaultUrl = () => {
|
||||
export const REACT_APP_SERVER_BASE_URL =
|
||||
window._env_?.REACT_APP_SERVER_BASE_URL ||
|
||||
process.env.REACT_APP_SERVER_BASE_URL ||
|
||||
getDefaultUrl();
|
||||
getDefaultUrl();
|
||||
|
||||
@ -552,7 +552,7 @@ export type Sentry = {
|
||||
|
||||
export type SessionEntity = {
|
||||
__typename?: 'SessionEntity';
|
||||
url: Scalars['String'];
|
||||
url?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
/** Sort Directions */
|
||||
@ -1015,7 +1015,7 @@ export type BillingPortalSessionQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type BillingPortalSessionQuery = { __typename?: 'Query', billingPortalSession: { __typename?: 'SessionEntity', url: string } };
|
||||
export type BillingPortalSessionQuery = { __typename?: 'Query', billingPortalSession: { __typename?: 'SessionEntity', url?: string | null } };
|
||||
|
||||
export type CheckoutSessionMutationVariables = Exact<{
|
||||
recurringInterval: Scalars['String'];
|
||||
@ -1023,7 +1023,7 @@ export type CheckoutSessionMutationVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type CheckoutSessionMutation = { __typename?: 'Mutation', checkoutSession: { __typename?: 'SessionEntity', url: string } };
|
||||
export type CheckoutSessionMutation = { __typename?: 'Mutation', checkoutSession: { __typename?: 'SessionEntity', url?: string | null } };
|
||||
|
||||
export type GetProductPricesQueryVariables = Exact<{
|
||||
product: Scalars['String'];
|
||||
|
||||
@ -35,6 +35,9 @@ export const SettingsBilling = () => {
|
||||
},
|
||||
});
|
||||
|
||||
const billingPortalButtonDisabled =
|
||||
loading || !isDefined(data) || !isDefined(data.billingPortalSession.url);
|
||||
|
||||
const displayPaymentFailInfo =
|
||||
onboardingStatus === OnboardingStatus.PastDue ||
|
||||
onboardingStatus === OnboardingStatus.Unpaid;
|
||||
@ -46,7 +49,7 @@ export const SettingsBilling = () => {
|
||||
onboardingStatus === OnboardingStatus.CompletedWithoutSubscription;
|
||||
|
||||
const openBillingPortal = () => {
|
||||
if (isDefined(data)) {
|
||||
if (isDefined(data) && isDefined(data.billingPortalSession.url)) {
|
||||
window.location.replace(data.billingPortalSession.url);
|
||||
}
|
||||
};
|
||||
@ -95,7 +98,7 @@ export const SettingsBilling = () => {
|
||||
title="View billing details"
|
||||
variant="secondary"
|
||||
onClick={openBillingPortal}
|
||||
disabled={loading}
|
||||
disabled={billingPortalButtonDisabled}
|
||||
/>
|
||||
</Section>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user