create-brainerce-store 1.71.0 → 1.73.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/README.md +31 -10
- package/dist/index.js +179 -107
- package/messages/en.json +14 -1
- package/messages/he.json +14 -1
- package/package.json +1 -1
- package/templates/nextjs/base/TRANSLATIONS.md +207 -200
- package/templates/nextjs/base/src/app/checkout/page.tsx +1074 -1018
- package/templates/nextjs/base/src/app/order-confirmation/page.tsx +21 -2
- package/templates/nextjs/base/src/components/account/order-history.tsx +371 -385
- package/templates/nextjs/base/src/components/account/order-status-timeline.tsx +85 -66
- package/templates/nextjs/base/src/core/hooks/use-cart-page.ts +127 -58
- package/templates/nextjs/base/src/core/lib/auth.ts +32 -39
- package/templates/nextjs/base/src/core/lib/brainerce.ts.ejs +5 -16
- package/templates/nextjs/base/src/core/providers/store-provider.tsx.ejs +3 -6
- package/templates/nextjs/base/src/ui/cart/cart-item.tsx +164 -146
- package/templates/nextjs/base/src/ui/cart/cart-view.tsx +176 -140
- package/templates/nextjs/base/src/ui/cart/reservation-countdown.tsx +137 -95
- package/templates/nextjs/base/src/ui/product/review-form.tsx +33 -11
- package/templates/nextjs/designs/atelier/ui/cart/cart-drawer.tsx +177 -163
- package/templates/nextjs/designs/atelier/ui/cart/cart-item.tsx +158 -140
- package/templates/nextjs/designs/atelier/ui/cart/cart-view.tsx +184 -147
- package/templates/nextjs/designs/atelier/ui/cart/reservation-countdown.tsx +131 -89
- package/templates/nextjs/designs/atelier/ui/product/review-form.tsx +30 -10
- package/templates/nextjs/ui-canvas/cart/cart-item.tsx +137 -123
- package/templates/nextjs/ui-canvas/cart/cart-view.tsx +140 -106
- package/templates/nextjs/ui-canvas/cart/reservation-countdown.tsx +124 -81
- package/templates/nextjs/ui-canvas/product/review-form.tsx +9 -1
|
@@ -1,146 +1,164 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { Image as ImageIcon } from 'lucide-react';
|
|
5
|
-
import { CdnImage as Image } from '@/ui/shared/cdn-image';
|
|
6
|
-
import type { CartItem as CartItemType } from 'brainerce';
|
|
7
|
-
import { getCartItemImage, formatPrice } from 'brainerce';
|
|
8
|
-
import { getClient } from '@/core/lib/brainerce';
|
|
9
|
-
import { useTranslations } from '@/core/lib/translations';
|
|
10
|
-
import { useCurrency } from '@/core/lib/use-currency';
|
|
11
|
-
import { LoadingSpinner } from '@/ui/shared/loading-spinner';
|
|
12
|
-
import { cn } from '@/core/lib/utils';
|
|
13
|
-
|
|
14
|
-
interface CartItemProps {
|
|
15
|
-
item: CartItemType;
|
|
16
|
-
onUpdate: () => void;
|
|
17
|
-
className?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function CartItem({ item, onUpdate, className }: CartItemProps) {
|
|
21
|
-
const t = useTranslations('common');
|
|
22
|
-
const td = useTranslations('productDetail');
|
|
23
|
-
const currency = useCurrency();
|
|
24
|
-
const [updating, setUpdating] = useState(false);
|
|
25
|
-
const [removing, setRemoving] = useState(false);
|
|
26
|
-
|
|
27
|
-
const productName = item.product.name;
|
|
28
|
-
const imageUrl = getCartItemImage(item);
|
|
29
|
-
const variantName = item.variant?.name;
|
|
30
|
-
const unitPrice = parseFloat(item.unitPrice);
|
|
31
|
-
const lineTotal = unitPrice * item.quantity;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
{/*
|
|
83
|
-
<div className="
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
disabled
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { Image as ImageIcon } from 'lucide-react';
|
|
5
|
+
import { CdnImage as Image } from '@/ui/shared/cdn-image';
|
|
6
|
+
import type { CartItem as CartItemType } from 'brainerce';
|
|
7
|
+
import { getCartItemImage, formatPrice } from 'brainerce';
|
|
8
|
+
import { getClient } from '@/core/lib/brainerce';
|
|
9
|
+
import { useTranslations } from '@/core/lib/translations';
|
|
10
|
+
import { useCurrency } from '@/core/lib/use-currency';
|
|
11
|
+
import { LoadingSpinner } from '@/ui/shared/loading-spinner';
|
|
12
|
+
import { cn } from '@/core/lib/utils';
|
|
13
|
+
|
|
14
|
+
interface CartItemProps {
|
|
15
|
+
item: CartItemType;
|
|
16
|
+
onUpdate: () => void;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function CartItem({ item, onUpdate, className }: CartItemProps) {
|
|
21
|
+
const t = useTranslations('common');
|
|
22
|
+
const td = useTranslations('productDetail');
|
|
23
|
+
const currency = useCurrency();
|
|
24
|
+
const [updating, setUpdating] = useState(false);
|
|
25
|
+
const [removing, setRemoving] = useState(false);
|
|
26
|
+
|
|
27
|
+
const productName = item.product.name;
|
|
28
|
+
const imageUrl = getCartItemImage(item);
|
|
29
|
+
const variantName = item.variant?.name;
|
|
30
|
+
const unitPrice = parseFloat(item.unitPrice);
|
|
31
|
+
const lineTotal = unitPrice * item.quantity;
|
|
32
|
+
|
|
33
|
+
// The server decides purchasability, per line. `isAvailable === false` means
|
|
34
|
+
// this line blocks checkout until it is removed, whether the stock ran out
|
|
35
|
+
// (a released reservation is the common cause) or the product/variant was
|
|
36
|
+
// withdrawn from sale. `unavailableReason` separates the two for the label.
|
|
37
|
+
const isUnavailable = item.isAvailable === false;
|
|
38
|
+
const unavailableLabel = isUnavailable
|
|
39
|
+
? item.unavailableReason === 'OUT_OF_STOCK'
|
|
40
|
+
? td('outOfStock')
|
|
41
|
+
: td('unavailable')
|
|
42
|
+
: null;
|
|
43
|
+
|
|
44
|
+
async function handleQuantityChange(newQuantity: number) {
|
|
45
|
+
if (newQuantity < 1 || updating) return;
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
setUpdating(true);
|
|
49
|
+
const client = getClient();
|
|
50
|
+
await client.smartUpdateCartItem(item.productId, newQuantity, item.variantId || undefined);
|
|
51
|
+
onUpdate();
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.error('Failed to update quantity:', err);
|
|
54
|
+
} finally {
|
|
55
|
+
setUpdating(false);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function handleRemove() {
|
|
60
|
+
if (removing) return;
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
setRemoving(true);
|
|
64
|
+
const client = getClient();
|
|
65
|
+
await client.smartRemoveFromCart(item.productId, item.variantId || undefined);
|
|
66
|
+
onUpdate();
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.error('Failed to remove item:', err);
|
|
69
|
+
} finally {
|
|
70
|
+
setRemoving(false);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div
|
|
76
|
+
className={cn(
|
|
77
|
+
'border-border flex gap-4 border-b py-4 last:border-0',
|
|
78
|
+
(updating || removing) && 'opacity-60',
|
|
79
|
+
className
|
|
80
|
+
)}
|
|
81
|
+
>
|
|
82
|
+
{/* Image */}
|
|
83
|
+
<div className="bg-muted relative h-20 w-20 flex-shrink-0 overflow-hidden rounded">
|
|
84
|
+
{imageUrl ? (
|
|
85
|
+
<Image src={imageUrl} alt={productName} fill sizes="80px" className="object-cover" />
|
|
86
|
+
) : (
|
|
87
|
+
<div className="text-muted-foreground absolute inset-0 flex items-center justify-center">
|
|
88
|
+
<ImageIcon className="h-8 w-8" strokeWidth={1.5} aria-hidden="true" />
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
{/* Details */}
|
|
94
|
+
<div className="min-w-0 flex-1">
|
|
95
|
+
<h3 className="text-foreground truncate text-sm font-medium">{productName}</h3>
|
|
96
|
+
|
|
97
|
+
{/* Availability badge. This line blocks checkout while it shows. */}
|
|
98
|
+
{unavailableLabel && (
|
|
99
|
+
<span className="bg-destructive/10 text-destructive mt-1 inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium">
|
|
100
|
+
{unavailableLabel}
|
|
101
|
+
</span>
|
|
102
|
+
)}
|
|
103
|
+
|
|
104
|
+
{/* Variant name */}
|
|
105
|
+
{variantName && <p className="text-muted-foreground mt-1 text-xs">{variantName}</p>}
|
|
106
|
+
|
|
107
|
+
{/* Unit price */}
|
|
108
|
+
<p className="text-muted-foreground mt-1 text-sm">
|
|
109
|
+
{formatPrice(unitPrice, { currency }) as string}
|
|
110
|
+
</p>
|
|
111
|
+
|
|
112
|
+
{/* Quantity controls */}
|
|
113
|
+
<div className="mt-2 flex items-center gap-3">
|
|
114
|
+
<div className="border-border flex items-center rounded border">
|
|
115
|
+
<button
|
|
116
|
+
type="button"
|
|
117
|
+
onClick={() => handleQuantityChange(item.quantity - 1)}
|
|
118
|
+
disabled={updating || item.quantity <= 1}
|
|
119
|
+
className="text-foreground hover:bg-muted px-2 py-1 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40"
|
|
120
|
+
aria-label={td('decreaseQuantity')}
|
|
121
|
+
>
|
|
122
|
+
-
|
|
123
|
+
</button>
|
|
124
|
+
<span className="text-foreground min-w-[2.5rem] px-3 py-1 text-center text-sm font-medium">
|
|
125
|
+
{updating ? (
|
|
126
|
+
<LoadingSpinner
|
|
127
|
+
size="sm"
|
|
128
|
+
className="border-muted-foreground/30 border-t-foreground mx-auto"
|
|
129
|
+
/>
|
|
130
|
+
) : (
|
|
131
|
+
item.quantity
|
|
132
|
+
)}
|
|
133
|
+
</span>
|
|
134
|
+
<button
|
|
135
|
+
type="button"
|
|
136
|
+
onClick={() => handleQuantityChange(item.quantity + 1)}
|
|
137
|
+
disabled={updating || isUnavailable}
|
|
138
|
+
className="text-foreground hover:bg-muted px-2 py-1 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40"
|
|
139
|
+
aria-label={td('increaseQuantity')}
|
|
140
|
+
>
|
|
141
|
+
+
|
|
142
|
+
</button>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<button
|
|
146
|
+
type="button"
|
|
147
|
+
onClick={handleRemove}
|
|
148
|
+
disabled={removing}
|
|
149
|
+
className="text-destructive hover:text-destructive/80 text-xs transition-colors disabled:opacity-40"
|
|
150
|
+
>
|
|
151
|
+
{removing ? t('removing') : t('remove')}
|
|
152
|
+
</button>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
{/* Line total */}
|
|
157
|
+
<div className="flex-shrink-0 text-end">
|
|
158
|
+
<span className="text-foreground text-sm font-medium">
|
|
159
|
+
{formatPrice(lineTotal, { currency }) as string}
|
|
160
|
+
</span>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
@@ -1,140 +1,176 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { ShoppingBag } from 'lucide-react';
|
|
4
|
-
import { Link } from '@/core/lib/navigation';
|
|
5
|
-
import { useCartPage } from '@/core/hooks/use-cart-page';
|
|
6
|
-
import { CartItem } from '@/ui/cart/cart-item';
|
|
7
|
-
import { CartUpgradeBanner } from '@/ui/cart/cart-upgrade-banner';
|
|
8
|
-
import { CartBundleOfferCard } from '@/ui/cart/cart-bundle-offer';
|
|
9
|
-
import { CartSummary } from '@/ui/cart/cart-summary';
|
|
10
|
-
import { CouponInput } from '@/ui/cart/coupon-input';
|
|
11
|
-
import { CartNudges } from '@/ui/cart/cart-nudges';
|
|
12
|
-
import { FreeShippingBar } from '@/ui/cart/free-shipping-bar';
|
|
13
|
-
import { ReservationCountdown } from '@/ui/cart/reservation-countdown';
|
|
14
|
-
import { CartRecommendationSection } from '@/ui/product/recommendation-section';
|
|
15
|
-
import { LoadingSpinner } from '@/ui/shared/loading-spinner';
|
|
16
|
-
import { Button } from '@/components/ui/button';
|
|
17
|
-
import { Card } from '@/components/ui/card';
|
|
18
|
-
import { Separator } from '@/components/ui/separator';
|
|
19
|
-
import { useTranslations } from '@/core/lib/translations';
|
|
20
|
-
|
|
21
|
-
export function CartView() {
|
|
22
|
-
const t = useTranslations('cart');
|
|
23
|
-
const tc = useTranslations('common');
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
{
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
</
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ShoppingBag } from 'lucide-react';
|
|
4
|
+
import { Link } from '@/core/lib/navigation';
|
|
5
|
+
import { useCartPage } from '@/core/hooks/use-cart-page';
|
|
6
|
+
import { CartItem } from '@/ui/cart/cart-item';
|
|
7
|
+
import { CartUpgradeBanner } from '@/ui/cart/cart-upgrade-banner';
|
|
8
|
+
import { CartBundleOfferCard } from '@/ui/cart/cart-bundle-offer';
|
|
9
|
+
import { CartSummary } from '@/ui/cart/cart-summary';
|
|
10
|
+
import { CouponInput } from '@/ui/cart/coupon-input';
|
|
11
|
+
import { CartNudges } from '@/ui/cart/cart-nudges';
|
|
12
|
+
import { FreeShippingBar } from '@/ui/cart/free-shipping-bar';
|
|
13
|
+
import { ReservationCountdown } from '@/ui/cart/reservation-countdown';
|
|
14
|
+
import { CartRecommendationSection } from '@/ui/product/recommendation-section';
|
|
15
|
+
import { LoadingSpinner } from '@/ui/shared/loading-spinner';
|
|
16
|
+
import { Button } from '@/components/ui/button';
|
|
17
|
+
import { Card } from '@/components/ui/card';
|
|
18
|
+
import { Separator } from '@/components/ui/separator';
|
|
19
|
+
import { useTranslations } from '@/core/lib/translations';
|
|
20
|
+
|
|
21
|
+
export function CartView() {
|
|
22
|
+
const t = useTranslations('cart');
|
|
23
|
+
const tc = useTranslations('common');
|
|
24
|
+
const tr = useTranslations('reservation');
|
|
25
|
+
const {
|
|
26
|
+
cart,
|
|
27
|
+
cartLoading,
|
|
28
|
+
refreshCart,
|
|
29
|
+
itemCount,
|
|
30
|
+
cartRecs,
|
|
31
|
+
upgrades,
|
|
32
|
+
bundles,
|
|
33
|
+
reservationExpired,
|
|
34
|
+
unavailableItems,
|
|
35
|
+
canProceedToCheckout,
|
|
36
|
+
onReservationExpired,
|
|
37
|
+
} = useCartPage();
|
|
38
|
+
|
|
39
|
+
if (cartLoading) {
|
|
40
|
+
return (
|
|
41
|
+
<div className="flex min-h-[60vh] items-center justify-center">
|
|
42
|
+
<LoadingSpinner size="lg" />
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Empty cart state
|
|
48
|
+
if (!cart || cart.items.length === 0) {
|
|
49
|
+
return (
|
|
50
|
+
<div className="mx-auto max-w-7xl px-4 py-16 text-center sm:px-6 lg:px-8">
|
|
51
|
+
<ShoppingBag
|
|
52
|
+
className="text-muted-foreground mx-auto mb-4 h-16 w-16"
|
|
53
|
+
strokeWidth={1.5}
|
|
54
|
+
aria-hidden="true"
|
|
55
|
+
/>
|
|
56
|
+
<h1 className="text-foreground text-2xl font-bold">{t('emptyTitle')}</h1>
|
|
57
|
+
<p className="text-muted-foreground mt-2">{t('emptySubtitle')}</p>
|
|
58
|
+
<Button asChild size="lg" className="mt-6 rounded px-6 text-base">
|
|
59
|
+
<Link href="/products">{tc('continueShopping')}</Link>
|
|
60
|
+
</Button>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<div className="mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8">
|
|
67
|
+
<h1 className="text-foreground mb-6 text-2xl font-bold">
|
|
68
|
+
{t('title')} ({itemCount} {itemCount === 1 ? tc('item') : tc('items')})
|
|
69
|
+
</h1>
|
|
70
|
+
|
|
71
|
+
{/* Reservation countdown. onExpire refreshes the cart and closes the
|
|
72
|
+
checkout gate below. Passing it is what makes expiry mean anything. */}
|
|
73
|
+
{cart.reservation?.hasReservation && (
|
|
74
|
+
<ReservationCountdown
|
|
75
|
+
reservation={cart.reservation}
|
|
76
|
+
onExpire={onReservationExpired}
|
|
77
|
+
className="mb-6"
|
|
78
|
+
/>
|
|
79
|
+
)}
|
|
80
|
+
|
|
81
|
+
<div className="grid grid-cols-1 gap-8 lg:grid-cols-3">
|
|
82
|
+
{/* Cart Items */}
|
|
83
|
+
<div className="lg:col-span-2">
|
|
84
|
+
{/* Nudges */}
|
|
85
|
+
{cart.nudges && cart.nudges.length > 0 && (
|
|
86
|
+
<CartNudges nudges={cart.nudges} className="mb-4" />
|
|
87
|
+
)}
|
|
88
|
+
|
|
89
|
+
{/* Cart items */}
|
|
90
|
+
<div>
|
|
91
|
+
{cart.items.map((item) => (
|
|
92
|
+
<div key={item.id}>
|
|
93
|
+
<CartItem item={item} onUpdate={refreshCart} />
|
|
94
|
+
{upgrades?.upgrades?.[item.productId] && (
|
|
95
|
+
<CartUpgradeBanner
|
|
96
|
+
suggestion={upgrades.upgrades[item.productId]}
|
|
97
|
+
cartItem={item}
|
|
98
|
+
onUpgrade={refreshCart}
|
|
99
|
+
className="mb-2 ms-24"
|
|
100
|
+
/>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
))}
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
{/* Bundle offers */}
|
|
107
|
+
{bundles?.bundles && bundles.bundles.length > 0 && (
|
|
108
|
+
<div className="mt-6 space-y-3">
|
|
109
|
+
<h3 className="text-foreground text-sm font-semibold">{t('bundleOffers')}</h3>
|
|
110
|
+
{bundles.bundles.map((offer) => (
|
|
111
|
+
<CartBundleOfferCard
|
|
112
|
+
key={offer.id}
|
|
113
|
+
offer={offer}
|
|
114
|
+
cartId={cart.id}
|
|
115
|
+
onAdd={refreshCart}
|
|
116
|
+
/>
|
|
117
|
+
))}
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
|
|
121
|
+
{/* Coupon input */}
|
|
122
|
+
<Separator className="mt-6" />
|
|
123
|
+
<div className="pt-4">
|
|
124
|
+
<CouponInput cart={cart} onUpdate={refreshCart} />
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
{/* Summary sidebar */}
|
|
129
|
+
<div className="lg:col-span-1">
|
|
130
|
+
<Card className="bg-muted/50 sticky top-24 p-6 shadow-none">
|
|
131
|
+
<FreeShippingBar className="mb-4" />
|
|
132
|
+
<CartSummary />
|
|
133
|
+
|
|
134
|
+
{/* Proceed to checkout. When the gate is closed this must be a
|
|
135
|
+
real disabled control, never a styled-down link: an anchor
|
|
136
|
+
ignores `disabled` and would still navigate. */}
|
|
137
|
+
{canProceedToCheckout ? (
|
|
138
|
+
<Button asChild size="lg" className="mt-6 w-full rounded px-6 text-sm">
|
|
139
|
+
<Link href="/checkout">{t('proceedToCheckout')}</Link>
|
|
140
|
+
</Button>
|
|
141
|
+
) : (
|
|
142
|
+
<>
|
|
143
|
+
<Button disabled size="lg" className="mt-6 w-full rounded px-6 text-sm">
|
|
144
|
+
{t('proceedToCheckout')}
|
|
145
|
+
</Button>
|
|
146
|
+
<p className="text-destructive mt-2 text-xs">
|
|
147
|
+
{unavailableItems.length > 0
|
|
148
|
+
? t('unavailableItemsHint')
|
|
149
|
+
: reservationExpired
|
|
150
|
+
? tr('expiredHint')
|
|
151
|
+
: null}
|
|
152
|
+
</p>
|
|
153
|
+
</>
|
|
154
|
+
)}
|
|
155
|
+
|
|
156
|
+
<Link
|
|
157
|
+
href="/products"
|
|
158
|
+
className="text-muted-foreground hover:text-foreground mt-3 inline-flex w-full items-center justify-center px-6 py-2 text-sm transition-colors"
|
|
159
|
+
>
|
|
160
|
+
{tc('continueShopping')}
|
|
161
|
+
</Link>
|
|
162
|
+
</Card>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
{/* Cross-sell recommendations */}
|
|
167
|
+
{cartRecs?.recommendations && cartRecs.recommendations.length > 0 && (
|
|
168
|
+
<CartRecommendationSection
|
|
169
|
+
title={t('youMightAlsoNeed')}
|
|
170
|
+
items={cartRecs.recommendations}
|
|
171
|
+
className="mt-10"
|
|
172
|
+
/>
|
|
173
|
+
)}
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
}
|