diff --git a/app/styles/global.css b/app/styles/global.css index 14fda6a6..818afd98 100644 --- a/app/styles/global.css +++ b/app/styles/global.css @@ -1,3 +1,5 @@ +<<<<<<< Updated upstream +<<<<<<< Updated upstream @tailwind base; @tailwind components; @tailwind utilities; @@ -103,3 +105,7 @@ @apply absolute top-20 left-10 -rotate-6; } } +======= +>>>>>>> Stashed changes +======= +>>>>>>> Stashed changes diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 00000000..51b40b5e --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,171 @@ +import type { ActionFunction } from "@remix-run/node"; +import { Form, useActionData, useSubmit } from "@remix-run/react"; +import { Mail, CheckCircle2, ThumbsUp } from "lucide-react"; +import React, { useEffect, useState } from "react"; + +interface ActionData { + error?: string; + success?: boolean; +} + +const validateEmail = (email: string) => { + return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); +}; + +export const action: ActionFunction = async ({ request }) => { + const formInput = await request.formData(); + const name = formInput.get("name"); + const email = formInput.get("email"); + + if (typeof name !== "string" || typeof email !== "string") { + return { error: "Invalid form submission" }; + } + + if (!name || !validateEmail(email)) { + return { error: "Name and valid email are required" }; + } + + // try { + // const response = await fetch('https://jsonplaceholder.typicode.com/posts', { + // method: 'POST', + // headers: { + // 'Content-Type': 'application/json', + // }, + // body: JSON.stringify({ name, email }), + // }); + + // if (!response.ok) { + // throw new Error('Network response was not ok'); + // } + + // return { success: true }; + // } catch (error) { + // return { error: "Failed to submit the form" }; + // } +}; + +const WaitlistForm: React.FC = () => { + const actionData = useActionData(); + const [name, setName] = useState("John Doe"); + const [email, setEmail] = useState("john.doe@example.com"); + const [mounted, setMounted] = useState(false); + const [error, setError] = useState(null); + const [submit, setSubmit] = useState(false); + + useEffect(() => { + setMounted(true); + }, []); + + const handleSubmit = (event: React.FormEvent) => { + event.preventDefault(); + + let hasError = false; + + if (!name) { + setError("Your Name is required to proceed"); + hasError = true; + } else if (!validateEmail(email)) { + setError("Please input a valid email address"); + hasError = true; + } else { + setError(null); + } + + if (hasError) { + return; + } + + const formData = new FormData(); + formData.append("name", name); + formData.append("email", email); + setSubmit(true); + }; + + return ( +
+
+

+ {" "} + Deployment made easy +

+

+ You can level up your Saas production today +

+

+ Join our waitlist and get early access to our boilerplate +

+
+ { + submit ? ( +
+
+ + + + +
+

You're all signed up!

+
+ ) : ( +
+
+
+ + setName(e.target.value)} + placeholder="Meghan Grace" + className="input_style" + /> +
+ {mounted && error && ( +

+ {error.includes("Name") && error} +

+ )} +
+ + setEmail(e.target.value)} + placeholder="Enter email" + className="input_style" + /> +
+ {mounted && error && ( +

+ {error.includes("email") && error} +

+ )} + +
+ {mounted && actionData?.success && ( +

+ Successfully joined the waitlist! +

+ )} +
+ ) + } +
+ ); +}; + +export default WaitlistForm;