-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mentor form-EmojiRain small changes * mentor form confirmation * mentor form confirmation * bg "light" added * bg light
- Loading branch information
1 parent
3b2f77f
commit 2c8e7b7
Showing
2 changed files
with
34 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import EmojiRain from "@components/EmojiRain"; | ||
import { useState } from "react"; | ||
import { useForm, SubmitHandler } from "react-hook-form"; | ||
import axios from "axios"; | ||
import Input from "@ui/form-elements/input"; | ||
import Button from "@ui/button"; | ||
import { hasKey } from "@utils/methods"; | ||
import Feedback from "@ui/form-elements/feedback"; | ||
|
||
interface IFormValues { | ||
name: string; | ||
|
@@ -17,6 +19,8 @@ interface IFormValues { | |
|
||
const MentorForm = () => { | ||
const [message, setMessage] = useState(""); | ||
const [showEmojiRain, setShowEmojiRain] = useState<boolean>(false); | ||
|
||
const { | ||
register, | ||
handleSubmit, | ||
|
@@ -28,6 +32,10 @@ const MentorForm = () => { | |
try { | ||
await axios.post("/api/mentor", data); | ||
setMessage("Thank you for your registration!"); | ||
setShowEmojiRain(true); | ||
|
||
setTimeout(() => setShowEmojiRain(false), 5000); | ||
|
||
reset(); | ||
} catch (error) { | ||
setMessage("Failed to submit the form. Please try again later."); | ||
|
@@ -37,7 +45,6 @@ const MentorForm = () => { | |
return ( | ||
<div className="tw-px-4 md:tw-px-[250px]"> | ||
<h3 className="tw-text-h2 tw-mb-5">Register</h3> | ||
{message && <p>{message}</p>} | ||
<form onSubmit={handleSubmit(onSubmit)} noValidate> | ||
<div className="tw-mb-7.5"> | ||
<label | ||
|
@@ -49,6 +56,7 @@ const MentorForm = () => { | |
<Input | ||
id="name" | ||
placeholder="Jody Grinder" | ||
bg="light" | ||
feedbackText={errors?.name?.message} | ||
state={hasKey(errors, "name") ? "error" : "success"} | ||
showState={!!hasKey(errors, "name")} | ||
|
@@ -67,6 +75,7 @@ const MentorForm = () => { | |
<Input | ||
id="email" | ||
placeholder="[email protected]" | ||
bg="light" | ||
feedbackText={errors?.email?.message} | ||
state={hasKey(errors, "email") ? "error" : "success"} | ||
showState={!!hasKey(errors, "email")} | ||
|
@@ -89,6 +98,7 @@ const MentorForm = () => { | |
<Input | ||
id="branch-of-service" | ||
placeholder="Civilian" | ||
bg="light" | ||
feedbackText={errors?.["branch-of-service"]?.message} | ||
state={ | ||
hasKey(errors, "branch-of-service") | ||
|
@@ -111,6 +121,7 @@ const MentorForm = () => { | |
<Input | ||
id="technical-expertise" | ||
placeholder="Javascript, React, Node, etc." | ||
bg="light" | ||
feedbackText={errors?.["technical-expertise"]?.message} | ||
state={ | ||
hasKey(errors, "technical-expertise") | ||
|
@@ -133,6 +144,7 @@ const MentorForm = () => { | |
<Input | ||
id="github-portfolio-or-linkedin" | ||
placeholder="github.com/jody-fake-profile" | ||
bg="light" | ||
feedbackText={ | ||
errors?.["github-portfolio-or-linkedin"]?.message | ||
} | ||
|
@@ -160,6 +172,7 @@ const MentorForm = () => { | |
<Input | ||
id="location" | ||
placeholder="Washington, DC" | ||
bg="light" | ||
feedbackText={errors?.location?.message} | ||
state={hasKey(errors, "location") ? "error" : "success"} | ||
showState={!!hasKey(errors, "location")} | ||
|
@@ -178,6 +191,7 @@ const MentorForm = () => { | |
<Input | ||
id="employer-restrictions" | ||
placeholder="None" | ||
bg="light" | ||
feedbackText={ | ||
errors?.["employer-restrictions"]?.message | ||
} | ||
|
@@ -200,6 +214,10 @@ const MentorForm = () => { | |
> | ||
Register | ||
</Button> | ||
{message && ( | ||
<Feedback state="success">{message}</Feedback> | ||
)} | ||
{showEmojiRain && <EmojiRain />} | ||
</form> | ||
</div> | ||
); | ||
|