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,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
- async function handleQuantityChange(newQuantity: number) {
38
- if (newQuantity < 1 || updating) return;
39
-
40
- try {
41
- setUpdating(true);
42
- const client = getClient();
43
- await client.smartUpdateCartItem(item.productId, newQuantity, item.variantId || undefined);
44
- onUpdate();
45
- } catch (err) {
46
- console.error('Failed to update quantity:', err);
47
- } finally {
48
- setUpdating(false);
49
- }
50
- }
51
-
52
- async function handleRemove() {
53
- if (removing) return;
54
-
55
- try {
56
- setRemoving(true);
57
- const client = getClient();
58
- await client.smartRemoveFromCart(item.productId, item.variantId || undefined);
59
- onUpdate();
60
- } catch (err) {
61
- console.error('Failed to remove item:', err);
62
- } finally {
63
- setRemoving(false);
64
- }
65
- }
66
-
67
- return (
68
- <div className={cn('flex items-start gap-4', className)}>
69
- {/* Image `relative` + fixed box are layout-critical for next/image fill */}
70
- <div className="relative h-20 w-20 shrink-0 overflow-hidden rounded-lg border bg-secondary sm:h-24 sm:w-24">
71
- {imageUrl ? (
72
- <Image src={imageUrl} alt={productName} fill sizes="96px" className="object-cover" />
73
- ) : (
74
- <span className="sr-only">{productName}</span>
75
- )}
76
- </div>
77
-
78
- {/* Details */}
79
- <div className="min-w-0 flex-1">
80
- <h3 className="font-sans text-[15px] font-semibold leading-snug text-foreground">
81
- {productName}
82
- </h3>
83
-
84
- {/* Variant name */}
85
- {variantName && <p className="mt-0.5 text-xs text-muted-foreground">{variantName}</p>}
86
-
87
- {/* Unit price */}
88
- <p className="mt-1 text-sm text-muted-foreground">
89
- {formatPrice(unitPrice, { currency }) as string}
90
- </p>
91
-
92
- {/* Quantity controls + remove */}
93
- <div className="mt-3 flex flex-wrap items-center gap-3">
94
- <div
95
- className="flex h-9 items-center rounded-full border"
96
- role="group"
97
- aria-label={td('quantityLabel')}
98
- >
99
- <button
100
- type="button"
101
- onClick={() => handleQuantityChange(item.quantity - 1)}
102
- disabled={updating || item.quantity <= 1}
103
- aria-label={td('decreaseQuantity')}
104
- className="flex h-full w-9 items-center justify-center rounded-s-full transition-colors hover:bg-secondary disabled:opacity-40"
105
- >
106
- <IconMinus size={16} />
107
- </button>
108
- <span aria-live="polite" className="min-w-7 text-center text-sm font-semibold">
109
- {updating ? <LoadingSpinner size="sm" /> : item.quantity}
110
- </span>
111
- <button
112
- type="button"
113
- onClick={() => handleQuantityChange(item.quantity + 1)}
114
- disabled={updating}
115
- aria-label={td('increaseQuantity')}
116
- className="flex h-full w-9 items-center justify-center rounded-e-full transition-colors hover:bg-secondary disabled:opacity-40"
117
- >
118
- <IconPlus size={16} />
119
- </button>
120
- </div>
121
-
122
- <button
123
- type="button"
124
- onClick={handleRemove}
125
- disabled={removing}
126
- className="inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50"
127
- >
128
- <IconTrash size={16} />
129
- {removing ? t('removing') : t('remove')}
130
- </button>
131
- </div>
132
- </div>
133
-
134
- {/* Line total */}
135
- <span className="text-base font-semibold text-foreground">
136
- {formatPrice(lineTotal, { currency }) as string}
137
- </span>
138
- </div>
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 { cart, cartLoading, refreshCart, itemCount, cartRecs, upgrades, bundles } = useCartPage();
22
-
23
- if (cartLoading) {
24
- return <LoadingSpinner size="lg" className="min-h-[60vh]" />;
25
- }
26
-
27
- // Empty cart state — designed, never a bare sentence in blank space.
28
- if (!cart || cart.items.length === 0) {
29
- return (
30
- <section className="container-narrow flex min-h-[60vh] items-center justify-center py-16">
31
- <div className="card flex w-full max-w-md flex-col items-center gap-3 px-8 py-14 text-center">
32
- <span className="flex h-16 w-16 items-center justify-center rounded-full bg-secondary text-primary">
33
- <IconBag size={32} />
34
- </span>
35
- <h1 className="text-2xl sm:text-3xl">{t('emptyTitle')}</h1>
36
- <p className="text-muted-foreground">{t('emptySubtitle')}</p>
37
- <Link href="/products" className="btn-primary btn-md mt-3">
38
- {tc('continueShopping')}
39
- <IconArrowEnd size={18} className="rtl-flip" />
40
- </Link>
41
- </div>
42
- </section>
43
- );
44
- }
45
-
46
- return (
47
- <section className="container-narrow py-8 lg:py-12">
48
- <h1 className="text-3xl sm:text-4xl">
49
- {t('title')}{' '}
50
- <span className="font-sans text-base font-normal text-muted-foreground">
51
- ({itemCount} {itemCount === 1 ? tc('item') : tc('items')})
52
- </span>
53
- </h1>
54
-
55
- {/* Reservation countdown */}
56
- {cart.reservation?.hasReservation && (
57
- <ReservationCountdown reservation={cart.reservation} className="mt-4" />
58
- )}
59
-
60
- <div className="mt-6 grid grid-cols-1 items-start gap-8 lg:grid-cols-3 lg:gap-10">
61
- {/* Cart Items */}
62
- <div className="lg:col-span-2">
63
- {/* Nudges */}
64
- {cart.nudges && cart.nudges.length > 0 && (
65
- <CartNudges nudges={cart.nudges} className="mb-4" />
66
- )}
67
-
68
- {/* Cart items */}
69
- <ul className="card divide-y overflow-hidden">
70
- {cart.items.map((item) => (
71
- <li key={item.id} className="p-4 sm:p-5">
72
- <CartItem item={item} onUpdate={refreshCart} />
73
- {upgrades?.upgrades?.[item.productId] && (
74
- <CartUpgradeBanner
75
- suggestion={upgrades.upgrades[item.productId]}
76
- cartItem={item}
77
- onUpgrade={refreshCart}
78
- className="mt-4"
79
- />
80
- )}
81
- </li>
82
- ))}
83
- </ul>
84
-
85
- {/* Bundle offers */}
86
- {bundles?.bundles && bundles.bundles.length > 0 && (
87
- <section className="mt-6">
88
- <h3 className="mb-3 text-xl">{t('bundleOffers')}</h3>
89
- <div className="space-y-4">
90
- {bundles.bundles.map((offer) => (
91
- <CartBundleOfferCard
92
- key={offer.id}
93
- offer={offer}
94
- cartId={cart.id}
95
- onAdd={refreshCart}
96
- />
97
- ))}
98
- </div>
99
- </section>
100
- )}
101
-
102
- {/* Coupon input */}
103
- <div className="mt-6">
104
- <p className="mb-2 text-sm font-semibold text-foreground">{t('couponTitle')}</p>
105
- <CouponInput cart={cart} onUpdate={refreshCart} />
106
- </div>
107
- </div>
108
-
109
- {/* Summary sidebar */}
110
- <aside className="lg:sticky lg:top-24">
111
- <div className="card space-y-5 p-5 sm:p-6">
112
- <FreeShippingBar />
113
- <CartSummary />
114
-
115
- <Link href="/checkout" className="btn-primary btn-lg w-full">
116
- {t('proceedToCheckout')}
117
- <IconArrowEnd size={20} className="rtl-flip" />
118
- </Link>
119
-
120
- <p className="flex items-center justify-center gap-1.5 text-xs text-muted-foreground">
121
- <IconShield size={16} />
122
- {t('secureCheckoutNote')}
123
- </p>
124
- </div>
125
-
126
- <p className="mt-4 text-center">
127
- <Link
128
- href="/products"
129
- className="text-sm font-medium text-primary underline-offset-2 hover:underline"
130
- >
131
- {tc('continueShopping')}
132
- </Link>
133
- </p>
134
- </aside>
135
- </div>
136
-
137
- {/* Cross-sell recommendations */}
138
- {cartRecs?.recommendations && cartRecs.recommendations.length > 0 && (
139
- <CartRecommendationSection
140
- title={t('youMightAlsoNeed')}
141
- items={cartRecs.recommendations}
142
- className="mt-12"
143
- />
144
- )}
145
- </section>
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
+ }