import { useState } from "react"; import { waitlistCollection } from "../firebase"; import { doc, setDoc } from "firebase/firestore"; import { useAtomValue } from "jotai"; import { translationAtom } from "@/atoms/translations-atom"; const nameRegex = /^[A-Za-z\s.'-]+$/; const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; export const UpscaylCloudModal = ({ show, setShow, setDontShowCloudModal }) => { const [name, setName] = useState(""); const [email, setEmail] = useState(""); const t = useAtomValue(translationAtom); return (

{t("APP.UPSCAYL_CLOUD.COMING_SOON")}

{t("APP.INTRO")}

{t("APP.UPSCAYL_CLOUD.CATCHY_PHRASE_1")}

            {t("APP.UPSCAYL_CLOUD.CATCHY_PHRASE_2")}
          
{ e.preventDefault(); if ( name && email && nameRegex.test(name) && emailRegex.test(email) ) { try { await setDoc(doc(waitlistCollection, email), { name, email, }); } catch (error) { alert(t("APP.UPSCAYL_CLOUD.ALREADY_REGISTERED", { name })); return; } setName(""); setEmail(""); setDontShowCloudModal(true); setShow(false); alert(t("APP.UPSCAYL_CLOUD.ADD_SUCCESS")); } else { alert(t("APP.UPSCAYL_CLOUD.INCORRECT_FIELDS")); } }} >
setName(e.target.value)} /> setEmail(e.target.value)} />
); };