Fix route handler method for delete/updating cart

This commit is contained in:
microdotmatrix 2023-05-12 16:38:57 -05:00
parent a0c0d10fae
commit bc1260b489
3 changed files with 5 additions and 5 deletions

View File

@ -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 { lineId } = await req.json();

View File

@ -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
})

View File

@ -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 ? (
<LoadingDots className="bg-black dark:bg-white" />
) : 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>
);