import React, { useEffect, ReactElement } from "react"; import Image from "next/image"; import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; // next-themes import { useTheme } from "next-themes"; // services import { AuthService } from "services/auth.service"; // hooks import { useUser } from "hooks/store"; import useUserAuth from "hooks/use-user-auth"; import useToast from "hooks/use-toast"; // layouts import DefaultLayout from "layouts/default-layout"; // components import { EmailSignUpForm } from "components/account"; // images import BluePlaneLogoWithoutText from "public/plane-logos/blue-without-text.png"; // types import { NextPageWithLayout } from "lib/types"; type EmailPasswordFormValues = { email: string; password?: string; medium?: string; }; // services const authService = new AuthService(); const SignUpPage: NextPageWithLayout = observer(() => { // router const router = useRouter(); // toast alert const { setToastAlert } = useToast(); // next-themes const { setTheme } = useTheme(); // store hooks const { currentUser, fetchCurrentUser, currentUserLoader } = useUser(); // custom hooks const {} = useUserAuth({ routeAuth: "sign-in", user: currentUser, isLoading: currentUserLoader }); const handleSignUp = async (formData: EmailPasswordFormValues) => { const payload = { email: formData.email, password: formData.password ?? "", }; await authService .emailSignUp(payload) .then(async (response) => { setToastAlert({ type: "success", title: "Success!", message: "Account created successfully.", }); if (response) await fetchCurrentUser(); router.push("/onboarding"); }) .catch((err) => setToastAlert({ type: "error", title: "Error!", message: err?.error || "Something went wrong. Please try again later or contact the support team.", }) ); }; useEffect(() => { setTheme("system"); }, [setTheme]); return ( <>