diff --git a/app/api/account/wishlist/route.ts b/app/api/account/wishlist/route.ts index ccc4552..fec315f 100644 --- a/app/api/account/wishlist/route.ts +++ b/app/api/account/wishlist/route.ts @@ -20,7 +20,7 @@ export async function POST(request: Request) { return NextResponse.json({ ok: false, reason: "Ungültiges Produkt." }, { status: 400 }); } - const result = await toggleWishlistItem(session.token, productId, variant); + const result = await toggleWishlistItem(session.token, session.customer.id, productId, variant); if (!result.ok) return NextResponse.json({ ok: false, reason: "Merkliste konnte nicht aktualisiert werden." }, { status: 500 }); return NextResponse.json({ ok: true, wishlisted: result.wishlisted }); } diff --git a/app/lib/customerAuth.ts b/app/lib/customerAuth.ts index d1f7d49..af7358a 100644 --- a/app/lib/customerAuth.ts +++ b/app/lib/customerAuth.ts @@ -435,17 +435,19 @@ export async function getWishlist(token: string, customerId: number): Promise { const createRes = await fetch(`${PAYLOAD_URL}/api/wishlist-items`, { method: "POST", headers: { Authorization: `JWT ${token}`, "Content-Type": "application/json" }, - body: JSON.stringify({ product: productId, variant }), + body: JSON.stringify({ customer: customerId, product: productId, variant }), }); if (createRes.ok) return { ok: true, wishlisted: true }; const findParams = new URLSearchParams({ + "where[customer][equals]": String(customerId), "where[product][equals]": String(productId), "where[variant][equals]": variant, depth: "0",