Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply form confirmation #551

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/components/forms/apply-form.tsx
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 {
firstName: string;
Expand All @@ -24,6 +26,8 @@ interface IFormValues {

const ApplyForm = () => {
const [message, setMessage] = useState("");
const [showEmojiRain, setShowEmojiRain] = useState<boolean>(false);

const {
register,
handleSubmit,
Expand All @@ -35,6 +39,10 @@ const ApplyForm = () => {
try {
await axios.post("/api/apply", data);
setMessage("Thank you for your application!");
setShowEmojiRain(true);

// Optional: Hide the EmojiRain after a set duration
setTimeout(() => setShowEmojiRain(false), 5000); // Adjust duration as necessary
reset();
} catch (error) {
setMessage("Failed to submit the form. Please try again later.");
Expand Down Expand Up @@ -348,6 +356,10 @@ const ApplyForm = () => {
>
Apply
</Button>
{message && (
<Feedback state="success">{message}</Feedback>
)}
{showEmojiRain && <EmojiRain />}
</form>
</div>
);
Expand Down
Loading