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.
Files changed (27) hide show
  1. package/README.md +31 -10
  2. package/dist/index.js +179 -107
  3. package/messages/en.json +14 -1
  4. package/messages/he.json +14 -1
  5. package/package.json +1 -1
  6. package/templates/nextjs/base/TRANSLATIONS.md +207 -200
  7. package/templates/nextjs/base/src/app/checkout/page.tsx +1074 -1018
  8. package/templates/nextjs/base/src/app/order-confirmation/page.tsx +21 -2
  9. package/templates/nextjs/base/src/components/account/order-history.tsx +371 -385
  10. package/templates/nextjs/base/src/components/account/order-status-timeline.tsx +85 -66
  11. package/templates/nextjs/base/src/core/hooks/use-cart-page.ts +127 -58
  12. package/templates/nextjs/base/src/core/lib/auth.ts +32 -39
  13. package/templates/nextjs/base/src/core/lib/brainerce.ts.ejs +5 -16
  14. package/templates/nextjs/base/src/core/providers/store-provider.tsx.ejs +3 -6
  15. package/templates/nextjs/base/src/ui/cart/cart-item.tsx +164 -146
  16. package/templates/nextjs/base/src/ui/cart/cart-view.tsx +176 -140
  17. package/templates/nextjs/base/src/ui/cart/reservation-countdown.tsx +137 -95
  18. package/templates/nextjs/base/src/ui/product/review-form.tsx +33 -11
  19. package/templates/nextjs/designs/atelier/ui/cart/cart-drawer.tsx +177 -163
  20. package/templates/nextjs/designs/atelier/ui/cart/cart-item.tsx +158 -140
  21. package/templates/nextjs/designs/atelier/ui/cart/cart-view.tsx +184 -147
  22. package/templates/nextjs/designs/atelier/ui/cart/reservation-countdown.tsx +131 -89
  23. package/templates/nextjs/designs/atelier/ui/product/review-form.tsx +30 -10
  24. package/templates/nextjs/ui-canvas/cart/cart-item.tsx +137 -123
  25. package/templates/nextjs/ui-canvas/cart/cart-view.tsx +140 -106
  26. package/templates/nextjs/ui-canvas/cart/reservation-countdown.tsx +124 -81
  27. 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
- async function handleQuantityChange(newQuantity: number) {
34
- if (newQuantity < 1 || updating) return;
35
-
36
- try {
37
- setUpdating(true);
38
- const client = getClient();
39
- await client.smartUpdateCartItem(item.productId, newQuantity, item.variantId || undefined);
40
- onUpdate();
41
- } catch (err) {
42
- console.error('Failed to update quantity:', err);
43
- } finally {
44
- setUpdating(false);
45
- }
46
- }
47
-
48
- async function handleRemove() {
49
- if (removing) return;
50
-
51
- try {
52
- setRemoving(true);
53
- const client = getClient();
54
- await client.smartRemoveFromCart(item.productId, item.variantId || undefined);
55
- onUpdate();
56
- } catch (err) {
57
- console.error('Failed to remove item:', err);
58
- } finally {
59
- setRemoving(false);
60
- }
61
- }
62
-
63
- return (
64
- <div
65
- className={cn(
66
- 'border-border flex gap-4 border-b py-4 last:border-0',
67
- (updating || removing) && 'opacity-60',
68
- className
69
- )}
70
- >
71
- {/* Image */}
72
- <div className="bg-muted relative h-20 w-20 flex-shrink-0 overflow-hidden rounded">
73
- {imageUrl ? (
74
- <Image src={imageUrl} alt={productName} fill sizes="80px" className="object-cover" />
75
- ) : (
76
- <div className="text-muted-foreground absolute inset-0 flex items-center justify-center">
77
- <ImageIcon className="h-8 w-8" strokeWidth={1.5} aria-hidden="true" />
78
- </div>
79
- )}
80
- </div>
81
-
82
- {/* Details */}
83
- <div className="min-w-0 flex-1">
84
- <h3 className="text-foreground truncate text-sm font-medium">{productName}</h3>
85
-
86
- {/* Variant name */}
87
- {variantName && <p className="text-muted-foreground mt-1 text-xs">{variantName}</p>}
88
-
89
- {/* Unit price */}
90
- <p className="text-muted-foreground mt-1 text-sm">
91
- {formatPrice(unitPrice, { currency }) as string}
92
- </p>
93
-
94
- {/* Quantity controls */}
95
- <div className="mt-2 flex items-center gap-3">
96
- <div className="border-border flex items-center rounded border">
97
- <button
98
- type="button"
99
- onClick={() => handleQuantityChange(item.quantity - 1)}
100
- disabled={updating || item.quantity <= 1}
101
- className="text-foreground hover:bg-muted px-2 py-1 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40"
102
- aria-label={td('decreaseQuantity')}
103
- >
104
- -
105
- </button>
106
- <span className="text-foreground min-w-[2.5rem] px-3 py-1 text-center text-sm font-medium">
107
- {updating ? (
108
- <LoadingSpinner
109
- size="sm"
110
- className="border-muted-foreground/30 border-t-foreground mx-auto"
111
- />
112
- ) : (
113
- item.quantity
114
- )}
115
- </span>
116
- <button
117
- type="button"
118
- onClick={() => handleQuantityChange(item.quantity + 1)}
119
- disabled={updating}
120
- className="text-foreground hover:bg-muted px-2 py-1 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40"
121
- aria-label={td('increaseQuantity')}
122
- >
123
- +
124
- </button>
125
- </div>
126
-
127
- <button
128
- type="button"
129
- onClick={handleRemove}
130
- disabled={removing}
131
- className="text-destructive hover:text-destructive/80 text-xs transition-colors disabled:opacity-40"
132
- >
133
- {removing ? t('removing') : t('remove')}
134
- </button>
135
- </div>
136
- </div>
137
-
138
- {/* Line total */}
139
- <div className="flex-shrink-0 text-end">
140
- <span className="text-foreground text-sm font-medium">
141
- {formatPrice(lineTotal, { currency }) as string}
142
- </span>
143
- </div>
144
- </div>
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 { cart, cartLoading, refreshCart, itemCount, cartRecs, upgrades, bundles } = useCartPage();
25
-
26
- if (cartLoading) {
27
- return (
28
- <div className="flex min-h-[60vh] items-center justify-center">
29
- <LoadingSpinner size="lg" />
30
- </div>
31
- );
32
- }
33
-
34
- // Empty cart state
35
- if (!cart || cart.items.length === 0) {
36
- return (
37
- <div className="mx-auto max-w-7xl px-4 py-16 text-center sm:px-6 lg:px-8">
38
- <ShoppingBag
39
- className="text-muted-foreground mx-auto mb-4 h-16 w-16"
40
- strokeWidth={1.5}
41
- aria-hidden="true"
42
- />
43
- <h1 className="text-foreground text-2xl font-bold">{t('emptyTitle')}</h1>
44
- <p className="text-muted-foreground mt-2">{t('emptySubtitle')}</p>
45
- <Button asChild size="lg" className="mt-6 rounded px-6 text-base">
46
- <Link href="/products">{tc('continueShopping')}</Link>
47
- </Button>
48
- </div>
49
- );
50
- }
51
-
52
- return (
53
- <div className="mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8">
54
- <h1 className="text-foreground mb-6 text-2xl font-bold">
55
- {t('title')} ({itemCount} {itemCount === 1 ? tc('item') : tc('items')})
56
- </h1>
57
-
58
- {/* Reservation countdown */}
59
- {cart.reservation?.hasReservation && (
60
- <ReservationCountdown reservation={cart.reservation} className="mb-6" />
61
- )}
62
-
63
- <div className="grid grid-cols-1 gap-8 lg:grid-cols-3">
64
- {/* Cart Items */}
65
- <div className="lg:col-span-2">
66
- {/* Nudges */}
67
- {cart.nudges && cart.nudges.length > 0 && (
68
- <CartNudges nudges={cart.nudges} className="mb-4" />
69
- )}
70
-
71
- {/* Cart items */}
72
- <div>
73
- {cart.items.map((item) => (
74
- <div key={item.id}>
75
- <CartItem item={item} onUpdate={refreshCart} />
76
- {upgrades?.upgrades?.[item.productId] && (
77
- <CartUpgradeBanner
78
- suggestion={upgrades.upgrades[item.productId]}
79
- cartItem={item}
80
- onUpgrade={refreshCart}
81
- className="mb-2 ms-24"
82
- />
83
- )}
84
- </div>
85
- ))}
86
- </div>
87
-
88
- {/* Bundle offers */}
89
- {bundles?.bundles && bundles.bundles.length > 0 && (
90
- <div className="mt-6 space-y-3">
91
- <h3 className="text-foreground text-sm font-semibold">{t('bundleOffers')}</h3>
92
- {bundles.bundles.map((offer) => (
93
- <CartBundleOfferCard
94
- key={offer.id}
95
- offer={offer}
96
- cartId={cart.id}
97
- onAdd={refreshCart}
98
- />
99
- ))}
100
- </div>
101
- )}
102
-
103
- {/* Coupon input */}
104
- <Separator className="mt-6" />
105
- <div className="pt-4">
106
- <CouponInput cart={cart} onUpdate={refreshCart} />
107
- </div>
108
- </div>
109
-
110
- {/* Summary sidebar */}
111
- <div className="lg:col-span-1">
112
- <Card className="bg-muted/50 sticky top-24 p-6 shadow-none">
113
- <FreeShippingBar className="mb-4" />
114
- <CartSummary />
115
-
116
- <Button asChild size="lg" className="mt-6 w-full rounded px-6 text-sm">
117
- <Link href="/checkout">{t('proceedToCheckout')}</Link>
118
- </Button>
119
-
120
- <Link
121
- href="/products"
122
- 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"
123
- >
124
- {tc('continueShopping')}
125
- </Link>
126
- </Card>
127
- </div>
128
- </div>
129
-
130
- {/* Cross-sell recommendations */}
131
- {cartRecs?.recommendations && cartRecs.recommendations.length > 0 && (
132
- <CartRecommendationSection
133
- title={t('youMightAlsoNeed')}
134
- items={cartRecs.recommendations}
135
- className="mt-10"
136
- />
137
- )}
138
- </div>
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
+ }