create-brainerce-store 1.50.5 → 1.52.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 (230) hide show
  1. package/README.md +72 -0
  2. package/dist/index.js +146 -100
  3. package/messages/en.json +36 -1
  4. package/messages/he.json +36 -1
  5. package/package.json +1 -1
  6. package/templates/nextjs/base/.claude/commands/design.md +60 -0
  7. package/templates/nextjs/base/.env.local.ejs +5 -0
  8. package/templates/nextjs/base/.eslintrc.json +57 -3
  9. package/templates/nextjs/base/AGENTS.md +41 -0
  10. package/templates/nextjs/base/AI-GUIDE.md +143 -0
  11. package/templates/nextjs/base/CLAUDE.md +52 -0
  12. package/templates/nextjs/base/TRANSLATIONS.md +1 -1
  13. package/templates/nextjs/base/next.config.ts +2 -2
  14. package/templates/nextjs/base/package.json.ejs +52 -39
  15. package/templates/nextjs/base/src/app/account/page.tsx +5 -5
  16. package/templates/nextjs/base/src/app/api/auth/logout/route.ts +1 -1
  17. package/templates/nextjs/base/src/app/api/auth/reset-password/route.ts +2 -2
  18. package/templates/nextjs/base/src/app/api/store/[...path]/route.ts +1 -1
  19. package/templates/nextjs/base/src/app/auth/callback/page.tsx +4 -4
  20. package/templates/nextjs/base/src/app/blog/[slug]/page.tsx.ejs +4 -4
  21. package/templates/nextjs/base/src/app/blog/page.tsx.ejs +2 -2
  22. package/templates/nextjs/base/src/app/cart/page.tsx +2 -173
  23. package/templates/nextjs/base/src/app/checkout/page.tsx +12 -11
  24. package/templates/nextjs/base/src/app/contact/page.tsx +3 -3
  25. package/templates/nextjs/base/src/app/faq/page.tsx.ejs +2 -2
  26. package/templates/nextjs/base/src/app/forgot-password/page.tsx +4 -4
  27. package/templates/nextjs/base/src/app/globals.css +36 -30
  28. package/templates/nextjs/base/src/app/layout.tsx.ejs +12 -12
  29. package/templates/nextjs/base/src/app/login/page.tsx +4 -4
  30. package/templates/nextjs/base/src/app/order-confirmation/page.tsx +19 -12
  31. package/templates/nextjs/base/src/app/page.tsx +4 -4
  32. package/templates/nextjs/base/src/app/pages/[slug]/page.tsx.ejs +3 -3
  33. package/templates/nextjs/base/src/app/payment-complete/page.tsx +1 -1
  34. package/templates/nextjs/base/src/app/products/[slug]/page.tsx +6 -6
  35. package/templates/nextjs/base/src/app/products/page.tsx +4 -623
  36. package/templates/nextjs/base/src/app/register/page.tsx +4 -4
  37. package/templates/nextjs/base/src/app/reset-password/page.tsx +5 -5
  38. package/templates/nextjs/base/src/app/sitemap.ts +1 -1
  39. package/templates/nextjs/base/src/app/verify-email/page.tsx +5 -5
  40. package/templates/nextjs/base/src/components/account/address-book.tsx +3 -3
  41. package/templates/nextjs/base/src/components/account/order-customizations.tsx +3 -3
  42. package/templates/nextjs/base/src/components/account/order-history.tsx +13 -5
  43. package/templates/nextjs/base/src/components/account/order-payment-block.tsx +2 -2
  44. package/templates/nextjs/base/src/components/account/order-shipping-block.tsx +2 -2
  45. package/templates/nextjs/base/src/components/account/order-status-timeline.tsx +2 -2
  46. package/templates/nextjs/base/src/components/account/profile-section.tsx +3 -3
  47. package/templates/nextjs/base/src/components/auth/login-form.tsx +4 -4
  48. package/templates/nextjs/base/src/components/auth/oauth-buttons.tsx +4 -4
  49. package/templates/nextjs/base/src/components/auth/register-form.tsx +4 -4
  50. package/templates/nextjs/base/src/components/brainerce-bot.tsx +2 -2
  51. package/templates/nextjs/base/src/components/checkout/checkout-form.tsx +24 -3
  52. package/templates/nextjs/base/src/components/checkout/custom-fields-step.tsx +2 -2
  53. package/templates/nextjs/base/src/components/checkout/delivery-method-step.tsx +2 -2
  54. package/templates/nextjs/base/src/components/checkout/order-bump-card.tsx +4 -4
  55. package/templates/nextjs/base/src/components/checkout/payment-step.tsx +20 -16
  56. package/templates/nextjs/base/src/components/checkout/pickup-step.tsx +3 -3
  57. package/templates/nextjs/base/src/components/checkout/shipping-step.tsx +3 -3
  58. package/templates/nextjs/base/src/components/checkout/tax-display.tsx +3 -3
  59. package/templates/nextjs/base/src/components/seo/organization-json-ld.tsx +2 -2
  60. package/templates/nextjs/base/src/components/seo/product-json-ld.tsx +3 -3
  61. package/templates/nextjs/base/src/components/ui/accordion.tsx +53 -0
  62. package/templates/nextjs/base/src/components/ui/badge.tsx +32 -0
  63. package/templates/nextjs/base/src/components/ui/button.tsx +49 -0
  64. package/templates/nextjs/base/src/components/ui/card.tsx +55 -0
  65. package/templates/nextjs/base/src/components/ui/checkbox.tsx +28 -0
  66. package/templates/nextjs/base/src/components/ui/dialog.tsx +107 -0
  67. package/templates/nextjs/base/src/components/ui/input.tsx +22 -0
  68. package/templates/nextjs/base/src/components/ui/label.tsx +21 -0
  69. package/templates/nextjs/base/src/components/ui/radio-group.tsx +38 -0
  70. package/templates/nextjs/base/src/components/ui/select.tsx +153 -0
  71. package/templates/nextjs/base/src/components/ui/separator.tsx +26 -0
  72. package/templates/nextjs/base/src/components/ui/sheet.tsx +125 -0
  73. package/templates/nextjs/base/src/components/ui/skeleton.tsx +7 -0
  74. package/templates/nextjs/base/src/components/ui/tabs.tsx +55 -0
  75. package/templates/nextjs/base/src/components/ui/textarea.tsx +21 -0
  76. package/templates/nextjs/base/src/components/ui/tooltip.tsx +32 -0
  77. package/templates/nextjs/base/src/core/hooks/use-cart-page.ts +58 -0
  78. package/templates/nextjs/base/src/core/hooks/use-home-data.ts +51 -0
  79. package/templates/nextjs/base/src/core/hooks/use-product-listing.ts +295 -0
  80. package/templates/nextjs/base/src/core/hooks/use-product-page.ts +278 -0
  81. package/templates/nextjs/base/src/{hooks → core/hooks}/use-search.ts +1 -1
  82. package/templates/nextjs/base/src/{lib → core/lib}/brainerce.ts.ejs +1 -1
  83. package/templates/nextjs/base/src/core/lib/product-options.ts +121 -0
  84. package/templates/nextjs/base/src/{lib → core/lib}/resolve-currency.ts +1 -1
  85. package/templates/nextjs/base/src/{lib → core/lib}/safe-redirect.ts +1 -1
  86. package/templates/nextjs/base/src/{lib → core/lib}/sanitize.ts.ejs +1 -1
  87. package/templates/nextjs/base/src/{lib → core/lib}/use-currency.ts +1 -1
  88. package/templates/nextjs/base/src/{providers → core/providers}/store-provider.tsx.ejs +4 -4
  89. package/templates/nextjs/base/src/{components → ui}/cart/cart-bundle-offer.tsx +22 -16
  90. package/templates/nextjs/base/src/{components → ui}/cart/cart-item.tsx +8 -14
  91. package/templates/nextjs/base/src/{components → ui}/cart/cart-nudges.tsx +28 -39
  92. package/templates/nextjs/base/src/{components → ui}/cart/cart-summary.tsx +7 -5
  93. package/templates/nextjs/base/src/{components → ui}/cart/cart-upgrade-banner.tsx +13 -28
  94. package/templates/nextjs/base/src/ui/cart/cart-view.tsx +140 -0
  95. package/templates/nextjs/base/src/{components → ui}/cart/coupon-input.tsx +14 -25
  96. package/templates/nextjs/base/src/{components → ui}/cart/free-shipping-bar.tsx +6 -7
  97. package/templates/nextjs/base/src/{components → ui}/cart/reservation-countdown.tsx +95 -103
  98. package/templates/nextjs/base/src/ui/home/discount-banner-strip.tsx +20 -0
  99. package/templates/nextjs/base/src/ui/home/featured-products-section.tsx +24 -0
  100. package/templates/nextjs/base/src/ui/home/hero-section.tsx +27 -0
  101. package/templates/nextjs/base/src/ui/home/home-client.tsx +29 -0
  102. package/templates/nextjs/base/src/{components/content → ui/layout}/announcement-bar.tsx.ejs +116 -125
  103. package/templates/nextjs/base/src/ui/layout/faq-section.tsx.ejs +90 -0
  104. package/templates/nextjs/base/src/{components/content → ui/layout}/header-account.tsx +5 -20
  105. package/templates/nextjs/base/src/ui/layout/language-switcher.tsx.ejs +80 -0
  106. package/templates/nextjs/base/src/{components/content → ui/layout}/rich-text-block.tsx.ejs +1 -1
  107. package/templates/nextjs/base/src/{components/content → ui/layout}/site-footer.tsx.ejs +144 -164
  108. package/templates/nextjs/base/src/{components/content → ui/layout}/site-header.tsx.ejs +152 -182
  109. package/templates/nextjs/base/src/{components/products → ui/product}/customization-fields.tsx +457 -478
  110. package/templates/nextjs/base/src/{components/products → ui/product}/discount-badge.tsx +18 -22
  111. package/templates/nextjs/base/src/{components/products → ui/product}/frequently-bought-together.tsx +21 -33
  112. package/templates/nextjs/base/src/ui/product/modifier-group-selector.tsx +206 -0
  113. package/templates/nextjs/base/src/{components/shared → ui/product}/price-display.tsx +5 -4
  114. package/templates/nextjs/base/src/{components/products → ui/product}/product-card.tsx +238 -271
  115. package/templates/nextjs/base/src/{app/products/[slug] → ui/product}/product-client-section.tsx +455 -631
  116. package/templates/nextjs/base/src/{components/products → ui/product}/product-grid.tsx +3 -3
  117. package/templates/nextjs/base/src/ui/product/product-listing.tsx +446 -0
  118. package/templates/nextjs/base/src/{components/products → ui/product}/recommendation-section.tsx +102 -107
  119. package/templates/nextjs/base/src/{components/reviews → ui/product}/review-form.tsx +46 -45
  120. package/templates/nextjs/base/src/{components/reviews/reviews-section.tsx → ui/product/reviews-section.tsx.ejs} +38 -15
  121. package/templates/nextjs/base/src/{components/products → ui/product}/stock-badge.tsx +61 -63
  122. package/templates/nextjs/base/src/{components/products → ui/product}/variant-selector.tsx +3 -3
  123. package/templates/nextjs/base/src/{components → ui}/shared/cdn-image.tsx +1 -1
  124. package/templates/nextjs/base/src/{components → ui}/shared/loading-spinner.tsx +2 -2
  125. package/templates/nextjs/base/tailwind.config.ts +69 -30
  126. package/templates/nextjs/designs/atelier/app-overlay/layout.tsx.ejs +251 -0
  127. package/templates/nextjs/designs/atelier/globals.css +396 -0
  128. package/templates/nextjs/designs/atelier/messages-patch/en.json +99 -0
  129. package/templates/nextjs/designs/atelier/messages-patch/he.json +99 -0
  130. package/templates/nextjs/designs/atelier/ui/cart/cart-bundle-offer.tsx +110 -0
  131. package/templates/nextjs/designs/atelier/ui/cart/cart-drawer.tsx +163 -0
  132. package/templates/nextjs/designs/atelier/ui/cart/cart-item.tsx +140 -0
  133. package/templates/nextjs/designs/atelier/ui/cart/cart-nudges.tsx +34 -0
  134. package/templates/nextjs/designs/atelier/ui/cart/cart-summary.tsx +107 -0
  135. package/templates/nextjs/designs/atelier/ui/cart/cart-upgrade-banner.tsx +123 -0
  136. package/templates/nextjs/designs/atelier/ui/cart/cart-view.tsx +147 -0
  137. package/templates/nextjs/designs/atelier/ui/cart/coupon-input.tsx +142 -0
  138. package/templates/nextjs/designs/atelier/ui/cart/free-shipping-bar.tsx +77 -0
  139. package/templates/nextjs/designs/atelier/ui/cart/reservation-countdown.tsx +89 -0
  140. package/templates/nextjs/designs/atelier/ui/home/benefits-band.tsx +34 -0
  141. package/templates/nextjs/designs/atelier/ui/home/category-tiles.tsx +148 -0
  142. package/templates/nextjs/designs/atelier/ui/home/discount-banner-strip.tsx +27 -0
  143. package/templates/nextjs/designs/atelier/ui/home/editorial-band.tsx +73 -0
  144. package/templates/nextjs/designs/atelier/ui/home/featured-products-section.tsx +36 -0
  145. package/templates/nextjs/designs/atelier/ui/home/hero-section.tsx +148 -0
  146. package/templates/nextjs/designs/atelier/ui/home/home-client.tsx +54 -0
  147. package/templates/nextjs/designs/atelier/ui/home/newsletter-section.tsx +78 -0
  148. package/templates/nextjs/designs/atelier/ui/home/testimonials-band.tsx +46 -0
  149. package/templates/nextjs/designs/atelier/ui/layout/announcement-bar.tsx +118 -0
  150. package/templates/nextjs/designs/atelier/ui/layout/faq-section.tsx +96 -0
  151. package/templates/nextjs/designs/atelier/ui/layout/header-account.tsx +36 -0
  152. package/templates/nextjs/designs/atelier/ui/layout/header-cart.tsx +36 -0
  153. package/templates/nextjs/designs/atelier/ui/layout/language-switcher.tsx.ejs +137 -0
  154. package/templates/nextjs/designs/atelier/ui/layout/nav-url.ts +14 -0
  155. package/templates/nextjs/designs/atelier/ui/layout/rich-text-block.tsx +34 -0
  156. package/templates/nextjs/designs/atelier/ui/layout/site-footer.tsx.ejs +141 -0
  157. package/templates/nextjs/designs/atelier/ui/layout/site-header.tsx.ejs +138 -0
  158. package/templates/nextjs/designs/atelier/ui/product/customization-fields.tsx +466 -0
  159. package/templates/nextjs/designs/atelier/ui/product/discount-badge.tsx +17 -0
  160. package/templates/nextjs/designs/atelier/ui/product/frequently-bought-together.tsx +196 -0
  161. package/templates/nextjs/designs/atelier/ui/product/modifier-group-selector.tsx +193 -0
  162. package/templates/nextjs/designs/atelier/ui/product/price-display.tsx +69 -0
  163. package/templates/nextjs/designs/atelier/ui/product/product-card.tsx +260 -0
  164. package/templates/nextjs/designs/atelier/ui/product/product-client-section.tsx +471 -0
  165. package/templates/nextjs/designs/atelier/ui/product/product-grid.tsx +47 -0
  166. package/templates/nextjs/designs/atelier/ui/product/product-listing.tsx +260 -0
  167. package/templates/nextjs/designs/atelier/ui/product/recommendation-section.tsx +95 -0
  168. package/templates/nextjs/designs/atelier/ui/product/review-form.tsx +267 -0
  169. package/templates/nextjs/designs/atelier/ui/product/reviews-section.tsx.ejs +148 -0
  170. package/templates/nextjs/designs/atelier/ui/product/stock-badge.tsx +66 -0
  171. package/templates/nextjs/designs/atelier/ui/product/variant-selector.tsx +206 -0
  172. package/templates/nextjs/designs/atelier/ui/shared/cdn-image.tsx +29 -0
  173. package/templates/nextjs/designs/atelier/ui/shared/fly-to-cart.ts +86 -0
  174. package/templates/nextjs/designs/atelier/ui/shared/icons.tsx +269 -0
  175. package/templates/nextjs/designs/atelier/ui/shared/loading-spinner.tsx +64 -0
  176. package/templates/nextjs/designs/atelier/ui/shared/reveal.tsx +71 -0
  177. package/templates/nextjs/designs/atelier/ui/shared/select-menu.tsx +125 -0
  178. package/templates/nextjs/themes/luxury/globals.css +405 -399
  179. package/templates/nextjs/themes/minimal/globals.css +36 -30
  180. package/templates/nextjs/themes/playful/globals.css +406 -400
  181. package/templates/nextjs/ui-canvas/cart/cart-bundle-offer.tsx +89 -0
  182. package/templates/nextjs/ui-canvas/cart/cart-item.tsx +123 -0
  183. package/templates/nextjs/ui-canvas/cart/cart-nudges.tsx +27 -0
  184. package/templates/nextjs/ui-canvas/cart/cart-summary.tsx +99 -0
  185. package/templates/nextjs/ui-canvas/cart/cart-upgrade-banner.tsx +105 -0
  186. package/templates/nextjs/ui-canvas/cart/cart-view.tsx +106 -0
  187. package/templates/nextjs/ui-canvas/cart/coupon-input.tsx +119 -0
  188. package/templates/nextjs/ui-canvas/cart/free-shipping-bar.tsx +54 -0
  189. package/templates/nextjs/ui-canvas/cart/reservation-countdown.tsx +81 -0
  190. package/templates/nextjs/ui-canvas/home/discount-banner-strip.tsx +19 -0
  191. package/templates/nextjs/ui-canvas/home/featured-products-section.tsx +23 -0
  192. package/templates/nextjs/ui-canvas/home/hero-section.tsx +21 -0
  193. package/templates/nextjs/ui-canvas/home/home-client.tsx +26 -0
  194. package/templates/nextjs/ui-canvas/layout/announcement-bar.tsx.ejs +101 -0
  195. package/templates/nextjs/ui-canvas/layout/faq-section.tsx.ejs +71 -0
  196. package/templates/nextjs/ui-canvas/layout/header-account.tsx +31 -0
  197. package/templates/nextjs/{base/src/components → ui-canvas}/layout/language-switcher.tsx.ejs +76 -70
  198. package/templates/nextjs/ui-canvas/layout/rich-text-block.tsx.ejs +36 -0
  199. package/templates/nextjs/ui-canvas/layout/site-footer.tsx.ejs +82 -0
  200. package/templates/nextjs/ui-canvas/layout/site-header.tsx.ejs +119 -0
  201. package/templates/nextjs/ui-canvas/product/customization-fields.tsx +445 -0
  202. package/templates/nextjs/ui-canvas/product/discount-badge.tsx +19 -0
  203. package/templates/nextjs/ui-canvas/product/frequently-bought-together.tsx +168 -0
  204. package/templates/nextjs/ui-canvas/product/modifier-group-selector.tsx +165 -0
  205. package/templates/nextjs/ui-canvas/product/price-display.tsx +52 -0
  206. package/templates/nextjs/ui-canvas/product/product-card.tsx +197 -0
  207. package/templates/nextjs/ui-canvas/product/product-client-section.tsx +352 -0
  208. package/templates/nextjs/ui-canvas/product/product-grid.tsx +27 -0
  209. package/templates/nextjs/ui-canvas/product/product-listing.tsx +224 -0
  210. package/templates/nextjs/ui-canvas/product/recommendation-section.tsx +99 -0
  211. package/templates/nextjs/ui-canvas/product/review-form.tsx +266 -0
  212. package/templates/nextjs/ui-canvas/product/reviews-section.tsx.ejs +96 -0
  213. package/templates/nextjs/ui-canvas/product/stock-badge.tsx +45 -0
  214. package/templates/nextjs/ui-canvas/product/variant-selector.tsx +212 -0
  215. package/templates/nextjs/ui-canvas/shared/cdn-image.tsx +31 -0
  216. package/templates/nextjs/ui-canvas/shared/loading-spinner.tsx +27 -0
  217. package/templates/nextjs/base/src/app/home-client.tsx +0 -98
  218. package/templates/nextjs/base/src/components/content/faq-section.tsx.ejs +0 -103
  219. package/templates/nextjs/base/src/components/products/modifier-group-selector.tsx +0 -238
  220. /package/templates/nextjs/base/src/{lib → core/lib}/auth.ts +0 -0
  221. /package/templates/nextjs/base/src/{lib → core/lib}/csrf.ts +0 -0
  222. /package/templates/nextjs/base/src/{lib → core/lib}/image-hosts.ts +0 -0
  223. /package/templates/nextjs/base/src/{lib → core/lib}/navigation.tsx.ejs +0 -0
  224. /package/templates/nextjs/base/src/{lib → core/lib}/nonce.ts +0 -0
  225. /package/templates/nextjs/base/src/{lib → core/lib}/sanitize-html.ts +0 -0
  226. /package/templates/nextjs/base/src/{lib → core/lib}/seo.ts +0 -0
  227. /package/templates/nextjs/base/src/{lib → core/lib}/store-info.ts +0 -0
  228. /package/templates/nextjs/base/src/{lib → core/lib}/translations.ts.ejs +0 -0
  229. /package/templates/nextjs/base/src/{lib → core/lib}/utils.ts +0 -0
  230. /package/templates/nextjs/base/src/{lib → core/lib}/validation.ts +0 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Storefront footer (bare skeleton) — fully driven by the merchant's
3
+ * dashboard configuration.
4
+ *
5
+ * The merchant configures the footer in the Brainerce dashboard under
6
+ * Sell → Content → Footer
7
+ *
8
+ * Renders a brand block (store-name + social links), the merchant's link
9
+ * columns, and a copyright bar.
10
+ *
11
+ * API contract:
12
+ * GET → client.content.footer.get('main', locale) → Content<'FOOTER'> | null
13
+ * Returns null on 404 — we render a minimal fallback so the layout never
14
+ * crashes when the merchant hasn't seeded the footer yet.
15
+ */
16
+ import * as React from 'react';
17
+ import type { Content } from 'brainerce';
18
+
19
+ interface SiteFooterProps {
20
+ /** Pre-fetched footer payload (server-side). `null` triggers fallback rendering. */
21
+ footer: Content<'FOOTER'> | null;
22
+ /** Store name shown in the brand block + fallback copyright. */
23
+ storeName?: string;
24
+ }
25
+
26
+ export function SiteFooter({ footer, storeName }: SiteFooterProps) {
27
+ const data = footer?.data;
28
+ const columns = data?.columns ?? [];
29
+ const social = data?.social ?? [];
30
+ const year = new Date().getFullYear();
31
+ const brandLabel = storeName ?? 'Store';
32
+
33
+ if (!data || (columns.length === 0 && !data.copyright && social.length === 0)) {
34
+ return (
35
+ <footer>
36
+ {/* DESIGN ME — footer (fallback branch): copyright only; Content<'FOOTER'> pre-fetched in the layout. Compose with the shadcn/ui primitives in src/components/ui (Button, Card, Badge, Input, Select, Accordion, Dialog, Skeleton, ...) + lucide-react icons. */}
37
+ <p>
38
+ © {year} {brandLabel}. All rights reserved.
39
+ </p>
40
+ </footer>
41
+ );
42
+ }
43
+
44
+ return (
45
+ <footer>
46
+ {/* DESIGN ME — footer: brand block, merchant link columns and social links (Content<'FOOTER'> pre-fetched in the layout), copyright bar. Compose with the shadcn/ui primitives in src/components/ui (Button, Card, Badge, Input, Select, Accordion, Dialog, Skeleton, ...) + lucide-react icons. */}
47
+ <div>
48
+ <a href="/">{brandLabel}</a>
49
+ {social.length > 0 ? (
50
+ <ul className="flex flex-wrap items-center gap-2">
51
+ {social.map((entry, idx) => (
52
+ <li key={`${entry.platform}-${idx}`}>
53
+ <a href={entry.url} target="_blank" rel="noopener noreferrer" aria-label={entry.platform}>
54
+ {entry.platform}
55
+ </a>
56
+ </li>
57
+ ))}
58
+ </ul>
59
+ ) : null}
60
+ </div>
61
+
62
+ {columns.length > 0 ? (
63
+ <div className="flex flex-wrap gap-8">
64
+ {columns.map((col, idx) => (
65
+ <nav key={`${col.title}-${idx}`} aria-label={col.title}>
66
+ <h3>{col.title}</h3>
67
+ <ul>
68
+ {col.links.map((link, linkIdx) => (
69
+ <li key={`${link.url}-${linkIdx}`}>
70
+ <a href={link.url}>{link.label}</a>
71
+ </li>
72
+ ))}
73
+ </ul>
74
+ </nav>
75
+ ))}
76
+ </div>
77
+ ) : null}
78
+
79
+ <p>{data.copyright ?? `© ${year} ${brandLabel}. All rights reserved.`}</p>
80
+ </footer>
81
+ );
82
+ }
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Merchant-controlled site header (bare skeleton).
3
+ *
4
+ * The merchant configures the header in the Brainerce dashboard under
5
+ * Sell → Content → Header
6
+ *
7
+ * Renders brand (logo or store-name fallback) + nav items + CTA + cart link,
8
+ * with a `<details>` mobile-friendly menu that works without client-side JS.
9
+ * Everything is generic — do NOT hardcode nav labels or logo paths here; the
10
+ * merchant edits them in the dashboard and the change propagates within ~5
11
+ * minutes.
12
+ *
13
+ * If `header` is null (404 from the API, or the merchant deleted the row),
14
+ * we render a minimal static fallback with just the brand label and cart link
15
+ * so the layout never collapses.
16
+ */
17
+ import * as React from 'react';
18
+ import type { Content } from 'brainerce';
19
+ import { HeaderAccount } from './header-account';
20
+ <% if (i18nEnabled) { %>
21
+ import { LanguageSwitcher } from '@/ui/layout/language-switcher';
22
+ <% } %>
23
+
24
+ interface SiteHeaderProps {
25
+ /** Pre-fetched header payload (server-side). `null` triggers static fallback. */
26
+ header: Content<'HEADER'> | null;
27
+ /** Fallback brand label when the merchant hasn't uploaded a logo yet. */
28
+ storeName?: string;
29
+ }
30
+
31
+ export function SiteHeader({ header, storeName }: SiteHeaderProps) {
32
+ const data = header?.data;
33
+ const logo = data?.logo;
34
+ const navItems = data?.navItems ?? [];
35
+ const cta = data?.cta;
36
+ const brandLabel = logo?.alt || storeName || 'Store';
37
+
38
+ // Static fallback — runs when the Content API returned null (no HEADER row
39
+ // for this store yet, or fetch failed). Keep the brand + cart so the page
40
+ // always has a clickable home link and entry to checkout.
41
+ if (!header) {
42
+ return (
43
+ <header>
44
+ {/* DESIGN ME — site header (fallback branch, no merchant nav yet): brand link + account + cart; data comes pre-fetched from the layout via the Content API. Compose with the shadcn/ui primitives in src/components/ui (Button, Card, Badge, Input, Select, Accordion, Dialog, Skeleton, ...) + lucide-react icons. */}
45
+ <div className="flex items-center justify-between gap-4">
46
+ <a href="/" aria-label={brandLabel}>
47
+ {brandLabel}
48
+ </a>
49
+ <div className="flex items-center gap-2">
50
+ <% if (i18nEnabled) { %>
51
+ <LanguageSwitcher />
52
+ <% } %>
53
+ <HeaderAccount />
54
+ <a href="/cart" aria-label="Cart">
55
+ Cart
56
+ </a>
57
+ </div>
58
+ </div>
59
+ </header>
60
+ );
61
+ }
62
+
63
+ return (
64
+ <header>
65
+ {/* DESIGN ME — site header: merchant-configured logo/nav/CTA (Content<'HEADER'> pre-fetched in the layout) + account + cart links. Keep every link working. Compose with the shadcn/ui primitives in src/components/ui (Button, Card, Badge, Input, Select, Accordion, Dialog, Skeleton, ...) + lucide-react icons. */}
66
+ <div className="flex items-center justify-between gap-4">
67
+ <a href="/" className="flex items-center gap-2" aria-label={brandLabel}>
68
+ {logo ? (
69
+ // eslint-disable-next-line @next/next/no-img-element -- merchant-supplied URL, dynamic optimization handled by CDN
70
+ <img src={logo.src} alt={logo.alt} />
71
+ ) : (
72
+ <span>{brandLabel}</span>
73
+ )}
74
+ </a>
75
+
76
+ {navItems.length > 0 ? (
77
+ <nav aria-label="Main">
78
+ <ul className="flex items-center gap-4">
79
+ {navItems.map((item, idx) => (
80
+ <li key={`${item.url}-${idx}`}>
81
+ <a href={item.url}>{item.label}</a>
82
+ </li>
83
+ ))}
84
+ </ul>
85
+ </nav>
86
+ ) : null}
87
+
88
+ <div className="flex items-center gap-2">
89
+ {cta ? <a href={cta.url}>{cta.label}</a> : null}
90
+
91
+ <% if (i18nEnabled) { %>
92
+ <LanguageSwitcher />
93
+ <% } %>
94
+
95
+ <HeaderAccount />
96
+
97
+ <a href="/cart" aria-label="Cart">
98
+ Cart
99
+ </a>
100
+
101
+ {navItems.length > 0 ? (
102
+ <details>
103
+ <summary>Menu</summary>
104
+ <nav aria-label="Mobile">
105
+ <ul>
106
+ {navItems.map((item, idx) => (
107
+ <li key={`m-${item.url}-${idx}`}>
108
+ <a href={item.url}>{item.label}</a>
109
+ </li>
110
+ ))}
111
+ </ul>
112
+ </nav>
113
+ </details>
114
+ ) : null}
115
+ </div>
116
+ </div>
117
+ </header>
118
+ );
119
+ }
@@ -0,0 +1,445 @@
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+ import type { ProductCustomizationField } from 'brainerce';
5
+ import { useTranslations } from '@/core/lib/translations';
6
+ import { LoadingSpinner } from '@/ui/shared/loading-spinner';
7
+ import type { CustomizationValues } from '@/core/lib/product-options';
8
+
9
+ // The pure validation logic lives in core (zero markup) so that
10
+ // `core/hooks/use-product-page` never imports from `ui/`. Re-exported here
11
+ // for backward compatibility with existing imports.
12
+ export { validateCustomization } from '@/core/lib/product-options';
13
+ export type { CustomizationValues } from '@/core/lib/product-options';
14
+
15
+ interface CustomizationFieldsProps {
16
+ fields: ProductCustomizationField[];
17
+ values: CustomizationValues;
18
+ onChange: (values: CustomizationValues) => void;
19
+ errors?: Record<string, string>;
20
+ }
21
+
22
+ /**
23
+ * DESIGN ME — buyer-input customization fields on the product page
24
+ * (engraving text, gift date, uploaded artwork, …). Field definitions,
25
+ * values and validation errors come from useProductPage(); every input type
26
+ * below must stay functional (including the image/gallery uploads).
27
+ *
28
+ * Building blocks: shadcn/ui primitives in src/components/ui (Button, Card, Badge, Input, Select, Accordion, Dialog, Skeleton, ...) + lucide-react icons are installed and ready to compose with.
29
+ */
30
+ export function CustomizationFields({
31
+ fields,
32
+ values,
33
+ onChange,
34
+ errors = {},
35
+ }: CustomizationFieldsProps) {
36
+ const t = useTranslations('customization');
37
+
38
+ if (fields.length === 0) return null;
39
+
40
+ const sorted = [...fields].sort((a, b) => a.position - b.position);
41
+
42
+ const setValue = (key: string, value: unknown) => {
43
+ onChange({ ...values, [key]: value });
44
+ };
45
+
46
+ return (
47
+ <fieldset>
48
+ <legend>{t('title')}</legend>
49
+ <div>
50
+ {sorted.map((field) => (
51
+ <CustomizationFieldRow
52
+ key={field.definitionId}
53
+ field={field}
54
+ value={values[field.key]}
55
+ error={errors[field.key]}
56
+ onChange={(v) => setValue(field.key, v)}
57
+ />
58
+ ))}
59
+ </div>
60
+ </fieldset>
61
+ );
62
+ }
63
+
64
+ interface RowProps {
65
+ field: ProductCustomizationField;
66
+ value: unknown;
67
+ error?: string;
68
+ onChange: (value: unknown) => void;
69
+ }
70
+
71
+ function CustomizationFieldRow({ field, value, error, onChange }: RowProps) {
72
+ const t = useTranslations('customization');
73
+ const labelText = (
74
+ <span>
75
+ {field.name}
76
+ {field.required && <span aria-hidden="true"> *</span>}
77
+ </span>
78
+ );
79
+
80
+ const help = field.description ? <p>{field.description}</p> : null;
81
+
82
+ const errorHint = error ? <p role="alert">{error}</p> : null;
83
+
84
+ switch (field.type) {
85
+ case 'TEXTAREA':
86
+ return (
87
+ <div>
88
+ <label>
89
+ {labelText}
90
+ <textarea
91
+ value={typeof value === 'string' ? value : ''}
92
+ onChange={(e) => onChange(e.target.value)}
93
+ minLength={field.minLength ?? undefined}
94
+ maxLength={field.maxLength ?? undefined}
95
+ required={field.required}
96
+ rows={3}
97
+ />
98
+ </label>
99
+ {help}
100
+ {errorHint}
101
+ </div>
102
+ );
103
+
104
+ case 'NUMBER':
105
+ return (
106
+ <div>
107
+ <label>
108
+ {labelText}
109
+ <input
110
+ type="number"
111
+ value={typeof value === 'number' ? value : ''}
112
+ onChange={(e) =>
113
+ onChange(e.target.value === '' ? undefined : Number(e.target.value))
114
+ }
115
+ min={field.minValue ?? undefined}
116
+ max={field.maxValue ?? undefined}
117
+ required={field.required}
118
+ />
119
+ </label>
120
+ {help}
121
+ {errorHint}
122
+ </div>
123
+ );
124
+
125
+ case 'BOOLEAN':
126
+ return (
127
+ <div>
128
+ <label className="inline-flex items-center gap-2">
129
+ <input
130
+ type="checkbox"
131
+ checked={value === true}
132
+ onChange={(e) => onChange(e.target.checked)}
133
+ />
134
+ {labelText}
135
+ </label>
136
+ {help}
137
+ {errorHint}
138
+ </div>
139
+ );
140
+
141
+ case 'DATE':
142
+ return (
143
+ <div>
144
+ <label>
145
+ {labelText}
146
+ <input
147
+ type="date"
148
+ value={typeof value === 'string' ? value : ''}
149
+ onChange={(e) => onChange(e.target.value)}
150
+ required={field.required}
151
+ />
152
+ </label>
153
+ {help}
154
+ {errorHint}
155
+ </div>
156
+ );
157
+
158
+ case 'DATETIME':
159
+ return (
160
+ <div>
161
+ <label>
162
+ {labelText}
163
+ <input
164
+ type="datetime-local"
165
+ value={typeof value === 'string' ? value : ''}
166
+ onChange={(e) => onChange(e.target.value)}
167
+ required={field.required}
168
+ />
169
+ </label>
170
+ {help}
171
+ {errorHint}
172
+ </div>
173
+ );
174
+
175
+ case 'COLOR':
176
+ return (
177
+ <div>
178
+ <label>
179
+ {labelText}
180
+ <input
181
+ type="color"
182
+ value={typeof value === 'string' && value ? value : '#000000'}
183
+ onChange={(e) => onChange(e.target.value)}
184
+ required={field.required}
185
+ />
186
+ </label>
187
+ {help}
188
+ {errorHint}
189
+ </div>
190
+ );
191
+
192
+ case 'SELECT': {
193
+ const options = field.enumValues ?? [];
194
+ return (
195
+ <div>
196
+ <label>
197
+ {labelText}
198
+ <select
199
+ value={typeof value === 'string' ? value : ''}
200
+ onChange={(e) => onChange(e.target.value || undefined)}
201
+ required={field.required}
202
+ >
203
+ <option value="">{t('selectPlaceholder')}</option>
204
+ {options.map((opt) => (
205
+ <option key={opt.value} value={opt.value}>
206
+ {opt.label || opt.value}
207
+ </option>
208
+ ))}
209
+ </select>
210
+ </label>
211
+ {help}
212
+ {errorHint}
213
+ </div>
214
+ );
215
+ }
216
+
217
+ case 'MULTI_SELECT': {
218
+ const options = field.enumValues ?? [];
219
+ const current = Array.isArray(value) ? (value as string[]) : [];
220
+ const toggle = (opt: string) => {
221
+ onChange(current.includes(opt) ? current.filter((v) => v !== opt) : [...current, opt]);
222
+ };
223
+ return (
224
+ <fieldset>
225
+ <legend>{labelText}</legend>
226
+ <div>
227
+ {options.map((opt) => (
228
+ <label key={opt.value} className="inline-flex items-center gap-2">
229
+ <input
230
+ type="checkbox"
231
+ checked={current.includes(opt.value)}
232
+ onChange={() => toggle(opt.value)}
233
+ />
234
+ {opt.label || opt.value}
235
+ </label>
236
+ ))}
237
+ </div>
238
+ {help}
239
+ {errorHint}
240
+ </fieldset>
241
+ );
242
+ }
243
+
244
+ case 'IMAGE':
245
+ return (
246
+ <SingleImageField
247
+ field={field}
248
+ value={typeof value === 'string' ? value : undefined}
249
+ onChange={onChange}
250
+ labelText={labelText}
251
+ help={help}
252
+ errorHint={errorHint}
253
+ />
254
+ );
255
+
256
+ case 'GALLERY':
257
+ return (
258
+ <GalleryField
259
+ field={field}
260
+ value={Array.isArray(value) ? (value as string[]) : []}
261
+ onChange={onChange}
262
+ labelText={labelText}
263
+ help={help}
264
+ errorHint={errorHint}
265
+ />
266
+ );
267
+
268
+ case 'URL':
269
+ return (
270
+ <div>
271
+ <label>
272
+ {labelText}
273
+ <input
274
+ type="url"
275
+ value={typeof value === 'string' ? value : ''}
276
+ onChange={(e) => onChange(e.target.value)}
277
+ required={field.required}
278
+ />
279
+ </label>
280
+ {help}
281
+ {errorHint}
282
+ </div>
283
+ );
284
+
285
+ default:
286
+ return (
287
+ <div>
288
+ <label>
289
+ {labelText}
290
+ <input
291
+ type="text"
292
+ value={typeof value === 'string' ? value : ''}
293
+ onChange={(e) => onChange(e.target.value)}
294
+ minLength={field.minLength ?? undefined}
295
+ maxLength={field.maxLength ?? undefined}
296
+ required={field.required}
297
+ />
298
+ </label>
299
+ {help}
300
+ {errorHint}
301
+ </div>
302
+ );
303
+ }
304
+ }
305
+
306
+ interface FileFieldProps {
307
+ field: ProductCustomizationField;
308
+ labelText: React.ReactNode;
309
+ help: React.ReactNode;
310
+ errorHint: React.ReactNode;
311
+ onChange: (value: unknown) => void;
312
+ }
313
+
314
+ function SingleImageField({
315
+ field,
316
+ value,
317
+ onChange,
318
+ labelText,
319
+ help,
320
+ errorHint,
321
+ }: FileFieldProps & { value?: string }) {
322
+ const t = useTranslations('customization');
323
+ const [uploading, setUploading] = useState(false);
324
+ const [uploadError, setUploadError] = useState<string | null>(null);
325
+
326
+ async function handleFile(file: File | null) {
327
+ if (!file) return;
328
+ setUploading(true);
329
+ setUploadError(null);
330
+ try {
331
+ const { getClient } = await import('@/core/lib/brainerce');
332
+ const client = getClient();
333
+ const result = await client.uploadCustomizationFile(file);
334
+ onChange(result.url);
335
+ } catch (err) {
336
+ console.error('Upload failed', err);
337
+ setUploadError(t('uploadFailed'));
338
+ } finally {
339
+ setUploading(false);
340
+ }
341
+ }
342
+
343
+ return (
344
+ <div>
345
+ <label>
346
+ {labelText}
347
+ <input
348
+ type="file"
349
+ accept="image/*"
350
+ onChange={(e) => handleFile(e.target.files?.[0] ?? null)}
351
+ disabled={uploading}
352
+ required={field.required && !value}
353
+ />
354
+ </label>
355
+ {uploading && (
356
+ <span>
357
+ <LoadingSpinner size="sm" />
358
+ {t('uploading')}
359
+ </span>
360
+ )}
361
+ {value && !uploading && (
362
+ <div>
363
+ <img src={value} alt="" className="h-20 w-20" />
364
+ </div>
365
+ )}
366
+ {uploadError && <p role="alert">{uploadError}</p>}
367
+ {help}
368
+ {errorHint}
369
+ </div>
370
+ );
371
+ }
372
+
373
+ function GalleryField({
374
+ field,
375
+ value,
376
+ onChange,
377
+ labelText,
378
+ help,
379
+ errorHint,
380
+ }: FileFieldProps & { value: string[] }) {
381
+ const t = useTranslations('customization');
382
+ const [uploading, setUploading] = useState(false);
383
+ const [uploadError, setUploadError] = useState<string | null>(null);
384
+
385
+ async function handleFiles(fileList: FileList | null) {
386
+ if (!fileList || fileList.length === 0) return;
387
+ setUploading(true);
388
+ setUploadError(null);
389
+ try {
390
+ const { getClient } = await import('@/core/lib/brainerce');
391
+ const client = getClient();
392
+ const newUrls: string[] = [];
393
+ for (const file of Array.from(fileList)) {
394
+ const result = await client.uploadCustomizationFile(file);
395
+ newUrls.push(result.url);
396
+ }
397
+ onChange([...value, ...newUrls]);
398
+ } catch (err) {
399
+ console.error('Upload failed', err);
400
+ setUploadError(t('uploadFailed'));
401
+ } finally {
402
+ setUploading(false);
403
+ }
404
+ }
405
+
406
+ function removeAt(idx: number) {
407
+ onChange(value.filter((_, i) => i !== idx));
408
+ }
409
+
410
+ return (
411
+ <div>
412
+ <label>
413
+ {labelText}
414
+ <input
415
+ type="file"
416
+ accept="image/*"
417
+ multiple
418
+ onChange={(e) => handleFiles(e.target.files)}
419
+ disabled={uploading}
420
+ />
421
+ </label>
422
+ {uploading && (
423
+ <span>
424
+ <LoadingSpinner size="sm" />
425
+ {t('uploading')}
426
+ </span>
427
+ )}
428
+ {value.length > 0 && (
429
+ <ul className="flex flex-wrap gap-2">
430
+ {value.map((url, idx) => (
431
+ <li key={`${url}-${idx}`}>
432
+ <img src={url} alt="" className="h-16 w-16" />
433
+ <button type="button" onClick={() => removeAt(idx)} aria-label={t('removeImage')}>
434
+ ×
435
+ </button>
436
+ </li>
437
+ ))}
438
+ </ul>
439
+ )}
440
+ {uploadError && <p role="alert">{uploadError}</p>}
441
+ {help}
442
+ {errorHint}
443
+ </div>
444
+ );
445
+ }
@@ -0,0 +1,19 @@
1
+ import type { ProductDiscount } from 'brainerce';
2
+ import { cn } from '@/core/lib/utils';
3
+
4
+ interface DiscountBadgeProps {
5
+ discount?: ProductDiscount | null;
6
+ className?: string;
7
+ }
8
+
9
+ /**
10
+ * DESIGN ME — discount-rule badge shown on product cards; text comes from
11
+ * the product's `discount.badgeText` (merchant-configured rule).
12
+ *
13
+ * Building blocks: shadcn/ui primitives in src/components/ui (Button, Card, Badge, Input, Select, Accordion, Dialog, Skeleton, ...) + lucide-react icons are installed and ready to compose with.
14
+ */
15
+ export function DiscountBadge({ discount, className }: DiscountBadgeProps) {
16
+ if (!discount) return null;
17
+
18
+ return <span className={cn(className)}>{discount.badgeText}</span>;
19
+ }