diff --git a/frontend/src/pages/Home/components/JoinUsForm/Form.jsx b/frontend/src/pages/Home/components/JoinUsForm/Form.jsx index a254277a..05fa566c 100644 --- a/frontend/src/pages/Home/components/JoinUsForm/Form.jsx +++ b/frontend/src/pages/Home/components/JoinUsForm/Form.jsx @@ -1,6 +1,8 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import Joi from "joi-browser"; import MultiSelect from "react-multi-select-component"; +import { SimpleToast } from "../../../../components/util/Toast"; +import { postJoinUs, PostJoinUs } from '../../../../service/JoinUs'; import styles from "./form.module.scss"; import { Button2 } from "../../../../components/util/Button/index"; @@ -9,16 +11,18 @@ export const JoinUsForm = (props) => { const [formdata, setFormData] = useState({ name: "", - phone: "", + contact: "", email: "", - link: "", - desc: "", - other: "", - dept: "", + linkdin: "", + description: "", + otherDomain: "", + department: "", year: null, college: "", }); + const [isSubmitted, setIsSubmitted] = useState(false) + const options = [ { label: "Machine Learning", value: "ml" }, { label: "Artificial Intelligence", value: "ai" }, @@ -36,16 +40,21 @@ export const JoinUsForm = (props) => { const [domainError, setDomainError] = useState(); const [formerrors, setFormErrors] = useState({}); + const [toast, setToast] = useState({ + toastStatus: false, + toastType: "", + toastMessage: "", + }); const schema = { name: Joi.string().required(), - phone: Joi.number().allow(""), - email: Joi.string().email().required(), - link: Joi.string().uri().allow(""), - desc: Joi.string().allow(""), - other: Joi.string().allow(""), - dept: Joi.string().allow(""), - year: Joi.number().required(), + contact: Joi.number().required(), + email: Joi.string().email().required().required(), + linkdin: Joi.string().uri().required(), + description: Joi.string().required(), + otherDomain: Joi.string(), + department: Joi.string().required(), + year: Joi.number().required().required(), college: Joi.string().required(), }; @@ -80,7 +89,7 @@ export const JoinUsForm = (props) => { setFormErrors(errors); }; - const handleSubmit = (e) => { + const handleSubmit = async (e) => { e.preventDefault(); const errors = validate(); console.log(errors); @@ -91,375 +100,401 @@ export const JoinUsForm = (props) => { } if (errors === null || Object.keys(errors).length === 0) { setFormErrors({}); - console.log("Submitted", formdata); + let data = { ...formdata, interestedDomain: domains.map((value)=>value.label) } + let res = await postJoinUs(data, setToast) + if (res == true) + setIsSubmitted(true) } else { setFormErrors(errors); + setToast({ toastStatus: true, toastMessage: "Fill all the fields", toastType: "error" }) } }; - console.log("form error: ", formerrors); - console.log("form data: ", formdata, domains); - return ( -
-
- -
+ <>
+
+ +
-

- Join Us Form -

-
-
-
-
-
- - -
- {formerrors["name"] ? ( -
* {formerrors["name"]}
- ) : ( -
   
- )} -
-
-
-
-
- - -
- {formerrors["phone"] ? ( -
* {formerrors["phone"]}
- ) : ( -
   
- )} -
-
-
-
-
-
- - -
- {formerrors["email"] &&
* {formerrors["email"]}
} -
-
-
-
-
- - -
- {formerrors["link"] ? ( -
* {formerrors["link"]}
- ) : ( -
   
- )} + { + isSubmitted ? + +
+

Hello There !

+
+

+ Your request is in process! 😄
+ we will get back to you soon! +

-
+ + :
- - -
- {formerrors["desc"] ? ( -
* {formerrors["desc"]}
- ) : ( -
   
- )} -
-
-
- - - -
- {domainError ? ( -
{domainError}
- ) : ( -
   
- )} -
-
-
-
- - -
-
-
-
- - -
-
-
- -
-
-
- - + Join Us Form + + +
+
+
+
+ + +
+ {formerrors["name"] ? ( +
* {formerrors["name"]}
+ ) : ( +
   
+ )} +
+
+
+
+
+ + +
+ {formerrors["phone"] ? ( +
* {formerrors["phone"]}
+ ) : ( +
   
+ )} +
+
+
+
+
+
+ + +
+ {formerrors["email"] &&
* {formerrors["email"]}
} +
+
+
+
+
+ + +
+ {formerrors["link"] ? ( +
* {formerrors["link"]}
+ ) : ( +
   
+ )} +
+
- - + > + +
+ {formerrors["desc"] ? ( +
* {formerrors["desc"]}
+ ) : ( +
   
+ )} +
- + Interested Domains + + - + +
+ {domainError ? ( +
{domainError}
+ ) : ( +
   
+ )} +
+
+
+
+ + +
+
+
+
+ + +
- + Year of Study + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ {formerrors["year"] ? ( +
* {formerrors["year"]}
+ ) : ( +
   
+ )} +
+
+
+
+ + +
+ {formerrors["college"] ? ( +
* {formerrors["college"]}
+ ) : ( +
   
+ )} +
+
+
+
+ -
-
-
- {formerrors["year"] ? ( -
* {formerrors["year"]}
- ) : ( -
   
- )} -
-
-
-
- - -
- {formerrors["college"] ? ( -
* {formerrors["college"]}
- ) : ( -
   
- )} -
-
+
-
- -
-
- + }
-
+ {toast.toastStatus && ( + { setToast({ toastStatus: false, toastMessage: "", toastType: '' }) }} + severity={toast.toastType} + /> + )} + ); }; diff --git a/frontend/src/pages/Home/components/JoinUsForm/form.module.scss b/frontend/src/pages/Home/components/JoinUsForm/form.module.scss index 448c06de..435cf9ea 100644 --- a/frontend/src/pages/Home/components/JoinUsForm/form.module.scss +++ b/frontend/src/pages/Home/components/JoinUsForm/form.module.scss @@ -201,9 +201,12 @@ --rmsc-border: #ccc !important; --rmsc-gray: #aaa !important; --rmsc-bg: #333333 !important; - --rmsc-p: 10px !important; /* Spacing */ - --rmsc-radius: 4px !important; /* Radius */ - --rmsc-h: 38px !important; /* Height */ + --rmsc-p: 10px !important; + /* Spacing */ + --rmsc-radius: 4px !important; + /* Radius */ + --rmsc-h: 38px !important; + /* Height */ } .dropdown { @@ -211,9 +214,12 @@ --rmsc-selected: #474343 !important; --rmsc-border: #838383 !important; --rmsc-bg: #e7e7e7 !important; - --rmsc-p: 10px !important; /* Spacing */ - --rmsc-radius: 4px !important; /* Radius */ - --rmsc-h: 38px !important; /* Height */ + --rmsc-p: 10px !important; + /* Spacing */ + --rmsc-radius: 4px !important; + /* Radius */ + --rmsc-h: 38px !important; + /* Height */ } .valid { @@ -284,7 +290,7 @@ background-color: transparent; } -.checkbox-item input[type="checkbox"]:checked + label:after { +.checkbox-item input[type="checkbox"]:checked+label:after { width: 20px; height: 20px; position: absolute; @@ -292,11 +298,9 @@ left: 8px; content: " "; display: block; - background-image: linear-gradient( - to right, - rgba(255, 0, 90, 1), - rgba(10, 24, 61, 1) - ); + background-image: linear-gradient(to right, + rgba(255, 0, 90, 1), + rgba(10, 24, 61, 1)); border: 4px solid whitesmoke; } @@ -307,7 +311,7 @@ margin-bottom: 10px; } -.radio-item input[type="radio"]:checked + label:after { +.radio-item input[type="radio"]:checked+label:after { border-radius: 50%; width: 20px; height: 20px; @@ -319,12 +323,10 @@ border: 4px solid whitesmoke; } -.radio-item-light input[type="radio"]:checked + label:after { - background-image: linear-gradient( - to right, - rgba(255, 0, 90, 1), - rgba(10, 24, 61, 1) - ); +.radio-item-light input[type="radio"]:checked+label:after { + background-image: linear-gradient(to right, + rgba(255, 0, 90, 1), + rgba(10, 24, 61, 1)); } .validation { @@ -333,7 +335,7 @@ } // for dark theme -.radio-item-dark input[type="radio"]:checked + label:after { +.radio-item-dark input[type="radio"]:checked+label:after { background-image: linear-gradient(to right, #2b5876, #4e4376); } @@ -481,3 +483,30 @@ input[type="date"]:not(:valid):before { text-align: left; } } + +.goodbye-card { + width: 60%; + height: auto; + background-color: #e7e7e7; + margin: 20% auto; + border-radius: 10px; + box-shadow: 5px 5px 15px #888888, -5px -5px 15px #ffffff; +} + +.card-heading { + font-size: 1.6rem; + margin-bottom: 3px; + padding: 9px 0; + text-align: center; +} + +.inside-card { + width: 75%; + margin: 0 auto; + padding-bottom: 32px; +} + +.inside-card p { + padding: 0px; + font-size: 1.3rem; +} \ No newline at end of file diff --git a/frontend/src/service/JoinUs.jsx b/frontend/src/service/JoinUs.jsx new file mode 100644 index 00000000..6f770c32 --- /dev/null +++ b/frontend/src/service/JoinUs.jsx @@ -0,0 +1,32 @@ +import { END_POINT } from "../config/api"; +import { showToast } from "./toastService"; + +const postJoinUs = async (data, setToast) => { + try { + showToast(setToast,"Loading...","info") + const response = await fetch(`${END_POINT}/joinUs/`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(data), + }); + + if (response.ok) { + const _data = await response.json(); + showToast(setToast, "Form submitted successfully!", "success"); + return true; + } else { + const errorData = await response.json(); + console.error("Error:", errorData); + showToast(setToast, "Something went wrong", "error"); + return false; + } + } catch (err) { + console.error("Network Error:", err); + showToast(setToast, "Something went wrong", "error"); + return false; + } + }; + + export { postJoinUs }; \ No newline at end of file