MCPcopy Create free account
hub / github.com/Bitbox-Connect/Bitbox / editProject

Function editProject

client/src/context/ProjectState.jsx:74–98  ·  view source on GitHub ↗
(id, title, description, gitHubLink, youTubeLink)

Source from the content-addressed store, hash-verified

72
73 // Edit a Project
74 const editProject = async (id, title, description, gitHubLink, youTubeLink) => {
75 // API CALL - Update Project
76 const response = await fetch(`${VITE_SERVER_PORT}/api/projects/updateproject/${id}`, {
77 method: "PUT",
78 headers: {
79 "Content-Type": "application/json",
80 "auth-token": localStorage.getItem('token')
81 },
82 body: JSON.stringify({ title, description, gitHubLink, youTubeLink }),
83 });
84 await response.json();
85
86 let newProjects = JSON.parse(JSON.stringify(userProjects));
87 for (let index = 0; index < newProjects.length; index++) {
88 const element = newProjects[index];
89 if (element._id === id) {
90 newProjects[index].title = title;
91 newProjects[index].description = description;
92 newProjects[index].gitHubLink = gitHubLink;
93 newProjects[index].youTubeLink = youTubeLink;
94 break;
95 }
96 }
97 setUserProjects(newProjects)
98 }
99
100 // Function to filter projects based on search query
101 // const handleSearch = (searchQuery) => {

Callers 1

handleClickFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected