diff --git a/frontend/src/pages/Admin/Components/About/About.jsx b/frontend/src/pages/Admin/Components/About/About.jsx index f3bae7a2..6ac8601f 100644 --- a/frontend/src/pages/Admin/Components/About/About.jsx +++ b/frontend/src/pages/Admin/Components/About/About.jsx @@ -2,7 +2,6 @@ import React from "react"; import style from "./about-us.module.scss"; import { AiFillEdit } from "react-icons/ai"; import { AiOutlinePlus } from "react-icons/ai"; -import { Link } from "react-router-dom"; export function About(props) { return ( @@ -12,9 +11,9 @@ export function About(props) {
- props.setTab(14)} style={{ color: "white" }}> +
props.setTab(14)} style={{ color: "white" }}> ADD TEAM MEMBER - +
@@ -22,9 +21,9 @@ export function About(props) {

- props.setTab(14)} style={{ color: "red" }}> +

props.setTab(14)} style={{ color: "red" }}> CLICK HERE - +

diff --git a/frontend/src/pages/Admin/Components/AddTeamMember/AddTeamMember.jsx b/frontend/src/pages/Admin/Components/AddTeamMember/AddTeamMember.jsx index 5446cd93..23292d48 100644 --- a/frontend/src/pages/Admin/Components/AddTeamMember/AddTeamMember.jsx +++ b/frontend/src/pages/Admin/Components/AddTeamMember/AddTeamMember.jsx @@ -6,6 +6,7 @@ import MultiSelect from "react-multi-select-component"; import { Button2 } from "../../../../components/util/Button/index"; import { Grid } from "@material-ui/core"; import { SimpleToast } from "./../../../../components/util/Toast/Toast"; +import { END_POINT } from "../../../../config/api"; export function AddTeamMember() { const options = [ @@ -27,10 +28,12 @@ export function AddTeamMember() { const [formerrors, setFormErrors] = useState({}); const [teamError, setTeamError] = useState(); const [teams, setTeams] = useState([]); + const [selectTeam, setSelectTeam] = useState([]); const [picUrl, setPicUrl] = useState("./images/admin.png"); const [pic, setPic] = useState(); - const [openSuccess, setOpenSuccessToast] = React.useState(false); - + const [toastStatus,setToastStatus] = useState(false); + const [toastMessage,setToastMessage] = useState(""); + const [toastType,setToastType] = useState("") const schema = { fullName: Joi.string().required(), description: Joi.string().required(), @@ -85,7 +88,7 @@ export function AddTeamMember() { if (reason === "clickaway") { return; } - setOpenSuccessToast(false); + setToastStatus(false); }; const handleChange = (e) => { @@ -101,9 +104,8 @@ export function AddTeamMember() { setFormErrors(errors); }; - console.log("formerrors: ", formerrors); - const onSubmit = (e) => { + const onSubmit = async (e) => { e.preventDefault(); const errors = validate(); if (formdata["linkedin"] === "") { @@ -131,7 +133,15 @@ export function AddTeamMember() { console.log(errors); } else { //Call the Server - console.log("Submitted"); + const form = new FormData(); + form.append("fullName", formdata?.fullName); + form.append("description", formdata?.description); + form.append("linkedinUrl", formdata?.linkedin); + form.append("githubUrl", formdata.github); + form.append("twitterUrl", formdata.twitter); + form.append("teams", selectTeam); + form.append("image", pic); + await addTeamMember(form) const temp = { fullName: "", description: "", @@ -141,10 +151,29 @@ export function AddTeamMember() { }; setFormData(temp); setTeams([]); - setOpenSuccessToast(true); + setPicUrl("./images/admin.png") + setToastType("success") + setToastMessage("User added Successfully!") + setToastStatus(true); } return pic; }; + const addTeamMember = async (data) => { + try { + let url = `${END_POINT}/teamMember/addTeamMember`; + const response = await fetch(url, { + method: "POST", + headers: { + Authorization: `Bearer ${localStorage.getItem("token")}`, + }, + body: data, + }); + } catch (error) { + setToastMessage("Sorry! Error is adding team Member") + setToastType("error") + setToastStatus(true); + } + }; return (
@@ -288,7 +317,13 @@ export function AddTeamMember() { { + const selectedValues = selectedOptions.map( + (option) => option.value + ); + setSelectTeam(selectedValues); + setTeams(selectedOptions); + }} labelledBy={"Teams"} // Property name to display in the dropdown options className={styles["dropdown"]} /> @@ -310,12 +345,13 @@ export function AddTeamMember() {
- + severity={toastType} + />} ); }