MCPcopy Create free account
hub / github.com/PartPilotLab/PartPilot / deletePart

Function deletePart

app/dashboardPage.tsx:328–368  ·  view source on GitHub ↗
(partId: number)

Source from the content-addressed store, hash-verified

326 }
327
328 async function deletePart(partId: number) {
329 // setLoading(true)
330 try {
331 const res = await fetch("/api/parts/delete", {
332 method: "POST",
333 body: JSON.stringify({ id: partId }),
334 }).then((response) =>
335 response
336 .json()
337 .then((data) => ({ status: response.status, body: data }))
338 );
339 if (res.status !== 200) {
340 console.log(res.body.message);
341 }
342 if (res.status == 200) {
343 if (
344 Math.ceil(itemCountState / itemsPerPage) >
345 Math.ceil(res.body.itemCount) &&
346 activePage == Math.ceil(itemCountState / itemsPerPage)
347 ) {
348 navigatePage(activePage - 1);
349 } else {
350 getParts(activePage);
351 }
352 setParentCatalogNamesState(
353 res.body.parentCatalogNames
354 .filter((item) => item.parentCatalogName !== null)
355 .map((item) => item.parentCatalogName)
356 );
357 setItemCountState(res.body.itemCount);
358 notifications.show({
359 title: "Part Deleted",
360 message: `The part ${res.body.body.productCode} was successfully deleted!`,
361 });
362 }
363 console.log(res.body);
364 // await getParts();
365 } catch (e: ErrorCallback | any) {
366 console.error(e.message);
367 }
368 }
369
370 async function updatePartQuantity(partId: number, quantity: number) {
371 setLoading(true);

Callers 1

PartItemFunction · 0.85

Calls 2

navigatePageFunction · 0.85
getPartsFunction · 0.85

Tested by

no test coverage detected