From bc1260b489eac563663af3465db7663260813f1f Mon Sep 17 00:00:00 2001 From: microdotmatrix Date: Fri, 12 May 2023 16:38:57 -0500 Subject: [PATCH] Fix route handler method for delete/updating cart --- app/api/cart/route.ts | 2 +- components/cart/delete-item-button.tsx | 2 +- components/cart/edit-item-quantity-button.tsx | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/api/cart/route.ts b/app/api/cart/route.ts index 15f5fb09f..c20bac3f8 100644 --- a/app/api/cart/route.ts +++ b/app/api/cart/route.ts @@ -55,7 +55,7 @@ export async function PUT(req: NextRequest): Promise { } } -export async function DELETE(req: NextRequest): Promise { +export async function PATCH(req: NextRequest): Promise { const cartId = cookies().get('cartId')?.value; const { lineId } = await req.json(); diff --git a/components/cart/delete-item-button.tsx b/components/cart/delete-item-button.tsx index 789a87754..973388267 100644 --- a/components/cart/delete-item-button.tsx +++ b/components/cart/delete-item-button.tsx @@ -14,7 +14,7 @@ export default function DeleteItemButton({ item }: { item: CartItem }) { setRemoving(true); const response = await fetch(`/api/cart`, { - method: 'DELETE', + method: 'PATCH', body: JSON.stringify({ lineId: item.id }) diff --git a/components/cart/edit-item-quantity-button.tsx b/components/cart/edit-item-quantity-button.tsx index 2249bd1aa..5986234b4 100644 --- a/components/cart/edit-item-quantity-button.tsx +++ b/components/cart/edit-item-quantity-button.tsx @@ -21,7 +21,7 @@ export default function EditItemQuantityButton({ setEditing(true); const response = await fetch(`/api/cart`, { - method: type === 'minus' && item.quantity - 1 === 0 ? 'DELETE' : 'PUT', + method: type === 'minus' && item.quantity - 1 === 0 ? 'PATCH' : 'PUT', body: JSON.stringify({ lineId: item.id, variantId: item.merchandise.id, @@ -58,9 +58,9 @@ export default function EditItemQuantityButton({ {editing ? ( ) : type === 'plus' ? ( - + ) : ( - + )} );