Fix guest-cart TypeScript so production Next builds succeed.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-25 16:48:07 +03:30
co-authored by Cursor
parent 0d6e98bf89
commit f0d8276c3e
+8 -8
View File
@@ -36,20 +36,20 @@ function parseItems(raw: string | null): CartItem[] {
/** Map storefront cart lines to the shared guest-cart shape (id = variant id). */ /** Map storefront cart lines to the shared guest-cart shape (id = variant id). */
export function toMeshkeeGuestItems(items: CartItem[]): MeshkeeGuestCartItem[] { export function toMeshkeeGuestItems(items: CartItem[]): MeshkeeGuestCartItem[] {
return items const result: MeshkeeGuestCartItem[] = [];
.map((item) => { for (const item of items) {
const variantId = (item.storeItemVariantId || item.id || "").trim(); const variantId = (item.storeItemVariantId || item.id || "").trim();
if (!variantId) return null; if (!variantId) continue;
return { result.push({
id: variantId, id: variantId,
name: item.name || "محصول", name: item.name || "محصول",
slug: item.slug || undefined, ...(item.slug ? { slug: item.slug } : {}),
price: item.price, price: item.price,
image: item.image ?? null, image: item.image ?? null,
quantity: Math.max(1, Math.floor(item.quantity) || 1), quantity: Math.max(1, Math.floor(item.quantity) || 1),
}; });
}) }
.filter((item): item is MeshkeeGuestCartItem => item != null); return result;
} }
export function encodeGuestCartForUrl(items: CartItem[]): string { export function encodeGuestCartForUrl(items: CartItem[]): string {