create-brainerce-store 1.50.1 → 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 (189) 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 +18 -10
  13. package/templates/nextjs/base/package.json.ejs +5 -1
  14. package/templates/nextjs/base/src/app/account/page.tsx +5 -5
  15. package/templates/nextjs/base/src/app/api/auth/logout/route.ts +1 -1
  16. package/templates/nextjs/base/src/app/api/auth/reset-password/route.ts +2 -2
  17. package/templates/nextjs/base/src/app/api/store/[...path]/route.ts +1 -1
  18. package/templates/nextjs/base/src/app/auth/callback/page.tsx +4 -4
  19. package/templates/nextjs/base/src/app/blog/[slug]/page.tsx.ejs +4 -4
  20. package/templates/nextjs/base/src/app/blog/page.tsx.ejs +2 -2
  21. package/templates/nextjs/base/src/app/cart/page.tsx +2 -173
  22. package/templates/nextjs/base/src/app/checkout/page.tsx +12 -11
  23. package/templates/nextjs/base/src/app/contact/page.tsx +3 -3
  24. package/templates/nextjs/base/src/app/faq/page.tsx.ejs +2 -2
  25. package/templates/nextjs/base/src/app/forgot-password/page.tsx +4 -4
  26. package/templates/nextjs/base/src/app/layout.tsx.ejs +16 -14
  27. package/templates/nextjs/base/src/app/login/page.tsx +4 -4
  28. package/templates/nextjs/base/src/app/order-confirmation/page.tsx +19 -12
  29. package/templates/nextjs/base/src/app/page.tsx +4 -4
  30. package/templates/nextjs/base/src/app/pages/[slug]/page.tsx.ejs +3 -3
  31. package/templates/nextjs/base/src/app/payment-complete/page.tsx +1 -1
  32. package/templates/nextjs/base/src/app/products/[slug]/page.tsx +6 -6
  33. package/templates/nextjs/base/src/app/products/page.tsx +4 -623
  34. package/templates/nextjs/base/src/app/register/page.tsx +4 -4
  35. package/templates/nextjs/base/src/app/reset-password/page.tsx +5 -5
  36. package/templates/nextjs/base/src/app/sitemap.ts +1 -1
  37. package/templates/nextjs/base/src/app/verify-email/page.tsx +5 -5
  38. package/templates/nextjs/base/src/components/account/address-book.tsx +3 -3
  39. package/templates/nextjs/base/src/components/account/order-customizations.tsx +3 -3
  40. package/templates/nextjs/base/src/components/account/order-history.tsx +13 -5
  41. package/templates/nextjs/base/src/components/account/order-payment-block.tsx +2 -2
  42. package/templates/nextjs/base/src/components/account/order-shipping-block.tsx +2 -2
  43. package/templates/nextjs/base/src/components/account/order-status-timeline.tsx +2 -2
  44. package/templates/nextjs/base/src/components/account/profile-section.tsx +3 -3
  45. package/templates/nextjs/base/src/components/auth/login-form.tsx +4 -4
  46. package/templates/nextjs/base/src/components/auth/oauth-buttons.tsx +4 -4
  47. package/templates/nextjs/base/src/components/auth/register-form.tsx +4 -4
  48. package/templates/nextjs/base/src/components/brainerce-bot.tsx +2 -2
  49. package/templates/nextjs/base/src/components/checkout/checkout-form.tsx +24 -3
  50. package/templates/nextjs/base/src/components/checkout/custom-fields-step.tsx +2 -2
  51. package/templates/nextjs/base/src/components/checkout/delivery-method-step.tsx +2 -2
  52. package/templates/nextjs/base/src/components/checkout/order-bump-card.tsx +4 -4
  53. package/templates/nextjs/base/src/components/checkout/payment-step.tsx +6 -6
  54. package/templates/nextjs/base/src/components/checkout/pickup-step.tsx +3 -3
  55. package/templates/nextjs/base/src/components/checkout/shipping-step.tsx +3 -3
  56. package/templates/nextjs/base/src/components/checkout/tax-display.tsx +3 -3
  57. package/templates/nextjs/base/src/components/seo/organization-json-ld.tsx +2 -2
  58. package/templates/nextjs/base/src/components/seo/product-json-ld.tsx +3 -3
  59. package/templates/nextjs/base/src/core/hooks/use-cart-page.ts +58 -0
  60. package/templates/nextjs/base/src/core/hooks/use-home-data.ts +51 -0
  61. package/templates/nextjs/base/src/core/hooks/use-product-listing.ts +295 -0
  62. package/templates/nextjs/base/src/core/hooks/use-product-page.ts +278 -0
  63. package/templates/nextjs/base/src/{hooks → core/hooks}/use-search.ts +1 -1
  64. package/templates/nextjs/base/src/{lib → core/lib}/brainerce.ts.ejs +1 -1
  65. package/templates/nextjs/base/src/core/lib/image-hosts.ts +7 -0
  66. package/templates/nextjs/base/src/core/lib/product-options.ts +121 -0
  67. package/templates/nextjs/base/src/{lib → core/lib}/resolve-currency.ts +1 -1
  68. package/templates/nextjs/base/src/{lib → core/lib}/safe-redirect.ts +1 -1
  69. package/templates/nextjs/base/src/{lib → core/lib}/sanitize-html.ts +12 -0
  70. package/templates/nextjs/base/src/{lib → core/lib}/sanitize.ts.ejs +1 -1
  71. package/templates/nextjs/base/src/{lib → core/lib}/use-currency.ts +1 -1
  72. package/templates/nextjs/base/src/{providers → core/providers}/store-provider.tsx.ejs +4 -4
  73. package/templates/nextjs/base/src/middleware.ts.ejs +2 -2
  74. package/templates/nextjs/base/src/{components → ui}/cart/cart-bundle-offer.tsx +5 -5
  75. package/templates/nextjs/base/src/{components → ui}/cart/cart-item.tsx +6 -6
  76. package/templates/nextjs/base/src/{components → ui}/cart/cart-nudges.tsx +1 -1
  77. package/templates/nextjs/base/src/{components → ui}/cart/cart-summary.tsx +4 -4
  78. package/templates/nextjs/base/src/{components → ui}/cart/cart-upgrade-banner.tsx +5 -5
  79. package/templates/nextjs/base/src/ui/cart/cart-view.tsx +149 -0
  80. package/templates/nextjs/base/src/{components → ui}/cart/coupon-input.tsx +4 -4
  81. package/templates/nextjs/base/src/{components → ui}/cart/free-shipping-bar.tsx +4 -4
  82. package/templates/nextjs/base/src/{components → ui}/cart/reservation-countdown.tsx +2 -2
  83. package/templates/nextjs/base/src/ui/home/discount-banner-strip.tsx +20 -0
  84. package/templates/nextjs/base/src/ui/home/featured-products-section.tsx +24 -0
  85. package/templates/nextjs/base/src/ui/home/hero-section.tsx +29 -0
  86. package/templates/nextjs/base/src/ui/home/home-client.tsx +29 -0
  87. package/templates/nextjs/base/src/{components/content → ui/layout}/faq-section.tsx.ejs +2 -2
  88. package/templates/nextjs/base/src/{components/content → ui/layout}/header-account.tsx +3 -3
  89. package/templates/nextjs/base/src/{components/content → ui/layout}/rich-text-block.tsx.ejs +1 -1
  90. package/templates/nextjs/base/src/{components/content → ui/layout}/site-header.tsx.ejs +1 -1
  91. package/templates/nextjs/base/src/{components/products → ui/product}/customization-fields.tsx +18 -51
  92. package/templates/nextjs/base/src/{components/products → ui/product}/discount-badge.tsx +1 -1
  93. package/templates/nextjs/base/src/{components/products → ui/product}/frequently-bought-together.tsx +6 -6
  94. package/templates/nextjs/base/src/{components/products → ui/product}/modifier-group-selector.tsx +10 -77
  95. package/templates/nextjs/base/src/{components/shared → ui/product}/price-display.tsx +2 -2
  96. package/templates/nextjs/base/src/{components/products → ui/product}/product-card.tsx +10 -10
  97. package/templates/nextjs/base/src/{app/products/[slug] → ui/product}/product-client-section.tsx +45 -206
  98. package/templates/nextjs/base/src/{components/products → ui/product}/product-grid.tsx +3 -3
  99. package/templates/nextjs/base/src/ui/product/product-listing.tsx +429 -0
  100. package/templates/nextjs/base/src/{components/products → ui/product}/recommendation-section.tsx +4 -4
  101. package/templates/nextjs/base/src/{components/reviews → ui/product}/review-form.tsx +2 -2
  102. package/templates/nextjs/base/src/{components/reviews → ui/product}/reviews-section.tsx +1 -1
  103. package/templates/nextjs/base/src/{components/products → ui/product}/stock-badge.tsx +2 -2
  104. package/templates/nextjs/base/src/{components/products → ui/product}/variant-selector.tsx +3 -3
  105. package/templates/nextjs/base/src/ui/shared/cdn-image.tsx +26 -0
  106. package/templates/nextjs/base/src/{components → ui}/shared/loading-spinner.tsx +2 -2
  107. package/templates/nextjs/base/tailwind.config.ts +12 -0
  108. package/templates/nextjs/designs/passepartout/app-overlay/layout.tsx.ejs +253 -0
  109. package/templates/nextjs/designs/passepartout/globals.css +412 -0
  110. package/templates/nextjs/designs/passepartout/messages-patch/en.json +87 -0
  111. package/templates/nextjs/designs/passepartout/messages-patch/he.json +87 -0
  112. package/templates/nextjs/designs/passepartout/ui/cart/cart-bundle-offer.tsx +111 -0
  113. package/templates/nextjs/designs/passepartout/ui/cart/cart-nudges.tsx +39 -0
  114. package/templates/nextjs/designs/passepartout/ui/cart/cart-upgrade-banner.tsx +141 -0
  115. package/templates/nextjs/designs/passepartout/ui/cart/cart-view.tsx +149 -0
  116. package/templates/nextjs/designs/passepartout/ui/cart/free-shipping-bar.tsx +62 -0
  117. package/templates/nextjs/designs/passepartout/ui/cart/reservation-countdown.tsx +103 -0
  118. package/templates/nextjs/designs/passepartout/ui/home/home-client.tsx +401 -0
  119. package/templates/nextjs/designs/passepartout/ui/layout/announcement-bar.tsx +139 -0
  120. package/templates/nextjs/designs/passepartout/ui/layout/cart-link.tsx +45 -0
  121. package/templates/nextjs/designs/passepartout/ui/layout/faq-section.tsx +103 -0
  122. package/templates/nextjs/designs/passepartout/ui/layout/site-footer.tsx +159 -0
  123. package/templates/nextjs/designs/passepartout/ui/layout/site-header.tsx.ejs +155 -0
  124. package/templates/nextjs/designs/passepartout/ui/layout/trust-icons.tsx +60 -0
  125. package/templates/nextjs/designs/passepartout/ui/layout/whatsapp-button.tsx +34 -0
  126. package/templates/nextjs/designs/passepartout/ui/product/discount-badge.tsx +22 -0
  127. package/templates/nextjs/designs/passepartout/ui/product/frequently-bought-together.tsx +205 -0
  128. package/templates/nextjs/designs/passepartout/ui/product/price-display.tsx +111 -0
  129. package/templates/nextjs/designs/passepartout/ui/product/product-card.tsx +265 -0
  130. package/templates/nextjs/designs/passepartout/ui/product/product-client-section.tsx +667 -0
  131. package/templates/nextjs/designs/passepartout/ui/product/product-grid.tsx +35 -0
  132. package/templates/nextjs/designs/passepartout/ui/product/product-listing.tsx +427 -0
  133. package/templates/nextjs/designs/passepartout/ui/product/recommendation-section.tsx +113 -0
  134. package/templates/nextjs/designs/passepartout/ui/product/review-form.tsx +294 -0
  135. package/templates/nextjs/designs/passepartout/ui/product/reviews-section.tsx.ejs +96 -0
  136. package/templates/nextjs/designs/passepartout/ui/product/stock-badge.tsx +52 -0
  137. package/templates/nextjs/designs/passepartout/ui/product/variant-selector.tsx +307 -0
  138. package/templates/nextjs/designs/passepartout/ui/shared/fly-to-cart.ts +85 -0
  139. package/templates/nextjs/designs/passepartout/ui/shared/loading-spinner.tsx +33 -0
  140. package/templates/nextjs/ui-canvas/cart/cart-bundle-offer.tsx +87 -0
  141. package/templates/nextjs/ui-canvas/cart/cart-item.tsx +121 -0
  142. package/templates/nextjs/ui-canvas/cart/cart-nudges.tsx +25 -0
  143. package/templates/nextjs/ui-canvas/cart/cart-summary.tsx +97 -0
  144. package/templates/nextjs/ui-canvas/cart/cart-upgrade-banner.tsx +103 -0
  145. package/templates/nextjs/ui-canvas/cart/cart-view.tsx +106 -0
  146. package/templates/nextjs/ui-canvas/cart/coupon-input.tsx +117 -0
  147. package/templates/nextjs/ui-canvas/cart/free-shipping-bar.tsx +52 -0
  148. package/templates/nextjs/ui-canvas/cart/reservation-countdown.tsx +79 -0
  149. package/templates/nextjs/ui-canvas/home/discount-banner-strip.tsx +19 -0
  150. package/templates/nextjs/ui-canvas/home/featured-products-section.tsx +23 -0
  151. package/templates/nextjs/ui-canvas/home/hero-section.tsx +21 -0
  152. package/templates/nextjs/ui-canvas/home/home-client.tsx +26 -0
  153. package/templates/nextjs/ui-canvas/layout/announcement-bar.tsx.ejs +101 -0
  154. package/templates/nextjs/ui-canvas/layout/faq-section.tsx.ejs +71 -0
  155. package/templates/nextjs/ui-canvas/layout/header-account.tsx +31 -0
  156. package/templates/nextjs/ui-canvas/layout/language-switcher.tsx.ejs +74 -0
  157. package/templates/nextjs/ui-canvas/layout/rich-text-block.tsx.ejs +34 -0
  158. package/templates/nextjs/ui-canvas/layout/site-footer.tsx.ejs +82 -0
  159. package/templates/nextjs/ui-canvas/layout/site-header.tsx.ejs +119 -0
  160. package/templates/nextjs/ui-canvas/product/customization-fields.tsx +443 -0
  161. package/templates/nextjs/ui-canvas/product/discount-badge.tsx +17 -0
  162. package/templates/nextjs/ui-canvas/product/frequently-bought-together.tsx +166 -0
  163. package/templates/nextjs/ui-canvas/product/modifier-group-selector.tsx +163 -0
  164. package/templates/nextjs/ui-canvas/product/price-display.tsx +50 -0
  165. package/templates/nextjs/ui-canvas/product/product-card.tsx +197 -0
  166. package/templates/nextjs/ui-canvas/product/product-client-section.tsx +352 -0
  167. package/templates/nextjs/ui-canvas/product/product-grid.tsx +27 -0
  168. package/templates/nextjs/ui-canvas/product/product-listing.tsx +224 -0
  169. package/templates/nextjs/ui-canvas/product/recommendation-section.tsx +95 -0
  170. package/templates/nextjs/ui-canvas/product/review-form.tsx +269 -0
  171. package/templates/nextjs/ui-canvas/product/reviews-section.tsx +78 -0
  172. package/templates/nextjs/ui-canvas/product/stock-badge.tsx +43 -0
  173. package/templates/nextjs/ui-canvas/product/variant-selector.tsx +210 -0
  174. package/templates/nextjs/ui-canvas/shared/cdn-image.tsx +29 -0
  175. package/templates/nextjs/ui-canvas/shared/loading-spinner.tsx +25 -0
  176. package/templates/nextjs/base/src/app/home-client.tsx +0 -98
  177. package/templates/nextjs/base/src/components/products/allergen-chips.tsx +0 -78
  178. /package/templates/nextjs/base/src/{lib → core/lib}/auth.ts +0 -0
  179. /package/templates/nextjs/base/src/{lib → core/lib}/csrf.ts +0 -0
  180. /package/templates/nextjs/base/src/{lib → core/lib}/navigation.tsx.ejs +0 -0
  181. /package/templates/nextjs/base/src/{lib → core/lib}/nonce.ts +0 -0
  182. /package/templates/nextjs/base/src/{lib → core/lib}/seo.ts +0 -0
  183. /package/templates/nextjs/base/src/{lib → core/lib}/store-info.ts +0 -0
  184. /package/templates/nextjs/base/src/{lib → core/lib}/translations.ts.ejs +0 -0
  185. /package/templates/nextjs/base/src/{lib → core/lib}/utils.ts +0 -0
  186. /package/templates/nextjs/base/src/{lib → core/lib}/validation.ts +0 -0
  187. /package/templates/nextjs/base/src/{components/content → ui/layout}/announcement-bar.tsx.ejs +0 -0
  188. /package/templates/nextjs/base/src/{components → ui}/layout/language-switcher.tsx.ejs +0 -0
  189. /package/templates/nextjs/base/src/{components/content → ui/layout}/site-footer.tsx.ejs +0 -0
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Storefront announcement bar (bare skeleton) — fully driven by the
3
+ * merchant's dashboard.
4
+ *
5
+ * The merchant configures announcements in the Brainerce dashboard under
6
+ * Sell → Content → Announcement
7
+ *
8
+ * Everything below is generic rendering logic — it adapts automatically to
9
+ * any announcement shape returned by the API, so **you should not hardcode
10
+ * the message or severity here**.
11
+ *
12
+ * API contract:
13
+ * GET → client.content.announcement.list(locale) → Content<'ANNOUNCEMENT'>[]
14
+ * Empty array → renders nothing (page layout stays intact).
15
+ *
16
+ * Time-bounded: each announcement may have `startsAt` / `endsAt` ISO
17
+ * timestamps. We filter client-side so the cached server response can be
18
+ * shared across visitors regardless of the current time.
19
+ *
20
+ * Each announcement carries `data.severity` ('info' | 'warning' | 'success')
21
+ * — the skeleton ignores it visually; use it to tone your design.
22
+ */
23
+ 'use client';
24
+
25
+ import * as React from 'react';
26
+ import type { Content } from 'brainerce';
27
+
28
+ interface AnnouncementBarProps {
29
+ /** Pre-fetched list from the server. Pass `[]` to render nothing. */
30
+ announcements: Content<'ANNOUNCEMENT'>[];
31
+ }
32
+
33
+ const STORAGE_KEY = 'brainerce_dismissed_announcements';
34
+
35
+ export function AnnouncementBar({ announcements }: AnnouncementBarProps) {
36
+ const [dismissed, setDismissed] = React.useState<Set<string>>(() => new Set());
37
+
38
+ // Hydrate dismissals from localStorage on mount (avoids SSR/CSR mismatch).
39
+ React.useEffect(() => {
40
+ if (typeof window === 'undefined') return;
41
+ try {
42
+ const raw = window.localStorage.getItem(STORAGE_KEY);
43
+ if (raw) setDismissed(new Set(JSON.parse(raw) as string[]));
44
+ } catch {
45
+ // ignore malformed storage
46
+ }
47
+ }, []);
48
+
49
+ const dismiss = (id: string) => {
50
+ setDismissed((prev) => {
51
+ const next = new Set(prev);
52
+ next.add(id);
53
+ if (typeof window !== 'undefined') {
54
+ try {
55
+ window.localStorage.setItem(STORAGE_KEY, JSON.stringify([...next]));
56
+ } catch {
57
+ // ignore quota errors
58
+ }
59
+ }
60
+ return next;
61
+ });
62
+ };
63
+
64
+ const now = Date.now();
65
+ const visible = announcements.filter((a) => {
66
+ if (dismissed.has(a.id)) return false;
67
+ const startOk = !a.data.startsAt || new Date(a.data.startsAt).getTime() <= now;
68
+ const endOk = !a.data.endsAt || new Date(a.data.endsAt).getTime() >= now;
69
+ return startOk && endOk;
70
+ });
71
+
72
+ if (visible.length === 0) return null;
73
+
74
+ return (
75
+ <div role="region" aria-label="Site announcements">
76
+ {/* DESIGN ME — announcement bar(s) at the very top of every page; data.severity + message + optional CTA come from Content<'ANNOUNCEMENT'>[] pre-fetched in the layout */}
77
+ {visible.map((announcement) => (
78
+ <div key={announcement.id} data-severity={announcement.data.severity} className="flex items-center gap-3">
79
+ <span>
80
+ {announcement.data.message}
81
+ {announcement.data.ctaHref && announcement.data.ctaLabel ? (
82
+ <>
83
+ {' '}
84
+ <a href={announcement.data.ctaHref}>{announcement.data.ctaLabel}</a>
85
+ </>
86
+ ) : null}
87
+ </span>
88
+ {announcement.data.dismissible ? (
89
+ <button
90
+ type="button"
91
+ onClick={() => dismiss(announcement.id)}
92
+ aria-label="Dismiss announcement"
93
+ >
94
+ ×
95
+ </button>
96
+ ) : null}
97
+ </div>
98
+ ))}
99
+ </div>
100
+ );
101
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * FAQ accordion (bare skeleton) — fully driven by the merchant's dashboard
3
+ * configuration.
4
+ *
5
+ * The merchant configures FAQs in the Brainerce dashboard under
6
+ * Sell → Content → FAQ
7
+ *
8
+ * Each FAQ row has a `key` (e.g. 'main', 'shipping', 'returns'). Pass the
9
+ * pre-fetched payload as `faq`; this component knows nothing about which
10
+ * key it came from.
11
+ *
12
+ * Two render branches:
13
+ * 1. `faq` has items → accordion of question/answer pairs
14
+ * 2. `faq` is null OR has no items → friendly empty state with a contact
15
+ * CTA, so the /faq page never looks broken before the merchant seeds.
16
+ *
17
+ * Security: FAQ answers may contain merchant-authored HTML — we sanitize
18
+ * via `sanitizeHtml` before injecting via dangerouslySetInnerHTML.
19
+ */
20
+ 'use client';
21
+
22
+ import * as React from 'react';
23
+ import type { Content } from 'brainerce';
24
+ import { useTranslations } from '@/core/lib/translations';
25
+ import { sanitizeHtml } from '@/core/lib/sanitize';
26
+
27
+ interface FaqSectionProps {
28
+ /** Pre-fetched FAQ row. `null` renders the empty-state fallback. */
29
+ faq: Content<'FAQ'> | null;
30
+ }
31
+
32
+ export function FaqSection({ faq }: FaqSectionProps) {
33
+ const t = useTranslations('content');
34
+
35
+ const items = faq?.data?.items ?? [];
36
+ const heading = faq?.name || t('faqTitle');
37
+
38
+ // Empty state — runs when the merchant hasn't created a FAQ row yet,
39
+ // or the row exists but contains no items.
40
+ if (!faq || items.length === 0) {
41
+ return (
42
+ <section>
43
+ {/* DESIGN ME — FAQ empty state: heading + contact CTA; fed by Content<'FAQ'> pre-fetched in the /faq route */}
44
+ <h1>{heading}</h1>
45
+ <p>
46
+ <strong>{t('faqEmptyTitle')}</strong>
47
+ <br />
48
+ {t('faqEmptyBody')}
49
+ </p>
50
+ <a href="/contact">{t('faqContactCta')}</a>
51
+ </section>
52
+ );
53
+ }
54
+
55
+ return (
56
+ <section>
57
+ {/* DESIGN ME — FAQ accordion: question/answer pairs from Content<'FAQ'> pre-fetched in the /faq route; answers are sanitized merchant HTML */}
58
+ <h1>{heading}</h1>
59
+ <ul>
60
+ {items.map((item, idx) => (
61
+ <li key={idx}>
62
+ <details open={idx === 0}>
63
+ <summary>{item.question}</summary>
64
+ <div dangerouslySetInnerHTML={{ __html: sanitizeHtml(item.answer) }} />
65
+ </details>
66
+ </li>
67
+ ))}
68
+ </ul>
69
+ </section>
70
+ );
71
+ }
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * Auth-aware account control for the site header (bare skeleton).
5
+ *
6
+ * The header itself is a server component fed by merchant-configured Content,
7
+ * so it can't read client auth state. This small client island bridges that:
8
+ * it links to `/account` when the visitor is signed in (the account page shows
9
+ * profile + orders + sign-out) and to `/login` otherwise.
10
+ */
11
+ import * as React from 'react';
12
+ import { Link } from '@/core/lib/navigation';
13
+ import { useAuth } from '@/core/providers/store-provider';
14
+ import { useTranslations } from '@/core/lib/translations';
15
+
16
+ export function HeaderAccount() {
17
+ const { isLoggedIn } = useAuth();
18
+ const t = useTranslations('nav');
19
+
20
+ // Guests land on /login; signed-in visitors go to /account (which itself
21
+ // bounces guests back to /login, so the link is safe even mid auth-resolve).
22
+ const href = isLoggedIn ? '/account' : '/login';
23
+ const label = isLoggedIn ? t('account') : t('login');
24
+
25
+ return (
26
+ <Link href={href} aria-label={label}>
27
+ {/* DESIGN ME — header account link; auth state via useAuth(), label via the `nav` translation namespace */}
28
+ {label}
29
+ </Link>
30
+ );
31
+ }
@@ -0,0 +1,74 @@
1
+ <% if (i18nEnabled) { %>
2
+ 'use client';
3
+
4
+ import { usePathname } from 'next/navigation';
5
+ import { supportedLocales } from '@/i18n';
6
+
7
+ const LOCALE_NAMES: Record<string, string> = {
8
+ en: 'English',
9
+ he: 'עברית',
10
+ ar: 'العربية',
11
+ es: 'Español',
12
+ fr: 'Français',
13
+ de: 'Deutsch',
14
+ it: 'Italiano',
15
+ pt: 'Português',
16
+ nl: 'Nederlands',
17
+ ja: '日本語',
18
+ ko: '한국어',
19
+ zh: '中文',
20
+ ru: 'Русский',
21
+ tr: 'Türkçe',
22
+ pl: 'Polski',
23
+ sv: 'Svenska',
24
+ da: 'Dansk',
25
+ no: 'Norsk',
26
+ fi: 'Suomi',
27
+ cs: 'Čeština',
28
+ th: 'ไทย',
29
+ vi: 'Tiếng Việt',
30
+ };
31
+
32
+ const defaultLocale = '<%= defaultLocale %>';
33
+
34
+ /**
35
+ * DESIGN ME — locale switcher in the header; reads supported locales from
36
+ * `@/i18n` and swaps the URL prefix. Keep the aria-label and the redirect
37
+ * logic exactly as-is.
38
+ */
39
+ export function LanguageSwitcher() {
40
+ const pathname = usePathname();
41
+ const firstSeg = pathname.split('/')[1];
42
+ const currentLocale = supportedLocales.includes(firstSeg as (typeof supportedLocales)[number])
43
+ ? firstSeg
44
+ : defaultLocale;
45
+
46
+ function switchLocale(newLocale: string) {
47
+ // Strip any existing locale segment, then re-add only if the new one
48
+ // isn't the default — matches the as-needed prefix scheme in middleware.
49
+ const segments = pathname.split('/');
50
+ if (supportedLocales.includes(segments[1] as (typeof supportedLocales)[number])) {
51
+ segments.splice(1, 1);
52
+ }
53
+ const bare = segments.join('/') || '/';
54
+ window.location.href =
55
+ newLocale === defaultLocale ? bare : `/${newLocale}${bare === '/' ? '' : bare}`;
56
+ }
57
+
58
+ if (supportedLocales.length <= 1) return null;
59
+
60
+ return (
61
+ <select
62
+ value={currentLocale}
63
+ onChange={(e) => switchLocale(e.target.value)}
64
+ aria-label="Select language"
65
+ >
66
+ {supportedLocales.map((locale) => (
67
+ <option key={locale} value={locale}>
68
+ {LOCALE_NAMES[locale] || locale}
69
+ </option>
70
+ ))}
71
+ </select>
72
+ );
73
+ }
74
+ <% } %>
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Inline rich-text block (bare skeleton) — fully driven by the merchant's
3
+ * dashboard.
4
+ *
5
+ * The merchant configures rich-text blocks in the Brainerce dashboard
6
+ * under Sell → Content → Rich Text. Use this component anywhere on a page
7
+ * to drop a merchant-editable HTML block (intro copy, banner descriptions,
8
+ * inline announcements that aren't tied to the top-of-page Announcement
9
+ * bar, etc.).
10
+ *
11
+ * Security: HTML is sanitized via `sanitizeHtml` (isomorphic-dompurify)
12
+ * before injecting via dangerouslySetInnerHTML.
13
+ *
14
+ * DESIGN ME — merchant-editable HTML block; fed by
15
+ * `client.content.richText.get(key, locale)` pre-fetched in the route.
16
+ * Style the injected HTML via the wrapper `className`.
17
+ */
18
+ import * as React from 'react';
19
+ import type { Content } from 'brainerce';
20
+ import { sanitizeHtml } from '@/core/lib/sanitize';
21
+
22
+ interface RichTextBlockProps {
23
+ /** Pre-fetched RICH_TEXT row, e.g. via `client.content.richText.get(key, locale)`. */
24
+ block: Content<'RICH_TEXT'> | null;
25
+ /** Optional wrapper className for layout positioning. */
26
+ className?: string;
27
+ }
28
+
29
+ export function RichTextBlock({ block, className }: RichTextBlockProps) {
30
+ if (!block?.data?.html) return null;
31
+ return (
32
+ <div className={className} dangerouslySetInnerHTML={{ __html: sanitizeHtml(block.data.html) }} />
33
+ );
34
+ }
@@ -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 */}
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 */}
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 */}
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. */}
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
+ }