1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-24 07:30:19 +01:00

Update waitlist firebase

This commit is contained in:
Nayam Amarshe 2023-08-30 13:28:15 +05:30
parent 5fff5c18bd
commit 982f847267
3 changed files with 38 additions and 25 deletions

View File

@ -1,6 +1,6 @@
import { doc, setDoc } from "@firebase/firestore";
import { useState } from "react"; import { useState } from "react";
import { waitlistCollection } from "@common/firebase"; import { waitlistCollection } from "../firebase";
import { doc, setDoc } from "firebase/firestore";
const nameRegex = /^[A-Za-z\s.'-]+$/; const nameRegex = /^[A-Za-z\s.'-]+$/;
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
@ -30,21 +30,10 @@ export const UpscaylCloudModal = ({ show, setShow }) => {
<p>😴 Upscayl while you sleep</p> <p>😴 Upscayl while you sleep</p>
</div> </div>
<div className="gap-2 flex"> <form
<input className="flex flex-col items-center gap-3"
type="text" onSubmit={async (e) => {
className="input input-bordered" e.preventDefault();
placeholder="Name"
/>
<input
type="text"
className="input input-bordered"
placeholder="Email"
/>
</div>
<button
className="bg-success text-success-content rounded-2xl px-4 py-2"
onClick={async () => {
if ( if (
name && name &&
email && email &&
@ -52,14 +41,16 @@ export const UpscaylCloudModal = ({ show, setShow }) => {
emailRegex.test(email) emailRegex.test(email)
) { ) {
try { try {
const result = await setDoc(doc(waitlistCollection, email), { await setDoc(doc(waitlistCollection, email), {
name, name,
email, email,
}); });
} catch (error) { } catch (error) {
alert("Error joining the waitlist. Please try again later..."); alert("Error joining the waitlist. Please try again...");
return; return;
} }
setName("");
setEmail("");
alert( alert(
"Thank you for joining the waitlist! We will notify you when Upscayl Cloud is ready for you." "Thank you for joining the waitlist! We will notify you when Upscayl Cloud is ready for you."
); );
@ -67,8 +58,28 @@ export const UpscaylCloudModal = ({ show, setShow }) => {
alert("Please fill in all the fields correctly."); alert("Please fill in all the fields correctly.");
} }
}}> }}>
<div className="gap-2 flex">
<input
type="text"
className="input input-bordered"
placeholder="Name"
value={name}
onChange={(e) => setName(e.target.value)}
/>
<input
type="email"
className="input input-bordered"
placeholder="Email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
</div>
<button
type="submit"
className="bg-success text-success-content rounded-2xl px-4 py-2">
Join the waitlist Join the waitlist
</button> </button>
</form>
</div> </div>
<form method="dialog" className="modal-backdrop"> <form method="dialog" className="modal-backdrop">

View File

@ -20,9 +20,13 @@ const firebaseConfig = {
// Initialize Firebase // Initialize Firebase
const app = initializeApp(firebaseConfig); const app = initializeApp(firebaseConfig);
export const db = getFirestore(app); export const db = getFirestore(app);
console.log("🚀 => file: firebase.ts:23 => db:", db);
const createCollection = <T = DocumentData>(collectionName: string) => { const createCollection = <T = DocumentData>(collectionName: string) => {
return collection(db, collectionName) as CollectionReference<T>; return collection(db, collectionName) as CollectionReference<T>;
}; };
export const waitlistCollection = createCollection("waitlist"); export const waitlistCollection = createCollection<{
name: string;
email: string;
}>("waitlist");

View File

@ -457,9 +457,7 @@ const Home = () => {
<div className="pt-8 mac-titlebar"></div> <div className="pt-8 mac-titlebar"></div>
)} )}
{/* HEADER */} {/* HEADER */}
<div className="flex flex-row items-center">
<Header version={version} /> <Header version={version} />
</div>
<button <button
className="mb-5 rounded-btn p-1 mx-5 bg-success shadow-lg shadow-success/40 text-slate-50 animate-pulse text-sm" className="mb-5 rounded-btn p-1 mx-5 bg-success shadow-lg shadow-success/40 text-slate-50 animate-pulse text-sm"
onClick={() => { onClick={() => {