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

Function updatePartQuantity

app/dashboardPage.tsx:370–396  ·  view source on GitHub ↗
(partId: number, quantity: number)

Source from the content-addressed store, hash-verified

368 }
369
370 async function updatePartQuantity(partId: number, quantity: number) {
371 setLoading(true);
372 try {
373 const res = await fetch("/api/parts/update", {
374 method: "POST",
375 body: JSON.stringify({ id: partId, quantity }),
376 }).then((response) =>
377 response
378 .json()
379 .then((data) => ({ status: response.status, body: data }))
380 );
381 if (res.status !== 200) {
382 throw new Error(res.body.message);
383 }
384 console.log(res.body);
385 if (res.status == 200) {
386 notifications.show({
387 title: "Quantity Updated",
388 message: `The quantity of ${res.body.body.productCode} was successfully updated to ${quantity}!`,
389 });
390 updatePartInState(res.body.body);
391 }
392 } catch (e: ErrorCallback | any) {
393 console.error(e.message);
394 }
395 setLoading(false);
396 }
397
398 async function navigatePage(page: number) {
399 setPage(page);

Callers 1

PartItemFunction · 0.85

Calls 1

updatePartInStateFunction · 0.85

Tested by

no test coverage detected