create-brainerce-store 1.73.0 → 1.74.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 (77) hide show
  1. package/dist/index.js +35 -2
  2. package/messages/en.json +27 -1
  3. package/messages/he.json +27 -1
  4. package/package.json +1 -1
  5. package/templates/nextjs/base/AGENTS.md.ejs +63 -16
  6. package/templates/nextjs/base/AI-GUIDE.md +17 -4
  7. package/templates/nextjs/base/CLAUDE.md.ejs +67 -20
  8. package/templates/nextjs/base/src/app/account/page.tsx +168 -122
  9. package/templates/nextjs/base/src/app/category/[slug]/page.tsx +10 -1
  10. package/templates/nextjs/base/src/app/checkout/page.tsx +145 -40
  11. package/templates/nextjs/base/src/app/layout.tsx.ejs +48 -4
  12. package/templates/nextjs/base/src/app/order-confirmation/page.tsx +98 -3
  13. package/templates/nextjs/base/src/app/products/[slug]/page.tsx +14 -2
  14. package/templates/nextjs/base/src/components/account/loyalty-panel.tsx +226 -0
  15. package/templates/nextjs/base/src/components/account/order-history.tsx +58 -7
  16. package/templates/nextjs/base/src/components/account/saved-payment-methods.tsx +104 -0
  17. package/templates/nextjs/base/src/components/checkout/checkout-form.tsx +618 -612
  18. package/templates/nextjs/base/src/components/checkout/custom-fields-step.tsx +354 -306
  19. package/templates/nextjs/base/src/components/checkout/tax-display.tsx +141 -74
  20. package/templates/nextjs/base/src/core/hooks/use-cart-page.ts +97 -6
  21. package/templates/nextjs/base/src/core/hooks/use-home-data.ts +63 -51
  22. package/templates/nextjs/base/src/core/hooks/use-product-listing.ts +379 -295
  23. package/templates/nextjs/base/src/core/hooks/use-product-page.ts +33 -1
  24. package/templates/nextjs/base/src/core/lib/capabilities.ts +65 -0
  25. package/templates/nextjs/base/src/core/lib/display-price.ts +139 -0
  26. package/templates/nextjs/base/src/core/lib/region.server.ts +112 -0
  27. package/templates/nextjs/base/src/core/lib/region.ts +112 -0
  28. package/templates/nextjs/base/src/core/lib/store-info.ts +19 -0
  29. package/templates/nextjs/base/src/core/providers/store-provider.tsx.ejs +423 -243
  30. package/templates/nextjs/base/src/ui/cart/cart-item.tsx +10 -0
  31. package/templates/nextjs/base/src/ui/cart/cart-summary.tsx +109 -110
  32. package/templates/nextjs/base/src/ui/cart/cart-view.tsx +45 -2
  33. package/templates/nextjs/base/src/ui/cart/gift-card-input.tsx +191 -0
  34. package/templates/nextjs/base/src/ui/cart/tax-estimate-line.tsx +108 -0
  35. package/templates/nextjs/base/src/ui/home/home-client.tsx +27 -29
  36. package/templates/nextjs/base/src/ui/layout/header-search.tsx +249 -0
  37. package/templates/nextjs/base/src/ui/layout/region-switcher.tsx +59 -0
  38. package/templates/nextjs/base/src/ui/layout/site-header.tsx.ejs +171 -152
  39. package/templates/nextjs/base/src/ui/product/frequently-bought-together.tsx +197 -191
  40. package/templates/nextjs/base/src/ui/product/product-card.tsx +25 -52
  41. package/templates/nextjs/base/src/ui/product/product-client-section.tsx +12 -3
  42. package/templates/nextjs/base/src/ui/product/product-listing.tsx +460 -446
  43. package/templates/nextjs/base/src/ui/product/recommendation-section.tsx +108 -102
  44. package/templates/nextjs/base/src/ui/product/stock-badge.tsx +15 -3
  45. package/templates/nextjs/designs/atelier/app-overlay/layout.tsx.ejs +48 -4
  46. package/templates/nextjs/designs/atelier/messages-patch/en.json +21 -25
  47. package/templates/nextjs/designs/atelier/messages-patch/he.json +21 -25
  48. package/templates/nextjs/designs/atelier/ui/cart/cart-item.tsx +10 -0
  49. package/templates/nextjs/designs/atelier/ui/cart/cart-summary.tsx +106 -107
  50. package/templates/nextjs/designs/atelier/ui/cart/cart-view.tsx +56 -11
  51. package/templates/nextjs/designs/atelier/ui/cart/tax-estimate-line.tsx +108 -0
  52. package/templates/nextjs/designs/atelier/ui/home/benefits-band.tsx +10 -1
  53. package/templates/nextjs/designs/atelier/ui/home/hero-section.tsx +178 -174
  54. package/templates/nextjs/designs/atelier/ui/home/home-client.tsx +4 -6
  55. package/templates/nextjs/designs/atelier/ui/home/newsletter-section.tsx +150 -78
  56. package/templates/nextjs/designs/atelier/ui/home/testimonials-band.tsx +79 -46
  57. package/templates/nextjs/designs/atelier/ui/layout/header-search.tsx +264 -0
  58. package/templates/nextjs/designs/atelier/ui/layout/region-switcher.tsx +44 -0
  59. package/templates/nextjs/designs/atelier/ui/layout/site-header.tsx.ejs +5 -0
  60. package/templates/nextjs/designs/atelier/ui/product/frequently-bought-together.tsx +202 -196
  61. package/templates/nextjs/designs/atelier/ui/product/product-card.tsx +27 -52
  62. package/templates/nextjs/designs/atelier/ui/product/product-client-section.tsx +12 -3
  63. package/templates/nextjs/designs/atelier/ui/product/product-listing.tsx +332 -260
  64. package/templates/nextjs/designs/atelier/ui/product/recommendation-section.tsx +101 -95
  65. package/templates/nextjs/designs/atelier/ui/product/stock-badge.tsx +17 -2
  66. package/templates/nextjs/designs/atelier/ui/shared/icons.tsx +9 -0
  67. package/templates/nextjs/ui-canvas/cart/cart-summary.tsx +98 -99
  68. package/templates/nextjs/ui-canvas/cart/gift-card-input.tsx +142 -0
  69. package/templates/nextjs/ui-canvas/cart/tax-estimate-line.tsx +104 -0
  70. package/templates/nextjs/ui-canvas/home/home-client.tsx +24 -26
  71. package/templates/nextjs/ui-canvas/layout/region-switcher.tsx +51 -0
  72. package/templates/nextjs/ui-canvas/layout/site-header.tsx.ejs +3 -0
  73. package/templates/nextjs/ui-canvas/product/frequently-bought-together.tsx +174 -168
  74. package/templates/nextjs/ui-canvas/product/product-card.tsx +9 -51
  75. package/templates/nextjs/ui-canvas/product/product-client-section.tsx +5 -3
  76. package/templates/nextjs/ui-canvas/product/recommendation-section.tsx +105 -99
  77. package/templates/nextjs/ui-canvas/product/stock-badge.tsx +17 -2
@@ -1,152 +1,171 @@
1
- /**
2
- * Merchant-controlled site header.
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 menu that works without client-side JS. Everything
9
- * is generic — do NOT hardcode nav labels or logo paths here; the merchant
10
- * edits them in the dashboard and the change propagates within ~5 minutes.
11
- *
12
- * If `header` is null (404 from the API, or the merchant deleted the row),
13
- * we render a minimal static fallback with just the brand label and cart link
14
- * so the layout never collapses. New stores ship with a seeded HEADER row
15
- * from the backend (StoresService.seedDefaultContent), so the populated
16
- * branch is the common case.
17
- */
18
- import * as React from 'react';
19
- import { Menu, ShoppingCart } from 'lucide-react';
20
- import type { Content } from 'brainerce';
21
- import { Button } from '@/components/ui/button';
22
- // Locale-aware Link (client component — fine to render from this server
23
- // component). Used for the static internal links (brand → /, cart) so the
24
- // current locale prefix is preserved; merchant-configured nav items keep
25
- // plain <a> since their URLs are arbitrary (may be external).
26
- import { Link } from '@/core/lib/navigation';
27
- import { HeaderAccount } from './header-account';
28
- <% if (i18nEnabled) { %>
29
- import { LanguageSwitcher } from '@/ui/layout/language-switcher';
30
- <% } %>
31
-
32
- interface SiteHeaderProps {
33
- /** Pre-fetched header payload (server-side). `null` triggers static fallback. */
34
- header: Content<'HEADER'> | null;
35
- /** Fallback brand label when the merchant hasn't uploaded a logo yet. */
36
- storeName?: string;
37
- }
38
-
39
- export function SiteHeader({ header, storeName }: SiteHeaderProps) {
40
- const data = header?.data;
41
- const logo = data?.logo;
42
- const navItems = data?.navItems ?? [];
43
- const cta = data?.cta;
44
- const brandLabel = logo?.alt || storeName || 'Store';
45
-
46
- // Static fallback — runs when the Content API returned null (no HEADER row
47
- // for this store yet, or fetch failed). Keep the brand + cart so the page
48
- // always has a clickable home link and entry to checkout, but no nav since
49
- // the merchant hasn't defined any items.
50
- if (!header) {
51
- return (
52
- <header className="border-border bg-background/95 supports-[backdrop-filter]:bg-background/70 sticky top-0 z-40 border-b backdrop-blur">
53
- <div className="mx-auto flex h-16 max-w-7xl items-center justify-between gap-4 px-4 sm:px-6 lg:px-8">
54
- <Link href="/" className="text-lg font-semibold tracking-tight" aria-label={brandLabel}>
55
- {brandLabel}
56
- </Link>
57
- <div className="flex items-center gap-2">
58
- <% if (i18nEnabled) { %>
59
- <LanguageSwitcher />
60
- <% } %>
61
- <HeaderAccount />
62
- <Link
63
- href="/cart"
64
- aria-label="Cart"
65
- className="text-foreground/80 hover:text-foreground hover:bg-muted/60 inline-flex h-9 w-9 items-center justify-center rounded-md transition-colors"
66
- >
67
- <ShoppingCart className="h-5 w-5" aria-hidden="true" />
68
- </Link>
69
- </div>
70
- </div>
71
- </header>
72
- );
73
- }
74
-
75
- return (
76
- <header className="border-border bg-background/95 supports-[backdrop-filter]:bg-background/70 sticky top-0 z-40 border-b backdrop-blur">
77
- <div className="mx-auto flex h-16 max-w-7xl items-center justify-between gap-4 px-4 sm:px-6 lg:px-8">
78
- <Link
79
- href="/"
80
- className="flex items-center gap-2 font-semibold tracking-tight"
81
- aria-label={brandLabel}
82
- >
83
- {logo ? (
84
- // eslint-disable-next-line @next/next/no-img-element -- merchant-supplied URL, dynamic optimization handled by CDN
85
- <img src={logo.src} alt={logo.alt} className="h-8 w-auto" />
86
- ) : (
87
- <span className="text-lg">{brandLabel}</span>
88
- )}
89
- </Link>
90
-
91
- {navItems.length > 0 ? (
92
- <nav className="hidden items-center gap-8 md:flex">
93
- {navItems.map((item, idx) => (
94
- <a
95
- key={`${item.url}-${idx}`}
96
- href={item.url}
97
- className="text-foreground/80 hover:text-foreground text-sm font-medium transition-colors"
98
- >
99
- {item.label}
100
- </a>
101
- ))}
102
- </nav>
103
- ) : null}
104
-
105
- <div className="flex items-center gap-2">
106
- {cta ? (
107
- <Button asChild className="hidden sm:inline-flex">
108
- <a href={cta.url}>{cta.label}</a>
109
- </Button>
110
- ) : null}
111
-
112
- <% if (i18nEnabled) { %>
113
- <LanguageSwitcher />
114
- <% } %>
115
-
116
- <HeaderAccount />
117
-
118
- <Link
119
- href="/cart"
120
- aria-label="Cart"
121
- className="text-foreground/80 hover:text-foreground hover:bg-muted/60 inline-flex h-9 w-9 items-center justify-center rounded-md transition-colors"
122
- >
123
- <ShoppingCart className="h-5 w-5" aria-hidden="true" />
124
- </Link>
125
-
126
- {navItems.length > 0 ? (
127
- <details className="group relative md:hidden">
128
- <summary className="text-foreground/80 hover:text-foreground hover:bg-muted/60 inline-flex h-9 w-9 cursor-pointer list-none items-center justify-center rounded-md transition-colors [&::-webkit-details-marker]:hidden">
129
- <Menu className="h-5 w-5" aria-hidden="true" />
130
- <span className="sr-only">Menu</span>
131
- </summary>
132
- <nav className="border-border bg-background absolute end-0 top-full z-50 mt-2 w-56 overflow-hidden rounded-lg border shadow-lg">
133
- <ul className="py-1">
134
- {navItems.map((item, idx) => (
135
- <li key={`m-${item.url}-${idx}`}>
136
- <a
137
- href={item.url}
138
- className="text-foreground/80 hover:text-foreground hover:bg-muted block px-4 py-2 text-sm transition-colors"
139
- >
140
- {item.label}
141
- </a>
142
- </li>
143
- ))}
144
- </ul>
145
- </nav>
146
- </details>
147
- ) : null}
148
- </div>
149
- </div>
150
- </header>
151
- );
152
- }
1
+ /**
2
+ * Merchant-controlled site header.
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 menu that works without client-side JS. Everything
9
+ * is generic — do NOT hardcode nav labels or logo paths here; the merchant
10
+ * edits them in the dashboard and the change propagates within ~5 minutes.
11
+ *
12
+ * If `header` is null (404 from the API, or the merchant deleted the row),
13
+ * we render a minimal static fallback with just the brand label and cart link
14
+ * so the layout never collapses. New stores ship with a seeded HEADER row
15
+ * from the backend (StoresService.seedDefaultContent), so the populated
16
+ * branch is the common case.
17
+ */
18
+ import * as React from 'react';
19
+ import { Menu, ShoppingCart } from 'lucide-react';
20
+ import type { Content } from 'brainerce';
21
+ import { Button } from '@/components/ui/button';
22
+ // Locale-aware Link (client component — fine to render from this server
23
+ // component). Used for the static internal links (brand → /, cart) so the
24
+ // current locale prefix is preserved; merchant-configured nav items keep
25
+ // plain <a> since their URLs are arbitrary (may be external).
26
+ import { Link } from '@/core/lib/navigation';
27
+ import { HeaderAccount } from './header-account';
28
+ import { HeaderSearch } from './header-search';
29
+ <% if (i18nEnabled) { %>
30
+ import { LanguageSwitcher } from '@/ui/layout/language-switcher';
31
+ <% } %>
32
+ import { RegionSwitcher } from '@/ui/layout/region-switcher';
33
+
34
+ interface SiteHeaderProps {
35
+ /** Pre-fetched header payload (server-side). `null` triggers static fallback. */
36
+ header: Content<'HEADER'> | null;
37
+ /** Fallback brand label when the merchant hasn't uploaded a logo yet. */
38
+ storeName?: string;
39
+ }
40
+
41
+ export function SiteHeader({ header, storeName }: SiteHeaderProps) {
42
+ const data = header?.data;
43
+ const logo = data?.logo;
44
+ const navItems = data?.navItems ?? [];
45
+ const cta = data?.cta;
46
+ const brandLabel = logo?.alt || storeName || 'Store';
47
+
48
+ // Static fallback — runs when the Content API returned null (no HEADER row
49
+ // for this store yet, or fetch failed). Keep the brand + cart so the page
50
+ // always has a clickable home link and entry to checkout, but no nav since
51
+ // the merchant hasn't defined any items.
52
+ if (!header) {
53
+ return (
54
+ <header className="border-border bg-background/95 supports-[backdrop-filter]:bg-background/70 sticky top-0 z-40 border-b backdrop-blur">
55
+ <div className="mx-auto flex h-16 max-w-7xl items-center justify-between gap-4 px-4 sm:px-6 lg:px-8">
56
+ <Link href="/" className="text-lg font-semibold tracking-tight" aria-label={brandLabel}>
57
+ {brandLabel}
58
+ </Link>
59
+ {/* Search lives in the fallback branch too — a store whose merchant
60
+ has not seeded a HEADER row still needs to be searchable. */}
61
+ <HeaderSearch className="hidden max-w-xs flex-1 sm:block" />
62
+ <div className="flex items-center gap-2">
63
+ <% if (i18nEnabled) { %>
64
+ <LanguageSwitcher />
65
+ <% } %>
66
+ <RegionSwitcher />
67
+ <HeaderAccount />
68
+ <Link
69
+ href="/cart"
70
+ aria-label="Cart"
71
+ className="text-foreground/80 hover:text-foreground hover:bg-muted/60 inline-flex h-9 w-9 items-center justify-center rounded-md transition-colors"
72
+ >
73
+ <ShoppingCart className="h-5 w-5" aria-hidden="true" />
74
+ </Link>
75
+ </div>
76
+ </div>
77
+ {/* Narrow screens get the field on its own row rather than a cramped
78
+ icon: the bar above is already three controls wide. */}
79
+ <div className="mx-auto max-w-7xl px-4 pb-3 sm:hidden">
80
+ <HeaderSearch />
81
+ </div>
82
+ </header>
83
+ );
84
+ }
85
+
86
+ return (
87
+ <header className="border-border bg-background/95 supports-[backdrop-filter]:bg-background/70 sticky top-0 z-40 border-b backdrop-blur">
88
+ <div className="mx-auto flex h-16 max-w-7xl items-center justify-between gap-4 px-4 sm:px-6 lg:px-8">
89
+ <Link
90
+ href="/"
91
+ className="flex items-center gap-2 font-semibold tracking-tight"
92
+ aria-label={brandLabel}
93
+ >
94
+ {logo ? (
95
+ // eslint-disable-next-line @next/next/no-img-element -- merchant-supplied URL, dynamic optimization handled by CDN
96
+ <img src={logo.src} alt={logo.alt} className="h-8 w-auto" />
97
+ ) : (
98
+ <span className="text-lg">{brandLabel}</span>
99
+ )}
100
+ </Link>
101
+
102
+ {navItems.length > 0 ? (
103
+ <nav className="hidden items-center gap-8 md:flex">
104
+ {navItems.map((item, idx) => (
105
+ <a
106
+ key={`${item.url}-${idx}`}
107
+ href={item.url}
108
+ className="text-foreground/80 hover:text-foreground text-sm font-medium transition-colors"
109
+ >
110
+ {item.label}
111
+ </a>
112
+ ))}
113
+ </nav>
114
+ ) : null}
115
+
116
+ <HeaderSearch className="hidden max-w-xs flex-1 sm:block" />
117
+
118
+ <div className="flex items-center gap-2">
119
+ {cta ? (
120
+ <Button asChild className="hidden sm:inline-flex">
121
+ <a href={cta.url}>{cta.label}</a>
122
+ </Button>
123
+ ) : null}
124
+
125
+ <% if (i18nEnabled) { %>
126
+ <LanguageSwitcher />
127
+ <% } %>
128
+ <RegionSwitcher />
129
+
130
+ <HeaderAccount />
131
+
132
+ <Link
133
+ href="/cart"
134
+ aria-label="Cart"
135
+ className="text-foreground/80 hover:text-foreground hover:bg-muted/60 inline-flex h-9 w-9 items-center justify-center rounded-md transition-colors"
136
+ >
137
+ <ShoppingCart className="h-5 w-5" aria-hidden="true" />
138
+ </Link>
139
+
140
+ {navItems.length > 0 ? (
141
+ <details className="group relative md:hidden">
142
+ <summary className="text-foreground/80 hover:text-foreground hover:bg-muted/60 inline-flex h-9 w-9 cursor-pointer list-none items-center justify-center rounded-md transition-colors [&::-webkit-details-marker]:hidden">
143
+ <Menu className="h-5 w-5" aria-hidden="true" />
144
+ <span className="sr-only">Menu</span>
145
+ </summary>
146
+ <nav className="border-border bg-background absolute end-0 top-full z-50 mt-2 w-56 overflow-hidden rounded-lg border shadow-lg">
147
+ <ul className="py-1">
148
+ {navItems.map((item, idx) => (
149
+ <li key={`m-${item.url}-${idx}`}>
150
+ <a
151
+ href={item.url}
152
+ className="text-foreground/80 hover:text-foreground hover:bg-muted block px-4 py-2 text-sm transition-colors"
153
+ >
154
+ {item.label}
155
+ </a>
156
+ </li>
157
+ ))}
158
+ </ul>
159
+ </nav>
160
+ </details>
161
+ ) : null}
162
+ </div>
163
+ </div>
164
+ {/* Narrow screens get the field on its own row rather than a cramped
165
+ icon: the bar above is already three controls wide. */}
166
+ <div className="mx-auto max-w-7xl px-4 pb-3 sm:hidden">
167
+ <HeaderSearch />
168
+ </div>
169
+ </header>
170
+ );
171
+ }