diff --git a/packages/dashboard-v2/src/components/forms/SignUpForm.js b/packages/dashboard-v2/src/components/forms/SignUpForm.js index 6725c673..c6ebed3e 100644 --- a/packages/dashboard-v2/src/components/forms/SignUpForm.js +++ b/packages/dashboard-v2/src/components/forms/SignUpForm.js @@ -32,14 +32,16 @@ export const SignUpForm = ({ onSuccess, onFailure }) => ( validationSchema={registrationSchema} onSubmit={async ({ email, password }, { setErrors }) => { try { - await accountsService.post("user", { - json: { - email, - password, - }, - }); + const user = await accountsService + .post("user", { + json: { + email, + password, + }, + }) + .json(); - onSuccess(); + onSuccess(user); } catch (err) { let isFormErrorSet = false; diff --git a/packages/dashboard-v2/src/pages/auth/registration.js b/packages/dashboard-v2/src/pages/auth/registration.js index b58562fd..5764ad6a 100644 --- a/packages/dashboard-v2/src/pages/auth/registration.js +++ b/packages/dashboard-v2/src/pages/auth/registration.js @@ -1,5 +1,4 @@ -import { useEffect, useState } from "react"; -import { navigate } from "gatsby"; +import { useCallback, useState } from "react"; import bytes from "pretty-bytes"; import AuthLayout from "../../layouts/AuthLayout"; @@ -10,6 +9,7 @@ import { SignUpForm } from "../../components/forms/SignUpForm"; import { usePortalSettings } from "../../contexts/portal-settings"; import { PlansProvider, usePlans } from "../../contexts/plans"; import { Metadata } from "../../components/Metadata"; +import { useUser } from "../../contexts/user"; const FreePortalHeader = () => { const { plans } = usePlans(); @@ -47,14 +47,14 @@ const State = { const SignUpPage = () => { const [state, setState] = useState(State.Pure); const { settings } = usePortalSettings(); + const { mutate: refreshUserState } = useUser(); - useEffect(() => { - if (state === State.Success) { - const timer = setTimeout(() => navigate(settings.isSubscriptionRequired ? "/upgrade" : "/"), 3000); - - return () => clearTimeout(timer); - } - }, [state, settings.isSubscriptionRequired]); + const onUserCreated = useCallback( + (newUser) => { + refreshUserState(newUser); + }, + [refreshUserState] + ); return ( @@ -70,7 +70,7 @@ const SignUpPage = () => { {state !== State.Success && ( <> - setState(State.Success)} onFailure={() => setState(State.Failure)} /> + setState(State.Failure)} />

Already have an account? Sign in @@ -78,14 +78,6 @@ const SignUpPage = () => { )} - {state === State.Success && ( -

-

Please check your inbox and confirm your email address.

-

You will be redirected to your dashboard shortly.

- Click here to go there now. -
- )} - {state === State.Failure && (

Something went wrong, please try again later.

)}