mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 06:56:59 +00:00
Fix route handler method for delete/updating cart
This commit is contained in:
parent
a0c0d10fae
commit
bc1260b489
@ -55,7 +55,7 @@ export async function PUT(req: NextRequest): Promise<Response> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function DELETE(req: NextRequest): Promise<Response> {
|
export async function PATCH(req: NextRequest): Promise<Response> {
|
||||||
const cartId = cookies().get('cartId')?.value;
|
const cartId = cookies().get('cartId')?.value;
|
||||||
const { lineId } = await req.json();
|
const { lineId } = await req.json();
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ export default function DeleteItemButton({ item }: { item: CartItem }) {
|
|||||||
setRemoving(true);
|
setRemoving(true);
|
||||||
|
|
||||||
const response = await fetch(`/api/cart`, {
|
const response = await fetch(`/api/cart`, {
|
||||||
method: 'DELETE',
|
method: 'PATCH',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
lineId: item.id
|
lineId: item.id
|
||||||
})
|
})
|
||||||
|
@ -21,7 +21,7 @@ export default function EditItemQuantityButton({
|
|||||||
setEditing(true);
|
setEditing(true);
|
||||||
|
|
||||||
const response = await fetch(`/api/cart`, {
|
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({
|
body: JSON.stringify({
|
||||||
lineId: item.id,
|
lineId: item.id,
|
||||||
variantId: item.merchandise.id,
|
variantId: item.merchandise.id,
|
||||||
@ -58,9 +58,9 @@ export default function EditItemQuantityButton({
|
|||||||
{editing ? (
|
{editing ? (
|
||||||
<LoadingDots className="bg-black dark:bg-white" />
|
<LoadingDots className="bg-black dark:bg-white" />
|
||||||
) : type === 'plus' ? (
|
) : type === 'plus' ? (
|
||||||
<PlusIcon className="h-4 w-4" />
|
<PlusIcon className="w-4 h-4" />
|
||||||
) : (
|
) : (
|
||||||
<MinusIcon className="h-4 w-4" />
|
<MinusIcon className="w-4 h-4" />
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user