fix: add an indication that the newsletter subscriber is already subscribed
Some checks are pending
Deploy Next.js application / deploy (push) Waiting to run
Some checks are pending
Deploy Next.js application / deploy (push) Waiting to run
This commit is contained in:
parent
a5f89d33af
commit
004ecc5c60
1 changed files with 9 additions and 1 deletions
|
@ -16,7 +16,7 @@ const happyMonkey = Happy_Monkey({
|
||||||
|
|
||||||
const Newsletter = () => {
|
const Newsletter = () => {
|
||||||
const [submission, setSubmission] = useState<
|
const [submission, setSubmission] = useState<
|
||||||
"idle" | "loading" | "success" | "error"
|
"idle" | "loading" | "success" | "already" | "error"
|
||||||
>("idle");
|
>("idle");
|
||||||
const [input, setInput] = useState<string>("");
|
const [input, setInput] = useState<string>("");
|
||||||
const [captchaToken, setCaptchaToken] = useState<string | null>(null);
|
const [captchaToken, setCaptchaToken] = useState<string | null>(null);
|
||||||
|
@ -49,6 +49,9 @@ const Newsletter = () => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
setSubmission("success");
|
setSubmission("success");
|
||||||
setInput("");
|
setInput("");
|
||||||
|
} else if (response.status == 409) {
|
||||||
|
setSubmission("already");
|
||||||
|
setInput("");
|
||||||
} else {
|
} else {
|
||||||
setSubmission("error");
|
setSubmission("error");
|
||||||
}
|
}
|
||||||
|
@ -120,6 +123,11 @@ const Newsletter = () => {
|
||||||
🎉 Subscribed successfully...
|
🎉 Subscribed successfully...
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
{submission === "already" && (
|
||||||
|
<p className="dark:invert text-sm text-center text-green-500">
|
||||||
|
🙏 You're already subscribed...
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
{submission === "error" && (
|
{submission === "error" && (
|
||||||
<p className="dark:invert text-sm text-center text-red-500">
|
<p className="dark:invert text-sm text-center text-red-500">
|
||||||
😥 Something went wrong...
|
😥 Something went wrong...
|
||||||
|
|
Loading…
Reference in a new issue