From 7b7c3efb65515e0ee8a03f58736aa95b2fb6bc8c Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 18 Jun 2026 12:08:34 -0400 Subject: [PATCH] Fix CartDrawer build error: move grouping logic out of JSX The IIFE with an inline type declaration inside a JSX ternary didn't compile. Pulled renderEntry and cartGroups into plain variables above the cartBody const so the JSX stays clean. Co-Authored-By: Claude Sonnet 4.6 --- estore/src/components/CartDrawer.tsx | 207 +++++++++++++-------------- 1 file changed, 102 insertions(+), 105 deletions(-) diff --git a/estore/src/components/CartDrawer.tsx b/estore/src/components/CartDrawer.tsx index fda80cc..dac6f1e 100644 --- a/estore/src/components/CartDrawer.tsx +++ b/estore/src/components/CartDrawer.tsx @@ -405,121 +405,118 @@ export default function CartDrawer() { // ── Step content ─────────────────────────────────────────────────────────── + const renderEntry = (entry: CartEntry, inBouquet = false) => ( +
+
+ {entry.product.imageUrls[0] && ( + {entry.product.name} + )} +
+
+ {entry.product.name} +
+ {!inBouquet && ( + + )} + +
+
+
+ + {entry.quantity} + + {entry.product.price && ( + {fmt(entryUnitPrice(entry) * entry.quantity)} + )} +
+ {entry.selectedColors.length > 0 && ( +
+ Colors: {entry.selectedColors.join(', ')} +
+ )} + {Object.entries(entry.modifierChoices).map(([listId, optIds]) => { + if (!optIds.length) return null + const ml = entry.product.modifiers?.find((m) => m.id === listId) + if (!ml) return null + const labels = optIds.map((id) => { + const opt = ml.options.find((o) => o.id === id) + if (!opt) return id + return opt.priceDelta ? `${opt.name} (+${fmt(opt.priceDelta)})` : opt.name + }) + return ( +
+ {ml.name}: {labels.join(', ')} +
+ ) + })} + {entry.notes && ( +
+ “{entry.notes}” +
+ )} +
+
+
+ ) + + const cartGroups: Array< + | { kind: 'single'; entry: CartEntry } + | { kind: 'bouquet'; groupId: string; items: CartEntry[] } + > = [] + const seenGroups = new Set() + entries.forEach((e) => { + if (!e.bouquetGroupId) { + cartGroups.push({ kind: 'single', entry: e }) + } else if (!seenGroups.has(e.bouquetGroupId)) { + seenGroups.add(e.bouquetGroupId) + cartGroups.push({ kind: 'bouquet', groupId: e.bouquetGroupId, items: entries.filter((x) => x.bouquetGroupId === e.bouquetGroupId) }) + } + }) + const cartBody = ( <> {entries.length === 0 ? (

Your order is empty.
Pick something from the shop!

- ) : (() => { - // Build render groups: bouquet entries grouped, regular entries standalone - type RenderGroup = - | { kind: 'single'; entry: CartEntry } - | { kind: 'bouquet'; groupId: string; items: CartEntry[] } - const groups: RenderGroup[] = [] - const seen = new Set() - entries.forEach((e) => { - if (!e.bouquetGroupId) { - groups.push({ kind: 'single', entry: e }) - } else if (!seen.has(e.bouquetGroupId)) { - seen.add(e.bouquetGroupId) - groups.push({ kind: 'bouquet', groupId: e.bouquetGroupId, items: entries.filter((x) => x.bouquetGroupId === e.bouquetGroupId) }) - } - }) - - const renderEntry = (entry: CartEntry, inBouquet = false) => ( -
-
- {entry.product.imageUrls[0] && ( - {entry.product.name} - )} -
-
- {entry.product.name} -
- {!inBouquet && ( - - )} - -
-
-
- - {entry.quantity} - - {entry.product.price && ( - {fmt(entryUnitPrice(entry) * entry.quantity)} - )} -
- {entry.selectedColors.length > 0 && ( -
- Colors: {entry.selectedColors.join(', ')} -
- )} - {Object.entries(entry.modifierChoices).map(([listId, optIds]) => { - if (!optIds.length) return null - const ml = entry.product.modifiers?.find((m) => m.id === listId) - if (!ml) return null - const labels = optIds.map((id) => { - const opt = ml.options.find((o) => o.id === id) - if (!opt) return id - return opt.priceDelta ? `${opt.name} (+${fmt(opt.priceDelta)})` : opt.name - }) - return ( -
- {ml.name}: {labels.join(', ')} -
- ) - })} - {entry.notes && ( -
- “{entry.notes}” -
- )} + ) : ( + cartGroups.map((group) => { + if (group.kind === 'single') return renderEntry(group.entry) + const bouquetTotal = group.items.reduce((sum, e) => sum + entryUnitPrice(e) * e.quantity, 0) + return ( +
+
+ Your Bouquet +
+ {bouquetTotal > 0 && {fmt(bouquetTotal)}} +
+ {group.items.map((e) => renderEntry(e, true))}
) - - return groups.map((group) => { - if (group.kind === 'single') return renderEntry(group.entry) - - const bouquetTotal = group.items.reduce((sum, e) => sum + entryUnitPrice(e) * e.quantity, 0) - return ( -
-
- Your Bouquet -
- {bouquetTotal > 0 && {fmt(bouquetTotal)}} - -
-
- {group.items.map((e) => renderEntry(e, true))} -
- ) - }) - })() + }) )} )