create-brainerce-store 1.78.0 → 1.80.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 (36) hide show
  1. package/dist/index.js +27 -2
  2. package/messages/en.json +12 -3
  3. package/messages/he.json +12 -3
  4. package/package.json +10 -1
  5. package/templates/nextjs/base/.eslintrc.json +2 -0
  6. package/templates/nextjs/base/AGENTS.md.ejs +23 -5
  7. package/templates/nextjs/base/CLAUDE.md.ejs +23 -5
  8. package/templates/nextjs/base/src/app/checkout/page.tsx +19 -2
  9. package/templates/nextjs/base/src/app/order-status/page.tsx +18 -3
  10. package/templates/nextjs/base/src/app/products/[slug]/page.tsx +220 -214
  11. package/templates/nextjs/base/src/components/account/order-history.tsx +11 -4
  12. package/templates/nextjs/base/src/components/account/profile-section.tsx +7 -1
  13. package/templates/nextjs/base/src/components/auth/register-form.tsx +18 -1
  14. package/templates/nextjs/base/src/components/checkout/payment-step.tsx +14 -2
  15. package/templates/nextjs/base/src/components/tracking-bootstrap.tsx +1 -1
  16. package/templates/nextjs/base/src/core/hooks/use-product-page.ts +343 -328
  17. package/templates/nextjs/base/src/core/lib/kit.ts +88 -0
  18. package/templates/nextjs/base/src/ui/cart/gift-card-input.tsx +87 -12
  19. package/templates/nextjs/base/src/ui/layout/newsletter-signup.tsx +59 -12
  20. package/templates/nextjs/base/src/ui/product/frequently-bought-together.tsx +205 -197
  21. package/templates/nextjs/base/src/ui/product/product-card.tsx +230 -221
  22. package/templates/nextjs/base/src/ui/product/product-client-section.tsx +524 -493
  23. package/templates/nextjs/base/src/ui/product/recommendation-section.tsx +117 -108
  24. package/templates/nextjs/base/src/ui/product/stock-badge.tsx +23 -3
  25. package/templates/nextjs/designs/atelier/ui/product/frequently-bought-together.tsx +210 -202
  26. package/templates/nextjs/designs/atelier/ui/product/product-card.tsx +251 -242
  27. package/templates/nextjs/designs/atelier/ui/product/product-client-section.tsx +540 -509
  28. package/templates/nextjs/designs/atelier/ui/product/recommendation-section.tsx +110 -101
  29. package/templates/nextjs/designs/atelier/ui/product/stock-badge.tsx +22 -2
  30. package/templates/nextjs/ui-canvas/cart/gift-card-input.tsx +41 -11
  31. package/templates/nextjs/ui-canvas/layout/newsletter-signup.tsx +50 -8
  32. package/templates/nextjs/ui-canvas/product/frequently-bought-together.tsx +182 -174
  33. package/templates/nextjs/ui-canvas/product/product-card.tsx +174 -165
  34. package/templates/nextjs/ui-canvas/product/product-client-section.tsx +31 -0
  35. package/templates/nextjs/ui-canvas/product/recommendation-section.tsx +114 -105
  36. package/templates/nextjs/ui-canvas/product/stock-badge.tsx +22 -2
@@ -5,9 +5,20 @@ import { cn } from '@/core/lib/utils';
5
5
  import { useTranslations } from '@/core/lib/translations';
6
6
  import { useStoreCapabilities } from '@/core/providers/store-provider';
7
7
  import { resolveLowStockThreshold } from '@/core/lib/capabilities';
8
+ import { kitInventory } from '@/core/lib/kit';
8
9
 
9
10
  interface StockBadgeProps {
10
11
  inventory: InventoryInfo | null | undefined;
12
+ /**
13
+ * KIT stock — pass `product.kitAvailable` whenever the product may be a kit.
14
+ *
15
+ * ⛔ A KIT has NO `inventory` block, so passing `inventory` alone sent every
16
+ * kit down the `!inventory` branch below and printed a red "Out of stock" on
17
+ * every card, category page, search result and product page — while the buy
18
+ * button beside it stayed enabled. `undefined` here means "not a kit";
19
+ * `null` means "unlimited". They are not interchangeable.
20
+ */
21
+ kitAvailable?: number | null;
11
22
  /**
12
23
  * Override the threshold. Leave it unset — the merchant's configured value
13
24
  * comes from the store's capabilities, and a hardcoded number here shows the
@@ -24,14 +35,21 @@ interface StockBadgeProps {
24
35
  *
25
36
  * 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.
26
37
  */
27
- export function StockBadge({ inventory, lowStockThreshold, className }: StockBadgeProps) {
38
+ export function StockBadge({
39
+ inventory,
40
+ kitAvailable,
41
+ lowStockThreshold,
42
+ className,
43
+ }: StockBadgeProps) {
28
44
  const t = useTranslations('productDetail');
29
45
  // Merchant-configured, from the channel's capabilities. Falls back to the
30
46
  // platform default while the fetch is in flight or if it failed, and resolves
31
47
  // to 0 (nothing is ever low) when the merchant turned low-stock warnings off.
32
48
  const { capabilities } = useStoreCapabilities();
49
+ // A kit reports from `kitAvailable`; everything else from its inventory row.
50
+ const stock = kitAvailable !== undefined ? kitInventory(kitAvailable) : inventory;
33
51
  const label = getStockLabel(
34
- inventory,
52
+ stock,
35
53
  lowStockThreshold ?? resolveLowStockThreshold(capabilities),
36
54
  t
37
55
  );
@@ -44,6 +62,8 @@ function getStockLabel(
44
62
  lowStockThreshold: number,
45
63
  t: (key: string) => string
46
64
  ): string {
65
+ // No stock signal at all. A KIT reaches here only when the caller forgot to
66
+ // pass `kitAvailable` — see the prop comment above.
47
67
  if (!inventory) return t('outOfStock');
48
68
 
49
69
  const { trackingMode, inStock, available } = inventory;