Skip to content

Commit

Permalink
apply form confirmation (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
IngridFuentes authored Feb 19, 2024
1 parent 2c8e7b7 commit ef22d21
Showing 1 changed file with 12 additions and 0 deletions.
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

0 comments on commit ef22d21

Please sign in to comment.