Fix guest-cart TypeScript so production Next builds succeed.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
0d6e98bf89
commit
f0d8276c3e
+14
-14
@@ -36,20 +36,20 @@ function parseItems(raw: string | null): CartItem[] {
|
||||
|
||||
/** Map storefront cart lines to the shared guest-cart shape (id = variant id). */
|
||||
export function toMeshkeeGuestItems(items: CartItem[]): MeshkeeGuestCartItem[] {
|
||||
return items
|
||||
.map((item) => {
|
||||
const variantId = (item.storeItemVariantId || item.id || "").trim();
|
||||
if (!variantId) return null;
|
||||
return {
|
||||
id: variantId,
|
||||
name: item.name || "محصول",
|
||||
slug: item.slug || undefined,
|
||||
price: item.price,
|
||||
image: item.image ?? null,
|
||||
quantity: Math.max(1, Math.floor(item.quantity) || 1),
|
||||
};
|
||||
})
|
||||
.filter((item): item is MeshkeeGuestCartItem => item != null);
|
||||
const result: MeshkeeGuestCartItem[] = [];
|
||||
for (const item of items) {
|
||||
const variantId = (item.storeItemVariantId || item.id || "").trim();
|
||||
if (!variantId) continue;
|
||||
result.push({
|
||||
id: variantId,
|
||||
name: item.name || "محصول",
|
||||
...(item.slug ? { slug: item.slug } : {}),
|
||||
price: item.price,
|
||||
image: item.image ?? null,
|
||||
quantity: Math.max(1, Math.floor(item.quantity) || 1),
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function encodeGuestCartForUrl(items: CartItem[]): string {
|
||||
|
||||
Reference in New Issue
Block a user