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

Adding Team Member fixed #1123

Merged
merged 8 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
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
21 changes: 10 additions & 11 deletions frontend/src/pages/Admin/Components/AddTeamMember/AddTeamMember.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export function AddTeamMember() {
setFormErrors(errors);
};


const onSubmit = async (e) => {
e.preventDefault();
const errors = validate();
Expand Down Expand Up @@ -135,15 +134,15 @@ export function AddTeamMember() {
console.log(errors);
} else {
//Call the Server
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 postTeamMember(form,setToast,toast);
const form = new Object();
form["fullName"] = formdata?.fullName;
form["description"] = formdata?.description;
form["linkedinUrl"] = formdata?.linkedin;
form["githubUrl"] = formdata.github;
form["twitterUrl"] = formdata.twitter;
form["teams"] = selectTeam;
form["image"] = pic;
await postTeamMember(form, setToast, toast);
const temp = {
fullName: "",
description: "",
Expand Down Expand Up @@ -328,7 +327,7 @@ export function AddTeamMember() {
</div>
</div>
</div>

{toast.toastStatus && (
<SimpleToast
open={toast.toastStatus}
Expand Down
44 changes: 26 additions & 18 deletions frontend/src/service/About.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { DELETE_FAIL, DELETE_SUCCESS, GET_FAIL, GET_SUCCESS, POST_FAIL, POST_SUCCUSS } from "../common/constants";
import {
DELETE_FAIL,
DELETE_SUCCESS,
GET_FAIL,
GET_SUCCESS,
POST_FAIL,
POST_SUCCUSS,
} from "../common/constants";
import { END_POINT } from "../config/api";

const getTeamMembers = async (setToast, toast) => {
Expand All @@ -12,22 +19,22 @@ const getTeamMembers = async (setToast, toast) => {
});
const data = await response.json();
const _data = data.map((item) => {
return {
...item,
teams: item.teams[0].split(","),
};
});
let _image = [];
await _data?.map((item) => {
let formattedPath = item.image?.replace(/\\/g, "/");
if (formattedPath?.startsWith("uploads/")) {
formattedPath = formattedPath.replace("uploads/", "");
if (formattedPath) {
formattedPath = `${END_POINT}/${formattedPath}`;
}
return {
...item,
teams: item.teams,
};
});
let _image = [];
await _data?.map((item) => {
let formattedPath = item.image?.replace(/\\/g, "/");
if (formattedPath?.startsWith("uploads/")) {
formattedPath = formattedPath.replace("uploads/", "");
if (formattedPath) {
formattedPath = `${END_POINT}/${formattedPath}`;
}
_image.push({ image: formattedPath, id: item._id });
});
}
_image.push({ image: formattedPath, id: item._id });
});

setToast({
...toast,
Expand All @@ -47,12 +54,13 @@ const getTeamMembers = async (setToast, toast) => {
}
};

const postTeamMember = async (data,setToast,toast) => {
const postTeamMember = async (data, setToast, toast) => {
try {
const response = await fetch(`${END_POINT}/teamMember/addTeamMember`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
body: JSON.stringify(data),
});
Expand Down Expand Up @@ -105,4 +113,4 @@ const deleteTeamMember = async (id, setToast, toast) => {
}
};

export { getTeamMembers, postTeamMember, deleteTeamMember};
export { getTeamMembers, postTeamMember, deleteTeamMember };
Loading