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("UPSCAYL_CLOUD.COMING_SOON")}

{t("INTRO")}

{t("UPSCAYL_CLOUD.CATCHY_PHRASE_1")}

            {t("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("UPSCAYL_CLOUD.ALREADY_REGISTERED_ALERT", { name })); return; } setName(""); setEmail(""); setDontShowCloudModal(true); setShow(false); alert(t("UPSCAYL_CLOUD.ADD_SUCCESS")); } else { alert(t("UPSCAYL_CLOUD.INCORRECT_FIELDS_ALERT")); } }} >
setName(e.target.value)} /> setEmail(e.target.value)} />
); };