create-brainerce-store 1.50.5 → 1.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/index.js +171 -66
  2. package/messages/en.json +4 -1
  3. package/messages/he.json +4 -1
  4. package/package.json +1 -1
  5. package/templates/nextjs/base/.claude/commands/design.md +51 -0
  6. package/templates/nextjs/base/.env.local.ejs +5 -0
  7. package/templates/nextjs/base/.eslintrc.json +57 -3
  8. package/templates/nextjs/base/AGENTS.md +41 -0
  9. package/templates/nextjs/base/AI-GUIDE.md +94 -0
  10. package/templates/nextjs/base/CLAUDE.md +42 -0
  11. package/templates/nextjs/base/TRANSLATIONS.md +1 -1
  12. package/templates/nextjs/base/next.config.ts +2 -2
  13. package/templates/nextjs/base/src/app/account/page.tsx +5 -5
  14. package/templates/nextjs/base/src/app/api/auth/logout/route.ts +1 -1
  15. package/templates/nextjs/base/src/app/api/auth/reset-password/route.ts +2 -2
  16. package/templates/nextjs/base/src/app/api/store/[...path]/route.ts +1 -1
  17. package/templates/nextjs/base/src/app/auth/callback/page.tsx +4 -4
  18. package/templates/nextjs/base/src/app/blog/[slug]/page.tsx.ejs +4 -4
  19. package/templates/nextjs/base/src/app/blog/page.tsx.ejs +2 -2
  20. package/templates/nextjs/base/src/app/cart/page.tsx +2 -173
  21. package/templates/nextjs/base/src/app/checkout/page.tsx +12 -11
  22. package/templates/nextjs/base/src/app/contact/page.tsx +3 -3
  23. package/templates/nextjs/base/src/app/faq/page.tsx.ejs +2 -2
  24. package/templates/nextjs/base/src/app/forgot-password/page.tsx +4 -4
  25. package/templates/nextjs/base/src/app/layout.tsx.ejs +12 -12
  26. package/templates/nextjs/base/src/app/login/page.tsx +4 -4
  27. package/templates/nextjs/base/src/app/order-confirmation/page.tsx +19 -12
  28. package/templates/nextjs/base/src/app/page.tsx +4 -4
  29. package/templates/nextjs/base/src/app/pages/[slug]/page.tsx.ejs +3 -3
  30. package/templates/nextjs/base/src/app/payment-complete/page.tsx +1 -1
  31. package/templates/nextjs/base/src/app/products/[slug]/page.tsx +6 -6
  32. package/templates/nextjs/base/src/app/products/page.tsx +4 -623
  33. package/templates/nextjs/base/src/app/register/page.tsx +4 -4
  34. package/templates/nextjs/base/src/app/reset-password/page.tsx +5 -5
  35. package/templates/nextjs/base/src/app/sitemap.ts +1 -1
  36. package/templates/nextjs/base/src/app/verify-email/page.tsx +5 -5
  37. package/templates/nextjs/base/src/components/account/address-book.tsx +3 -3
  38. package/templates/nextjs/base/src/components/account/order-customizations.tsx +3 -3
  39. package/templates/nextjs/base/src/components/account/order-history.tsx +13 -5
  40. package/templates/nextjs/base/src/components/account/order-payment-block.tsx +2 -2
  41. package/templates/nextjs/base/src/components/account/order-shipping-block.tsx +2 -2
  42. package/templates/nextjs/base/src/components/account/order-status-timeline.tsx +2 -2
  43. package/templates/nextjs/base/src/components/account/profile-section.tsx +3 -3
  44. package/templates/nextjs/base/src/components/auth/login-form.tsx +4 -4
  45. package/templates/nextjs/base/src/components/auth/oauth-buttons.tsx +4 -4
  46. package/templates/nextjs/base/src/components/auth/register-form.tsx +4 -4
  47. package/templates/nextjs/base/src/components/brainerce-bot.tsx +2 -2
  48. package/templates/nextjs/base/src/components/checkout/checkout-form.tsx +24 -3
  49. package/templates/nextjs/base/src/components/checkout/custom-fields-step.tsx +2 -2
  50. package/templates/nextjs/base/src/components/checkout/delivery-method-step.tsx +2 -2
  51. package/templates/nextjs/base/src/components/checkout/order-bump-card.tsx +4 -4
  52. package/templates/nextjs/base/src/components/checkout/payment-step.tsx +6 -6
  53. package/templates/nextjs/base/src/components/checkout/pickup-step.tsx +3 -3
  54. package/templates/nextjs/base/src/components/checkout/shipping-step.tsx +3 -3
  55. package/templates/nextjs/base/src/components/checkout/tax-display.tsx +3 -3
  56. package/templates/nextjs/base/src/components/seo/organization-json-ld.tsx +2 -2
  57. package/templates/nextjs/base/src/components/seo/product-json-ld.tsx +3 -3
  58. package/templates/nextjs/base/src/core/hooks/use-cart-page.ts +58 -0
  59. package/templates/nextjs/base/src/core/hooks/use-home-data.ts +51 -0
  60. package/templates/nextjs/base/src/core/hooks/use-product-listing.ts +295 -0
  61. package/templates/nextjs/base/src/core/hooks/use-product-page.ts +278 -0
  62. package/templates/nextjs/base/src/{hooks → core/hooks}/use-search.ts +1 -1
  63. package/templates/nextjs/base/src/{lib → core/lib}/brainerce.ts.ejs +1 -1
  64. package/templates/nextjs/base/src/core/lib/product-options.ts +121 -0
  65. package/templates/nextjs/base/src/{lib → core/lib}/resolve-currency.ts +1 -1
  66. package/templates/nextjs/base/src/{lib → core/lib}/safe-redirect.ts +1 -1
  67. package/templates/nextjs/base/src/{lib → core/lib}/sanitize.ts.ejs +1 -1
  68. package/templates/nextjs/base/src/{lib → core/lib}/use-currency.ts +1 -1
  69. package/templates/nextjs/base/src/{providers → core/providers}/store-provider.tsx.ejs +4 -4
  70. package/templates/nextjs/base/src/{components → ui}/cart/cart-bundle-offer.tsx +5 -5
  71. package/templates/nextjs/base/src/{components → ui}/cart/cart-item.tsx +6 -6
  72. package/templates/nextjs/base/src/{components → ui}/cart/cart-nudges.tsx +1 -1
  73. package/templates/nextjs/base/src/{components → ui}/cart/cart-summary.tsx +4 -4
  74. package/templates/nextjs/base/src/{components → ui}/cart/cart-upgrade-banner.tsx +5 -5
  75. package/templates/nextjs/base/src/ui/cart/cart-view.tsx +149 -0
  76. package/templates/nextjs/base/src/{components → ui}/cart/coupon-input.tsx +4 -4
  77. package/templates/nextjs/base/src/{components → ui}/cart/free-shipping-bar.tsx +4 -4
  78. package/templates/nextjs/base/src/{components → ui}/cart/reservation-countdown.tsx +2 -2
  79. package/templates/nextjs/base/src/ui/home/discount-banner-strip.tsx +20 -0
  80. package/templates/nextjs/base/src/ui/home/featured-products-section.tsx +24 -0
  81. package/templates/nextjs/base/src/ui/home/hero-section.tsx +29 -0
  82. package/templates/nextjs/base/src/ui/home/home-client.tsx +29 -0
  83. package/templates/nextjs/base/src/{components/content → ui/layout}/faq-section.tsx.ejs +2 -2
  84. package/templates/nextjs/base/src/{components/content → ui/layout}/header-account.tsx +3 -3
  85. package/templates/nextjs/base/src/{components/content → ui/layout}/rich-text-block.tsx.ejs +1 -1
  86. package/templates/nextjs/base/src/{components/content → ui/layout}/site-header.tsx.ejs +1 -1
  87. package/templates/nextjs/base/src/{components/products → ui/product}/customization-fields.tsx +18 -51
  88. package/templates/nextjs/base/src/{components/products → ui/product}/discount-badge.tsx +1 -1
  89. package/templates/nextjs/base/src/{components/products → ui/product}/frequently-bought-together.tsx +6 -6
  90. package/templates/nextjs/base/src/{components/products → ui/product}/modifier-group-selector.tsx +10 -73
  91. package/templates/nextjs/base/src/{components/shared → ui/product}/price-display.tsx +2 -2
  92. package/templates/nextjs/base/src/{components/products → ui/product}/product-card.tsx +10 -10
  93. package/templates/nextjs/base/src/{app/products/[slug] → ui/product}/product-client-section.tsx +45 -206
  94. package/templates/nextjs/base/src/{components/products → ui/product}/product-grid.tsx +3 -3
  95. package/templates/nextjs/base/src/ui/product/product-listing.tsx +429 -0
  96. package/templates/nextjs/base/src/{components/products → ui/product}/recommendation-section.tsx +4 -4
  97. package/templates/nextjs/base/src/{components/reviews → ui/product}/review-form.tsx +2 -2
  98. package/templates/nextjs/base/src/{components/reviews → ui/product}/reviews-section.tsx +1 -1
  99. package/templates/nextjs/base/src/{components/products → ui/product}/stock-badge.tsx +2 -2
  100. package/templates/nextjs/base/src/{components/products → ui/product}/variant-selector.tsx +3 -3
  101. package/templates/nextjs/base/src/{components → ui}/shared/cdn-image.tsx +1 -1
  102. package/templates/nextjs/base/src/{components → ui}/shared/loading-spinner.tsx +2 -2
  103. package/templates/nextjs/base/tailwind.config.ts +12 -0
  104. package/templates/nextjs/designs/passepartout/app-overlay/layout.tsx.ejs +253 -0
  105. package/templates/nextjs/designs/passepartout/globals.css +412 -0
  106. package/templates/nextjs/designs/passepartout/messages-patch/en.json +87 -0
  107. package/templates/nextjs/designs/passepartout/messages-patch/he.json +87 -0
  108. package/templates/nextjs/designs/passepartout/ui/cart/cart-bundle-offer.tsx +111 -0
  109. package/templates/nextjs/designs/passepartout/ui/cart/cart-nudges.tsx +39 -0
  110. package/templates/nextjs/designs/passepartout/ui/cart/cart-upgrade-banner.tsx +141 -0
  111. package/templates/nextjs/designs/passepartout/ui/cart/cart-view.tsx +149 -0
  112. package/templates/nextjs/designs/passepartout/ui/cart/free-shipping-bar.tsx +62 -0
  113. package/templates/nextjs/designs/passepartout/ui/cart/reservation-countdown.tsx +103 -0
  114. package/templates/nextjs/designs/passepartout/ui/home/home-client.tsx +401 -0
  115. package/templates/nextjs/designs/passepartout/ui/layout/announcement-bar.tsx +139 -0
  116. package/templates/nextjs/designs/passepartout/ui/layout/cart-link.tsx +45 -0
  117. package/templates/nextjs/designs/passepartout/ui/layout/faq-section.tsx +103 -0
  118. package/templates/nextjs/designs/passepartout/ui/layout/site-footer.tsx +159 -0
  119. package/templates/nextjs/designs/passepartout/ui/layout/site-header.tsx.ejs +155 -0
  120. package/templates/nextjs/designs/passepartout/ui/layout/trust-icons.tsx +60 -0
  121. package/templates/nextjs/designs/passepartout/ui/layout/whatsapp-button.tsx +34 -0
  122. package/templates/nextjs/designs/passepartout/ui/product/discount-badge.tsx +22 -0
  123. package/templates/nextjs/designs/passepartout/ui/product/frequently-bought-together.tsx +205 -0
  124. package/templates/nextjs/designs/passepartout/ui/product/price-display.tsx +111 -0
  125. package/templates/nextjs/designs/passepartout/ui/product/product-card.tsx +265 -0
  126. package/templates/nextjs/designs/passepartout/ui/product/product-client-section.tsx +667 -0
  127. package/templates/nextjs/designs/passepartout/ui/product/product-grid.tsx +35 -0
  128. package/templates/nextjs/designs/passepartout/ui/product/product-listing.tsx +427 -0
  129. package/templates/nextjs/designs/passepartout/ui/product/recommendation-section.tsx +113 -0
  130. package/templates/nextjs/designs/passepartout/ui/product/review-form.tsx +294 -0
  131. package/templates/nextjs/designs/passepartout/ui/product/reviews-section.tsx.ejs +96 -0
  132. package/templates/nextjs/designs/passepartout/ui/product/stock-badge.tsx +52 -0
  133. package/templates/nextjs/designs/passepartout/ui/product/variant-selector.tsx +307 -0
  134. package/templates/nextjs/designs/passepartout/ui/shared/fly-to-cart.ts +85 -0
  135. package/templates/nextjs/designs/passepartout/ui/shared/loading-spinner.tsx +33 -0
  136. package/templates/nextjs/ui-canvas/cart/cart-bundle-offer.tsx +87 -0
  137. package/templates/nextjs/ui-canvas/cart/cart-item.tsx +121 -0
  138. package/templates/nextjs/ui-canvas/cart/cart-nudges.tsx +25 -0
  139. package/templates/nextjs/ui-canvas/cart/cart-summary.tsx +97 -0
  140. package/templates/nextjs/ui-canvas/cart/cart-upgrade-banner.tsx +103 -0
  141. package/templates/nextjs/ui-canvas/cart/cart-view.tsx +106 -0
  142. package/templates/nextjs/ui-canvas/cart/coupon-input.tsx +117 -0
  143. package/templates/nextjs/ui-canvas/cart/free-shipping-bar.tsx +52 -0
  144. package/templates/nextjs/ui-canvas/cart/reservation-countdown.tsx +79 -0
  145. package/templates/nextjs/ui-canvas/home/discount-banner-strip.tsx +19 -0
  146. package/templates/nextjs/ui-canvas/home/featured-products-section.tsx +23 -0
  147. package/templates/nextjs/ui-canvas/home/hero-section.tsx +21 -0
  148. package/templates/nextjs/ui-canvas/home/home-client.tsx +26 -0
  149. package/templates/nextjs/ui-canvas/layout/announcement-bar.tsx.ejs +101 -0
  150. package/templates/nextjs/ui-canvas/layout/faq-section.tsx.ejs +71 -0
  151. package/templates/nextjs/ui-canvas/layout/header-account.tsx +31 -0
  152. package/templates/nextjs/ui-canvas/layout/language-switcher.tsx.ejs +74 -0
  153. package/templates/nextjs/ui-canvas/layout/rich-text-block.tsx.ejs +34 -0
  154. package/templates/nextjs/ui-canvas/layout/site-footer.tsx.ejs +82 -0
  155. package/templates/nextjs/ui-canvas/layout/site-header.tsx.ejs +119 -0
  156. package/templates/nextjs/ui-canvas/product/customization-fields.tsx +443 -0
  157. package/templates/nextjs/ui-canvas/product/discount-badge.tsx +17 -0
  158. package/templates/nextjs/ui-canvas/product/frequently-bought-together.tsx +166 -0
  159. package/templates/nextjs/ui-canvas/product/modifier-group-selector.tsx +163 -0
  160. package/templates/nextjs/ui-canvas/product/price-display.tsx +50 -0
  161. package/templates/nextjs/ui-canvas/product/product-card.tsx +197 -0
  162. package/templates/nextjs/ui-canvas/product/product-client-section.tsx +352 -0
  163. package/templates/nextjs/ui-canvas/product/product-grid.tsx +27 -0
  164. package/templates/nextjs/ui-canvas/product/product-listing.tsx +224 -0
  165. package/templates/nextjs/ui-canvas/product/recommendation-section.tsx +95 -0
  166. package/templates/nextjs/ui-canvas/product/review-form.tsx +269 -0
  167. package/templates/nextjs/ui-canvas/product/reviews-section.tsx +78 -0
  168. package/templates/nextjs/ui-canvas/product/stock-badge.tsx +43 -0
  169. package/templates/nextjs/ui-canvas/product/variant-selector.tsx +210 -0
  170. package/templates/nextjs/ui-canvas/shared/cdn-image.tsx +29 -0
  171. package/templates/nextjs/ui-canvas/shared/loading-spinner.tsx +25 -0
  172. package/templates/nextjs/base/src/app/home-client.tsx +0 -98
  173. /package/templates/nextjs/base/src/{lib → core/lib}/auth.ts +0 -0
  174. /package/templates/nextjs/base/src/{lib → core/lib}/csrf.ts +0 -0
  175. /package/templates/nextjs/base/src/{lib → core/lib}/image-hosts.ts +0 -0
  176. /package/templates/nextjs/base/src/{lib → core/lib}/navigation.tsx.ejs +0 -0
  177. /package/templates/nextjs/base/src/{lib → core/lib}/nonce.ts +0 -0
  178. /package/templates/nextjs/base/src/{lib → core/lib}/sanitize-html.ts +0 -0
  179. /package/templates/nextjs/base/src/{lib → core/lib}/seo.ts +0 -0
  180. /package/templates/nextjs/base/src/{lib → core/lib}/store-info.ts +0 -0
  181. /package/templates/nextjs/base/src/{lib → core/lib}/translations.ts.ejs +0 -0
  182. /package/templates/nextjs/base/src/{lib → core/lib}/utils.ts +0 -0
  183. /package/templates/nextjs/base/src/{lib → core/lib}/validation.ts +0 -0
  184. /package/templates/nextjs/base/src/{components/content → ui/layout}/announcement-bar.tsx.ejs +0 -0
  185. /package/templates/nextjs/base/src/{components → ui}/layout/language-switcher.tsx.ejs +0 -0
  186. /package/templates/nextjs/base/src/{components/content → ui/layout}/site-footer.tsx.ejs +0 -0
@@ -0,0 +1,429 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useState, useRef } from 'react';
4
+ import {
5
+ useProductListing,
6
+ sortOptions,
7
+ isActiveInTree,
8
+ type CategoryNode,
9
+ } from '@/core/hooks/use-product-listing';
10
+ import { ProductGrid } from '@/ui/product/product-grid';
11
+ import { LoadingSpinner } from '@/ui/shared/loading-spinner';
12
+ import { useTranslations } from '@/core/lib/translations';
13
+ import { cn } from '@/core/lib/utils';
14
+
15
+ /** Chevron down SVG */
16
+ function ChevronDown({ className }: { className?: string }) {
17
+ return (
18
+ <svg
19
+ className={className}
20
+ width="12"
21
+ height="12"
22
+ viewBox="0 0 12 12"
23
+ fill="none"
24
+ stroke="currentColor"
25
+ strokeWidth="2"
26
+ strokeLinecap="round"
27
+ strokeLinejoin="round"
28
+ >
29
+ <path d="M3 4.5L6 7.5L9 4.5" />
30
+ </svg>
31
+ );
32
+ }
33
+
34
+ /** Recursive dropdown items for nested categories */
35
+ function CategoryDropdownItems({
36
+ items,
37
+ depth,
38
+ selectedId,
39
+ onSelect,
40
+ }: {
41
+ items: CategoryNode[];
42
+ depth: number;
43
+ selectedId: string;
44
+ onSelect: (id: string) => void;
45
+ }) {
46
+ return (
47
+ <>
48
+ {items.map((child) => (
49
+ <div key={child.id}>
50
+ <button
51
+ onClick={() => onSelect(child.id)}
52
+ className={cn(
53
+ 'hover:bg-muted w-full px-4 py-2 text-start text-sm transition-colors',
54
+ selectedId === child.id && 'bg-primary/10 text-primary font-medium'
55
+ )}
56
+ style={{ paddingInlineStart: `${(depth + 1) * 16}px` }}
57
+ >
58
+ {child.name}
59
+ </button>
60
+ {child.children.length > 0 && (
61
+ <CategoryDropdownItems
62
+ items={child.children}
63
+ depth={depth + 1}
64
+ selectedId={selectedId}
65
+ onSelect={onSelect}
66
+ />
67
+ )}
68
+ </div>
69
+ ))}
70
+ </>
71
+ );
72
+ }
73
+
74
+ /** Category chip with dropdown for subcategories */
75
+ function CategoryChip({
76
+ category,
77
+ selectedId,
78
+ onSelect,
79
+ tc,
80
+ }: {
81
+ category: CategoryNode;
82
+ selectedId: string;
83
+ onSelect: (id: string) => void;
84
+ tc: (key: string) => string;
85
+ }) {
86
+ const [open, setOpen] = useState(false);
87
+ const ref = useRef<HTMLDivElement>(null);
88
+ const hasChildren = category.children.length > 0;
89
+ const isActive = isActiveInTree(category, selectedId);
90
+
91
+ // Find the display name for the selected subcategory
92
+ function findName(nodes: CategoryNode[], id: string): string | null {
93
+ for (const n of nodes) {
94
+ if (n.id === id) return n.name;
95
+ const found = findName(n.children, id);
96
+ if (found) return found;
97
+ }
98
+ return null;
99
+ }
100
+
101
+ const selectedChildName =
102
+ isActive && selectedId !== category.id ? findName(category.children, selectedId) : null;
103
+
104
+ // Close dropdown on outside click
105
+ useEffect(() => {
106
+ if (!open) return;
107
+ function handleClick(e: MouseEvent) {
108
+ if (ref.current && !ref.current.contains(e.target as Node)) {
109
+ setOpen(false);
110
+ }
111
+ }
112
+ document.addEventListener('mousedown', handleClick);
113
+ return () => document.removeEventListener('mousedown', handleClick);
114
+ }, [open]);
115
+
116
+ if (!hasChildren) {
117
+ return (
118
+ <button
119
+ onClick={() => onSelect(category.id)}
120
+ className={cn(
121
+ 'rounded-full border px-3 py-1.5 text-sm transition-colors',
122
+ selectedId === category.id
123
+ ? 'bg-primary text-primary-foreground border-primary'
124
+ : 'border-border text-muted-foreground hover:border-primary hover:text-foreground'
125
+ )}
126
+ >
127
+ {category.name}
128
+ </button>
129
+ );
130
+ }
131
+
132
+ return (
133
+ <div ref={ref} className="relative">
134
+ <button
135
+ onClick={() => setOpen((prev) => !prev)}
136
+ className={cn(
137
+ 'inline-flex items-center gap-1 rounded-full border px-3 py-1.5 text-sm transition-colors',
138
+ isActive
139
+ ? 'bg-primary text-primary-foreground border-primary'
140
+ : 'border-border text-muted-foreground hover:border-primary hover:text-foreground'
141
+ )}
142
+ >
143
+ {category.name}
144
+ {selectedChildName && (
145
+ <span className="opacity-80">
146
+ {'·'} {selectedChildName}
147
+ </span>
148
+ )}
149
+ <ChevronDown className={cn('ms-0.5 transition-transform', open && 'rotate-180')} />
150
+ </button>
151
+
152
+ {open && (
153
+ <div className="bg-background border-border absolute start-0 top-full z-50 mt-1 min-w-[180px] overflow-hidden rounded-lg border shadow-lg">
154
+ {/* "All in [category]" option */}
155
+ <button
156
+ onClick={() => {
157
+ onSelect(category.id);
158
+ setOpen(false);
159
+ }}
160
+ className={cn(
161
+ 'hover:bg-muted w-full px-4 py-2 text-start text-sm font-medium transition-colors',
162
+ selectedId === category.id && 'bg-primary/10 text-primary'
163
+ )}
164
+ >
165
+ {tc('all')} {category.name}
166
+ </button>
167
+ <div className="bg-border mx-2 h-px" />
168
+ {/* Recursive children */}
169
+ <div onClick={() => setOpen(false)}>
170
+ <CategoryDropdownItems
171
+ items={category.children}
172
+ depth={0}
173
+ selectedId={selectedId}
174
+ onSelect={onSelect}
175
+ />
176
+ </div>
177
+ </div>
178
+ )}
179
+ </div>
180
+ );
181
+ }
182
+
183
+ /**
184
+ * Product listing page (filters + sort + grid + load-more). All data and
185
+ * URL-state behavior comes from `useProductListing`; this component is
186
+ * presentation only. Must be rendered inside `<Suspense>` (URL params).
187
+ */
188
+ export function ProductListing() {
189
+ const t = useTranslations('products');
190
+ const tc = useTranslations('common');
191
+
192
+ const {
193
+ products,
194
+ loading,
195
+ loadingMore,
196
+ page,
197
+ totalPages,
198
+ total,
199
+ categories,
200
+ brands,
201
+ tags,
202
+ metafieldDefs,
203
+ searchQuery,
204
+ categoryId,
205
+ brandId,
206
+ tagId,
207
+ sortIndex,
208
+ handleLoadMore,
209
+ updateParam,
210
+ handleCategorySelect,
211
+ getSelectedMetafieldValues,
212
+ setMetafieldValue,
213
+ } = useProductListing();
214
+
215
+ return (
216
+ <div className="mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8">
217
+ {/* Page Header */}
218
+ <div className="mb-8">
219
+ <h1 className="text-foreground text-3xl font-bold">
220
+ {searchQuery ? `${t('searchPrefix')} "${searchQuery}"` : t('allProducts')}
221
+ </h1>
222
+ {!loading && (
223
+ <p className="text-muted-foreground mt-1 text-sm">
224
+ {total} {total === 1 ? tc('product') : tc('products')} {tc('found')}
225
+ </p>
226
+ )}
227
+ </div>
228
+
229
+ {/* Filters and Sort */}
230
+ <div className="mb-6 flex flex-col gap-4">
231
+ {/* Category Filter */}
232
+ {categories.length > 0 && (
233
+ <div className="flex flex-wrap gap-2">
234
+ <button
235
+ onClick={() => updateParam('category', '')}
236
+ className={cn(
237
+ 'rounded-full border px-3 py-1.5 text-sm transition-colors',
238
+ !categoryId
239
+ ? 'bg-primary text-primary-foreground border-primary'
240
+ : 'border-border text-muted-foreground hover:border-primary hover:text-foreground'
241
+ )}
242
+ >
243
+ {tc('all')}
244
+ </button>
245
+ {categories.map((cat) => (
246
+ <CategoryChip
247
+ key={cat.id}
248
+ category={cat}
249
+ selectedId={categoryId}
250
+ onSelect={handleCategorySelect}
251
+ tc={tc as (key: string) => string}
252
+ />
253
+ ))}
254
+ </div>
255
+ )}
256
+
257
+ {/* Brand, Tag & Sort row */}
258
+ <div className="flex flex-wrap items-center gap-3">
259
+ {/* Brand Filter */}
260
+ {brands.length > 0 && (
261
+ <select
262
+ value={brandId}
263
+ onChange={(e) => updateParam('brand', e.target.value)}
264
+ className="border-border bg-background text-foreground focus:ring-primary/20 focus:border-primary h-9 rounded border px-3 text-sm focus:outline-none focus:ring-2"
265
+ >
266
+ <option value="">{t('allBrands')}</option>
267
+ {brands.map((b) => (
268
+ <option key={b.id} value={b.id}>
269
+ {b.name}
270
+ </option>
271
+ ))}
272
+ </select>
273
+ )}
274
+
275
+ {/* Tag Filter */}
276
+ {tags.length > 0 && (
277
+ <select
278
+ value={tagId}
279
+ onChange={(e) => updateParam('tag', e.target.value)}
280
+ className="border-border bg-background text-foreground focus:ring-primary/20 focus:border-primary h-9 rounded border px-3 text-sm focus:outline-none focus:ring-2"
281
+ >
282
+ <option value="">{t('allTags')}</option>
283
+ {tags.map((tg) => (
284
+ <option key={tg.id} value={tg.id}>
285
+ {tg.name}
286
+ </option>
287
+ ))}
288
+ </select>
289
+ )}
290
+
291
+ {/* Custom-field (metafield) facets — rendered per definition type.
292
+ Only definitions flagged `filterable: true` and published to
293
+ this sales channel reach this list (see `metafieldDefs` filter
294
+ in the hook). The merchant's display name (`def.name`) is shown
295
+ as-is — `enumValues` come from the merchant's dashboard config. */}
296
+ {metafieldDefs.map((def) => {
297
+ const selected = getSelectedMetafieldValues(def.key);
298
+
299
+ if (def.type === 'BOOLEAN') {
300
+ const isOn = selected.includes('true');
301
+ return (
302
+ <label
303
+ key={def.id}
304
+ className="border-border text-foreground hover:border-primary inline-flex h-9 cursor-pointer items-center gap-2 rounded border px-3 text-sm transition-colors"
305
+ >
306
+ <input
307
+ type="checkbox"
308
+ checked={isOn}
309
+ onChange={(e) => setMetafieldValue(def.key, e.target.checked ? ['true'] : [])}
310
+ className="accent-primary h-4 w-4"
311
+ />
312
+ {def.name}
313
+ </label>
314
+ );
315
+ }
316
+
317
+ if (def.type === 'SELECT') {
318
+ return (
319
+ <select
320
+ key={def.id}
321
+ value={selected[0] || ''}
322
+ onChange={(e) =>
323
+ setMetafieldValue(def.key, e.target.value ? [e.target.value] : [])
324
+ }
325
+ aria-label={def.name}
326
+ className="border-border bg-background text-foreground focus:ring-primary/20 focus:border-primary h-9 rounded border px-3 text-sm focus:outline-none focus:ring-2"
327
+ >
328
+ <option value="">{`${tc('all')} ${def.name}`}</option>
329
+ {(def.enumValues || []).map((v) => (
330
+ <option key={v.value} value={v.value}>
331
+ {v.label || v.value}
332
+ </option>
333
+ ))}
334
+ </select>
335
+ );
336
+ }
337
+
338
+ // MULTI_SELECT — chip toggles. Each click adds/removes one value.
339
+ return (
340
+ <div
341
+ key={def.id}
342
+ className="border-border inline-flex items-center gap-1 rounded border px-2 py-1"
343
+ aria-label={def.name}
344
+ >
345
+ <span className="text-muted-foreground px-1 text-xs">{def.name}:</span>
346
+ {(def.enumValues || []).map((v) => {
347
+ const active = selected.includes(v.value);
348
+ return (
349
+ <button
350
+ key={v.value}
351
+ type="button"
352
+ onClick={() =>
353
+ setMetafieldValue(
354
+ def.key,
355
+ active ? selected.filter((s) => s !== v.value) : [...selected, v.value]
356
+ )
357
+ }
358
+ className={cn(
359
+ 'rounded-full border px-2 py-0.5 text-xs transition-colors',
360
+ active
361
+ ? 'bg-primary text-primary-foreground border-primary'
362
+ : 'border-border text-muted-foreground hover:border-primary hover:text-foreground'
363
+ )}
364
+ >
365
+ {v.label || v.value}
366
+ </button>
367
+ );
368
+ })}
369
+ </div>
370
+ );
371
+ })}
372
+
373
+ {/* Sort */}
374
+ <div className="flex items-center gap-2 sm:ms-auto">
375
+ <label htmlFor="sort" className="text-muted-foreground whitespace-nowrap text-sm">
376
+ {tc('sortBy')}
377
+ </label>
378
+ <select
379
+ id="sort"
380
+ value={sortIndex}
381
+ onChange={(e) => updateParam('sort', e.target.value)}
382
+ className="border-border bg-background text-foreground focus:ring-primary/20 focus:border-primary h-9 rounded border px-3 text-sm focus:outline-none focus:ring-2"
383
+ >
384
+ {sortOptions.map((opt, idx) => (
385
+ <option key={idx} value={idx}>
386
+ {t(opt.labelKey)}
387
+ </option>
388
+ ))}
389
+ </select>
390
+ </div>
391
+ </div>
392
+ </div>
393
+
394
+ {/* Products Grid */}
395
+ {loading ? (
396
+ <div className="flex items-center justify-center py-20">
397
+ <LoadingSpinner size="lg" />
398
+ </div>
399
+ ) : (
400
+ <>
401
+ <ProductGrid products={products} />
402
+
403
+ {/* Load More */}
404
+ {page < totalPages && (
405
+ <div className="mt-10 flex justify-center">
406
+ <button
407
+ onClick={handleLoadMore}
408
+ disabled={loadingMore}
409
+ className="bg-primary text-primary-foreground inline-flex items-center gap-2 rounded px-6 py-2.5 font-medium transition-opacity hover:opacity-90 disabled:opacity-50"
410
+ >
411
+ {loadingMore ? (
412
+ <>
413
+ <LoadingSpinner
414
+ size="sm"
415
+ className="border-primary-foreground/30 border-t-primary-foreground"
416
+ />
417
+ {tc('loading')}
418
+ </>
419
+ ) : (
420
+ t('loadMore')
421
+ )}
422
+ </button>
423
+ </div>
424
+ )}
425
+ </>
426
+ )}
427
+ </div>
428
+ );
429
+ }
@@ -1,11 +1,11 @@
1
1
  'use client';
2
2
 
3
3
  import { useEffect, useState } from 'react';
4
- import { Link } from '@/lib/navigation';
5
- import { CdnImage as Image } from '@/components/shared/cdn-image';
4
+ import { Link } from '@/core/lib/navigation';
5
+ import { CdnImage as Image } from '@/ui/shared/cdn-image';
6
6
  import type { ProductRecommendation } from 'brainerce';
7
- import { PriceDisplay } from '@/components/shared/price-display';
8
- import { cn } from '@/lib/utils';
7
+ import { PriceDisplay } from '@/ui/product/price-display';
8
+ import { cn } from '@/core/lib/utils';
9
9
 
10
10
  interface RecommendationCardProps {
11
11
  item: ProductRecommendation;
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
3
  import { useEffect, useState } from 'react';
4
- import { getClient } from '@/lib/brainerce';
5
- import { checkAuthStatus } from '@/lib/auth';
4
+ import { getClient } from '@/core/lib/brainerce';
5
+ import { checkAuthStatus } from '@/core/lib/auth';
6
6
  import type { MyProductReview, ProductReview } from 'brainerce';
7
7
 
8
8
  interface ReviewFormProps {
@@ -1,5 +1,5 @@
1
1
  import type { ProductReview } from 'brainerce';
2
- import { getServerClient } from '@/lib/brainerce';
2
+ import { getServerClient } from '@/core/lib/brainerce';
3
3
  import { ReviewForm } from './review-form';
4
4
 
5
5
  interface ReviewsSectionProps {
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
3
  import type { InventoryInfo } from 'brainerce';
4
- import { cn } from '@/lib/utils';
5
- import { useTranslations } from '@/lib/translations';
4
+ import { cn } from '@/core/lib/utils';
5
+ import { useTranslations } from '@/core/lib/translations';
6
6
 
7
7
  interface StockBadgeProps {
8
8
  inventory: InventoryInfo | null | undefined;
@@ -4,9 +4,9 @@ import { useMemo } from 'react';
4
4
  import type { Product, ProductVariant } from 'brainerce';
5
5
  import { getVariantOptions, getProductSwatches, formatPrice } from 'brainerce';
6
6
  import type { InventoryInfo } from 'brainerce';
7
- import { useCurrency } from '@/lib/use-currency';
8
- import { useTranslations } from '@/lib/translations';
9
- import { cn } from '@/lib/utils';
7
+ import { useCurrency } from '@/core/lib/use-currency';
8
+ import { useTranslations } from '@/core/lib/translations';
9
+ import { cn } from '@/core/lib/utils';
10
10
 
11
11
  interface VariantSelectorProps {
12
12
  product: Product;
@@ -1,5 +1,5 @@
1
1
  import Image, { type ImageProps } from 'next/image';
2
- import { OPTIMIZED_IMAGE_HOSTS } from '@/lib/image-hosts';
2
+ import { OPTIMIZED_IMAGE_HOSTS } from '@/core/lib/image-hosts';
3
3
 
4
4
  const OPTIMIZED_HOSTS = new Set(OPTIMIZED_IMAGE_HOSTS);
5
5
 
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
- import { useTranslations } from '@/lib/translations';
4
- import { cn } from '@/lib/utils';
3
+ import { useTranslations } from '@/core/lib/translations';
4
+ import { cn } from '@/core/lib/utils';
5
5
 
6
6
  interface LoadingSpinnerProps {
7
7
  size?: 'sm' | 'md' | 'lg';
@@ -18,6 +18,18 @@ const config: Config = {
18
18
  'destructive-foreground': 'hsl(var(--destructive-foreground))',
19
19
  accent: 'hsl(var(--accent))',
20
20
  'accent-foreground': 'hsl(var(--accent-foreground))',
21
+ // Extended tokens used by design packs (defined in their globals.css).
22
+ // Harmless when a design doesn't set the CSS variables — the classes
23
+ // simply aren't used by the base ui.
24
+ surface: 'hsl(var(--surface))',
25
+ plinth: 'hsl(var(--plinth))',
26
+ },
27
+ fontFamily: {
28
+ // Design packs set --font-sans / --font-serif via next/font variables
29
+ // in app/layout.tsx; the fallbacks keep font-sans/font-serif usable
30
+ // even when a layout doesn't define them.
31
+ sans: ['var(--font-sans)', 'ui-sans-serif', 'system-ui', 'sans-serif'],
32
+ serif: ['var(--font-serif)', 'ui-serif', 'Georgia', 'serif'],
21
33
  },
22
34
  borderRadius: {
23
35
  DEFAULT: 'var(--radius)',