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:
@@ -3,9 +3,11 @@ import { useSearchParams } from 'react-router-dom';
|
||||
|
||||
import { useIsLogged } from '@/auth/hooks/useIsLogged';
|
||||
import { useVerifyLogin } from '@/auth/hooks/useVerifyLogin';
|
||||
import { clientConfigApiStatusState } from '@/client-config/states/clientConfigApiStatusState';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
import { SignInUpLoading } from '~/pages/auth/SignInUpLoading';
|
||||
@@ -20,6 +22,10 @@ export const Verify = () => {
|
||||
const navigate = useNavigateApp();
|
||||
const { verifyLoginToken } = useVerifyLogin();
|
||||
|
||||
const { isLoaded: clientConfigLoaded } = useRecoilValue(
|
||||
clientConfigApiStatusState,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (isDefined(errorMessage)) {
|
||||
enqueueSnackBar(errorMessage, {
|
||||
@@ -28,6 +34,8 @@ export const Verify = () => {
|
||||
});
|
||||
}
|
||||
|
||||
if (!clientConfigLoaded) return;
|
||||
|
||||
if (isDefined(loginToken)) {
|
||||
verifyLoginToken(loginToken);
|
||||
} else if (!isLogged) {
|
||||
@@ -35,7 +43,7 @@ export const Verify = () => {
|
||||
}
|
||||
// Verify only needs to run once at mount
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
}, [clientConfigLoaded]);
|
||||
|
||||
return <SignInUpLoading />;
|
||||
};
|
||||
|
||||
@@ -4,10 +4,12 @@ import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/Snac
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
|
||||
import { useVerifyLogin } from '@/auth/hooks/useVerifyLogin';
|
||||
import { animateModalState } from '@/auth/states/animateModalState';
|
||||
import { useRedirectToWorkspaceDomain } from '@/domain-manager/hooks/useRedirectToWorkspaceDomain';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
import { getWorkspaceUrl } from '~/utils/getWorkspaceUrl';
|
||||
import { EmailVerificationSent } from '../sign-in-up/components/EmailVerificationSent';
|
||||
@@ -19,6 +21,8 @@ export const VerifyEmailEffect = () => {
|
||||
|
||||
const [searchParams] = useSearchParams();
|
||||
const [isError, setIsError] = useState(false);
|
||||
const setAnimateModal = useSetRecoilState(animateModalState);
|
||||
|
||||
const email = searchParams.get('email');
|
||||
const emailVerificationToken = searchParams.get('emailVerificationToken');
|
||||
|
||||
@@ -48,9 +52,9 @@ export const VerifyEmailEffect = () => {
|
||||
|
||||
const workspaceUrl = getWorkspaceUrl(workspaceUrls);
|
||||
if (workspaceUrl.slice(0, -1) !== window.location.origin) {
|
||||
return redirectToWorkspaceDomain(workspaceUrl, AppPath.Verify, {
|
||||
setAnimateModal(false);
|
||||
return await redirectToWorkspaceDomain(workspaceUrl, AppPath.Verify, {
|
||||
loginToken: loginToken.token,
|
||||
animateModal: false,
|
||||
});
|
||||
}
|
||||
verifyLoginToken(loginToken.token);
|
||||
|
||||
Reference in New Issue
Block a user