fix billingCheckoutSession query param + enable redirect on workspace… (#11509)

… during onboarding



fixes : https://github.com/twentyhq/core-team-issues/issues/668
This commit is contained in:
Etienne
2025-04-10 16:47:40 +02:00
committed by GitHub
parent d69932c6c4
commit ee5aa2393d
20 changed files with 151 additions and 92 deletions

View File

@ -2,7 +2,7 @@ import styled from '@emotion/styled';
import { motion } from 'framer-motion';
const StyledContentContainer = styled(motion.div)`
height: 300px;
height: 480px;
margin-bottom: ${({ theme }) => theme.spacing(8)};
margin-top: ${({ theme }) => theme.spacing(4)};
`;

View File

@ -14,11 +14,14 @@ import { useRecoilState, useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared/utils';
import { Loader } from 'twenty-ui/feedback';
import { CardPicker, MainButton } from 'twenty-ui/input';
import { CAL_LINK, ClickToActionLink } from 'twenty-ui/navigation';
import {
CAL_LINK,
ClickToActionLink,
TWENTY_PRICING_LINK,
} from 'twenty-ui/navigation';
import {
BillingPlanKey,
BillingPriceLicensedDto,
SubscriptionInterval,
useBillingBaseProductPricesQuery,
} from '~/generated/graphql';
@ -94,7 +97,7 @@ export const ChooseYourPlan = () => {
const { data: plans } = useBillingBaseProductPricesQuery();
const currentPlan = billingCheckoutSession.plan || BillingPlanKey.PRO;
const currentPlan = billingCheckoutSession.plan;
const getPlanBenefits = (planKey: BillingPlanKey) => {
if (planKey === BillingPlanKey.ENTERPRISE) {
@ -128,7 +131,7 @@ export const ChooseYourPlan = () => {
const baseProductPrice = baseProduct?.prices?.find(
(price): price is BillingPriceLicensedDto =>
isBillingPriceLicensed(price) &&
price.recurringInterval === SubscriptionInterval.Month,
price.recurringInterval === billingCheckoutSession.interval,
);
const hasWithoutCreditCardTrialPeriod = billing?.trialPeriods.some(
@ -160,27 +163,10 @@ export const ChooseYourPlan = () => {
};
};
const handleSwitchPlan = (planKey: BillingPlanKey) => {
return () => {
if (isDefined(baseProductPrice)) {
setBillingCheckoutSession({
plan: planKey,
interval: baseProductPrice.recurringInterval,
requirePaymentMethod: billingCheckoutSession.requirePaymentMethod,
});
}
};
};
const { signOut } = useAuth();
const withCreditCardTrialPeriodDuration = withCreditCardTrialPeriod?.duration;
const alternatePlan =
currentPlan === BillingPlanKey.PRO
? BillingPlanKey.ENTERPRISE
: BillingPlanKey.PRO;
const planName = plans?.plans.find((plan) => plan.planKey === currentPlan)
?.baseProduct.name;
@ -252,8 +238,8 @@ export const ChooseYourPlan = () => {
<Trans>Log out</Trans>
</ClickToActionLink>
<span />
<ClickToActionLink onClick={handleSwitchPlan(alternatePlan)}>
<Trans>Switch Plan</Trans>
<ClickToActionLink href={TWENTY_PRICING_LINK}>
<Trans>Change Plan</Trans>
</ClickToActionLink>
<span />
<ClickToActionLink href={CAL_LINK} target="_blank" rel="noreferrer">

View File

@ -1,30 +1,30 @@
import { ApolloError } from '@apollo/client';
import {
CurrentWorkspace,
currentWorkspaceState,
} from '@/auth/states/currentWorkspaceState';
import { useRecoilState } from 'recoil';
import { useRedirectToWorkspaceDomain } from '@/domain-manager/hooks/useRedirectToWorkspaceDomain';
import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { SettingsPath } from '@/types/SettingsPath';
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { ApolloError } from '@apollo/client';
import { zodResolver } from '@hookform/resolvers/zod';
import { Trans, useLingui } from '@lingui/react/macro';
import { FormProvider, useForm } from 'react-hook-form';
import { useRecoilState } from 'recoil';
import { isDefined } from 'twenty-shared/utils';
import { z } from 'zod';
import {
FeatureFlagKey,
useUpdateWorkspaceMutation,
} from '~/generated/graphql';
import { useRedirectToWorkspaceDomain } from '@/domain-manager/hooks/useRedirectToWorkspaceDomain';
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
import { SettingsCustomDomain } from '~/pages/settings/workspace/SettingsCustomDomain';
import { SettingsSubdomain } from '~/pages/settings/workspace/SettingsSubdomain';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
import { Trans, useLingui } from '@lingui/react/macro';
import { z } from 'zod';
import { FormProvider, useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
import { SettingsPath } from '@/types/SettingsPath';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { isDefined } from 'twenty-shared/utils';
export const SettingsDomain = () => {
const navigate = useNavigateSettings();
@ -151,7 +151,7 @@ export const SettingsDomain = () => {
variant: SnackBarVariant.Error,
});
},
onCompleted: () => {
onCompleted: async () => {
const currentUrl = new URL(window.location.href);
currentUrl.hostname = new URL(
@ -167,7 +167,7 @@ export const SettingsDomain = () => {
variant: SnackBarVariant.Success,
});
redirectToWorkspaceDomain(currentUrl.toString());
await redirectToWorkspaceDomain(currentUrl.toString());
},
});
};