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