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.
- package/dist/index.js +27 -2
- package/messages/en.json +12 -3
- package/messages/he.json +12 -3
- package/package.json +10 -1
- package/templates/nextjs/base/.eslintrc.json +2 -0
- package/templates/nextjs/base/AGENTS.md.ejs +23 -5
- package/templates/nextjs/base/CLAUDE.md.ejs +23 -5
- package/templates/nextjs/base/src/app/checkout/page.tsx +19 -2
- package/templates/nextjs/base/src/app/order-status/page.tsx +18 -3
- package/templates/nextjs/base/src/app/products/[slug]/page.tsx +220 -214
- package/templates/nextjs/base/src/components/account/order-history.tsx +11 -4
- package/templates/nextjs/base/src/components/account/profile-section.tsx +7 -1
- package/templates/nextjs/base/src/components/auth/register-form.tsx +18 -1
- package/templates/nextjs/base/src/components/checkout/payment-step.tsx +14 -2
- package/templates/nextjs/base/src/components/tracking-bootstrap.tsx +1 -1
- package/templates/nextjs/base/src/core/hooks/use-product-page.ts +343 -328
- package/templates/nextjs/base/src/core/lib/kit.ts +88 -0
- package/templates/nextjs/base/src/ui/cart/gift-card-input.tsx +87 -12
- package/templates/nextjs/base/src/ui/layout/newsletter-signup.tsx +59 -12
- package/templates/nextjs/base/src/ui/product/frequently-bought-together.tsx +205 -197
- package/templates/nextjs/base/src/ui/product/product-card.tsx +230 -221
- package/templates/nextjs/base/src/ui/product/product-client-section.tsx +524 -493
- package/templates/nextjs/base/src/ui/product/recommendation-section.tsx +117 -108
- package/templates/nextjs/base/src/ui/product/stock-badge.tsx +23 -3
- package/templates/nextjs/designs/atelier/ui/product/frequently-bought-together.tsx +210 -202
- package/templates/nextjs/designs/atelier/ui/product/product-card.tsx +251 -242
- package/templates/nextjs/designs/atelier/ui/product/product-client-section.tsx +540 -509
- package/templates/nextjs/designs/atelier/ui/product/recommendation-section.tsx +110 -101
- package/templates/nextjs/designs/atelier/ui/product/stock-badge.tsx +22 -2
- package/templates/nextjs/ui-canvas/cart/gift-card-input.tsx +41 -11
- package/templates/nextjs/ui-canvas/layout/newsletter-signup.tsx +50 -8
- package/templates/nextjs/ui-canvas/product/frequently-bought-together.tsx +182 -174
- package/templates/nextjs/ui-canvas/product/product-card.tsx +174 -165
- package/templates/nextjs/ui-canvas/product/product-client-section.tsx +31 -0
- package/templates/nextjs/ui-canvas/product/recommendation-section.tsx +114 -105
- 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({
|
|
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
|
-
|
|
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;
|