import React from "react"; import { useTranslation } from "react-i18next"; import { useDispatch } from "react-redux"; import useSteps from "@/hooks/palmistry/use-steps"; import Button from "@/components/palmistry/button/button"; import Input from "@/components/palmistry/input/input"; import { actions } from "@/store"; import Title from "@/components/Title"; import Loader, { LoaderColor } from "@/components/Loader"; import { useAuthentication } from "@/hooks/authentication/use-authentication"; import { ESourceAuthorization } from "@/api/resources/User"; import metricService, { EGoals } from "@/services/metric/metricService"; const emailRegex = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/; export default function StepEmail() { const { t } = useTranslation(); const dispatch = useDispatch(); const steps = useSteps(); const [email, setEmail] = React.useState(steps.storedValue); const [emailIsValid, setEmailIsValid] = React.useState(false); const [isAuth, setIsAuth] = React.useState(false); const { error, isLoading, authorization } = useAuthentication(); const onChangeEmail = (value: string) => { setEmail(value); }; React.useEffect(() => { if (steps.storedValue) setEmail(steps.storedValue); }, [steps.storedValue]); React.useEffect(() => { const emailIsValid = email.match(emailRegex) !== null; setEmailIsValid(emailIsValid); if (emailIsValid) { dispatch(actions.form.addEmail(email)); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [email]); const authorize = async () => { await authorization(email, ESourceAuthorization["aura.palmistry"]); metricService.reachGoal(EGoals.ENTERED_EMAIL); setIsAuth(true); }; const onNext = async () => { await authorize(); steps.saveCurrent(email); steps.goNext(); }; return ( <>

Enter your email to get your advanced Palmistry reading with AURA

We don’t share any personal information.

By clicking "Continue" below you agree to AURA{" "} EULA {" "} and{" "} Privacy Policy .

{isLoading && } {error?.length && ( Something went wrong )} ); }