create-brainerce-store 1.4.1 → 1.5.1

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 (37) hide show
  1. package/dist/index.js +1 -1
  2. package/messages/en.json +9 -1
  3. package/messages/he.json +9 -1
  4. package/package.json +1 -1
  5. package/templates/nextjs/base/src/app/account/page.tsx +8 -4
  6. package/templates/nextjs/base/src/app/auth/callback/page.tsx +90 -90
  7. package/templates/nextjs/base/src/app/cart/page.tsx +110 -110
  8. package/templates/nextjs/base/src/app/checkout/page.tsx +614 -614
  9. package/templates/nextjs/base/src/app/login/page.tsx +58 -58
  10. package/templates/nextjs/base/src/app/order-confirmation/page.tsx +193 -193
  11. package/templates/nextjs/base/src/app/page.tsx +98 -98
  12. package/templates/nextjs/base/src/app/products/[slug]/page.tsx +435 -435
  13. package/templates/nextjs/base/src/app/products/page.tsx +246 -246
  14. package/templates/nextjs/base/src/app/register/page.tsx +68 -68
  15. package/templates/nextjs/base/src/app/verify-email/page.tsx +293 -293
  16. package/templates/nextjs/base/src/components/account/order-history.tsx +198 -198
  17. package/templates/nextjs/base/src/components/account/profile-section.tsx +189 -40
  18. package/templates/nextjs/base/src/components/auth/login-form.tsx +94 -94
  19. package/templates/nextjs/base/src/components/auth/oauth-buttons.tsx +137 -137
  20. package/templates/nextjs/base/src/components/auth/register-form.tsx +184 -184
  21. package/templates/nextjs/base/src/components/cart/cart-item.tsx +153 -153
  22. package/templates/nextjs/base/src/components/cart/cart-summary.tsx +70 -70
  23. package/templates/nextjs/base/src/components/cart/coupon-input.tsx +134 -134
  24. package/templates/nextjs/base/src/components/cart/reservation-countdown.tsx +103 -103
  25. package/templates/nextjs/base/src/components/checkout/checkout-form.tsx +305 -305
  26. package/templates/nextjs/base/src/components/checkout/delivery-method-step.tsx +64 -64
  27. package/templates/nextjs/base/src/components/checkout/payment-step.tsx +350 -344
  28. package/templates/nextjs/base/src/components/checkout/pickup-step.tsx +199 -199
  29. package/templates/nextjs/base/src/components/checkout/shipping-step.tsx +110 -110
  30. package/templates/nextjs/base/src/components/checkout/tax-display.tsx +65 -65
  31. package/templates/nextjs/base/src/components/layout/footer.tsx +38 -38
  32. package/templates/nextjs/base/src/components/layout/header.tsx +332 -332
  33. package/templates/nextjs/base/src/components/products/product-card.tsx +96 -96
  34. package/templates/nextjs/base/src/components/products/product-grid.tsx +35 -35
  35. package/templates/nextjs/base/src/components/shared/loading-spinner.tsx +32 -32
  36. package/templates/nextjs/base/src/lib/translations.ts +11 -11
  37. package/templates/nextjs/base/src/providers/store-provider.tsx.ejs +5 -1
@@ -1,153 +1,153 @@
1
- 'use client';
2
-
3
- import { useState } from 'react';
4
- import Image from 'next/image';
5
- import type { CartItem as CartItemType } from 'brainerce';
6
- import { getCartItemName, getCartItemImage, formatPrice } from 'brainerce';
7
- import { getClient } from '@/lib/brainerce';
8
- import { useTranslations } from '@/lib/translations';
9
- import { useStoreInfo } from '@/providers/store-provider';
10
- import { LoadingSpinner } from '@/components/shared/loading-spinner';
11
- import { cn } from '@/lib/utils';
12
-
13
- interface CartItemProps {
14
- item: CartItemType;
15
- onUpdate: () => void;
16
- className?: string;
17
- }
18
-
19
- export function CartItem({ item, onUpdate, className }: CartItemProps) {
20
- const t = useTranslations('common');
21
- const td = useTranslations('productDetail');
22
- const { storeInfo } = useStoreInfo();
23
- const currency = storeInfo?.currency || 'USD';
24
- const [updating, setUpdating] = useState(false);
25
- const [removing, setRemoving] = useState(false);
26
-
27
- const name = getCartItemName(item);
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={name} fill sizes="80px" className="object-cover" />
75
- ) : (
76
- <div className="text-muted-foreground absolute inset-0 flex items-center justify-center">
77
- <svg className="h-8 w-8" fill="none" viewBox="0 0 24 24" stroke="currentColor">
78
- <path
79
- strokeLinecap="round"
80
- strokeLinejoin="round"
81
- strokeWidth={1.5}
82
- d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"
83
- />
84
- </svg>
85
- </div>
86
- )}
87
- </div>
88
-
89
- {/* Details */}
90
- <div className="min-w-0 flex-1">
91
- <h3 className="text-foreground truncate text-sm font-medium">{name}</h3>
92
-
93
- {/* Variant name */}
94
- {variantName && <p className="text-muted-foreground mt-1 text-xs">{variantName}</p>}
95
-
96
- {/* Unit price */}
97
- <p className="text-muted-foreground mt-1 text-sm">
98
- {formatPrice(unitPrice, { currency }) as string}
99
- </p>
100
-
101
- {/* Quantity controls */}
102
- <div className="mt-2 flex items-center gap-3">
103
- <div className="border-border flex items-center rounded border">
104
- <button
105
- type="button"
106
- onClick={() => handleQuantityChange(item.quantity - 1)}
107
- disabled={updating || item.quantity <= 1}
108
- className="text-foreground hover:bg-muted px-2 py-1 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40"
109
- aria-label={td('decreaseQuantity')}
110
- >
111
- -
112
- </button>
113
- <span className="text-foreground min-w-[2.5rem] px-3 py-1 text-center text-sm font-medium">
114
- {updating ? (
115
- <LoadingSpinner
116
- size="sm"
117
- className="border-muted-foreground/30 border-t-foreground mx-auto"
118
- />
119
- ) : (
120
- item.quantity
121
- )}
122
- </span>
123
- <button
124
- type="button"
125
- onClick={() => handleQuantityChange(item.quantity + 1)}
126
- disabled={updating}
127
- className="text-foreground hover:bg-muted px-2 py-1 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40"
128
- aria-label={td('increaseQuantity')}
129
- >
130
- +
131
- </button>
132
- </div>
133
-
134
- <button
135
- type="button"
136
- onClick={handleRemove}
137
- disabled={removing}
138
- className="text-destructive hover:text-destructive/80 text-xs transition-colors disabled:opacity-40"
139
- >
140
- {removing ? t('removing') : t('remove')}
141
- </button>
142
- </div>
143
- </div>
144
-
145
- {/* Line total */}
146
- <div className="flex-shrink-0 text-end">
147
- <span className="text-foreground text-sm font-medium">
148
- {formatPrice(lineTotal, { currency }) as string}
149
- </span>
150
- </div>
151
- </div>
152
- );
153
- }
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+ import Image from 'next/image';
5
+ import type { CartItem as CartItemType } from 'brainerce';
6
+ import { getCartItemName, getCartItemImage, formatPrice } from 'brainerce';
7
+ import { getClient } from '@/lib/brainerce';
8
+ import { useTranslations } from '@/lib/translations';
9
+ import { useStoreInfo } from '@/providers/store-provider';
10
+ import { LoadingSpinner } from '@/components/shared/loading-spinner';
11
+ import { cn } from '@/lib/utils';
12
+
13
+ interface CartItemProps {
14
+ item: CartItemType;
15
+ onUpdate: () => void;
16
+ className?: string;
17
+ }
18
+
19
+ export function CartItem({ item, onUpdate, className }: CartItemProps) {
20
+ const t = useTranslations('common');
21
+ const td = useTranslations('productDetail');
22
+ const { storeInfo } = useStoreInfo();
23
+ const currency = storeInfo?.currency || 'USD';
24
+ const [updating, setUpdating] = useState(false);
25
+ const [removing, setRemoving] = useState(false);
26
+
27
+ const name = getCartItemName(item);
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={name} fill sizes="80px" className="object-cover" />
75
+ ) : (
76
+ <div className="text-muted-foreground absolute inset-0 flex items-center justify-center">
77
+ <svg className="h-8 w-8" fill="none" viewBox="0 0 24 24" stroke="currentColor">
78
+ <path
79
+ strokeLinecap="round"
80
+ strokeLinejoin="round"
81
+ strokeWidth={1.5}
82
+ d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"
83
+ />
84
+ </svg>
85
+ </div>
86
+ )}
87
+ </div>
88
+
89
+ {/* Details */}
90
+ <div className="min-w-0 flex-1">
91
+ <h3 className="text-foreground truncate text-sm font-medium">{name}</h3>
92
+
93
+ {/* Variant name */}
94
+ {variantName && <p className="text-muted-foreground mt-1 text-xs">{variantName}</p>}
95
+
96
+ {/* Unit price */}
97
+ <p className="text-muted-foreground mt-1 text-sm">
98
+ {formatPrice(unitPrice, { currency }) as string}
99
+ </p>
100
+
101
+ {/* Quantity controls */}
102
+ <div className="mt-2 flex items-center gap-3">
103
+ <div className="border-border flex items-center rounded border">
104
+ <button
105
+ type="button"
106
+ onClick={() => handleQuantityChange(item.quantity - 1)}
107
+ disabled={updating || item.quantity <= 1}
108
+ className="text-foreground hover:bg-muted px-2 py-1 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40"
109
+ aria-label={td('decreaseQuantity')}
110
+ >
111
+ -
112
+ </button>
113
+ <span className="text-foreground min-w-[2.5rem] px-3 py-1 text-center text-sm font-medium">
114
+ {updating ? (
115
+ <LoadingSpinner
116
+ size="sm"
117
+ className="border-muted-foreground/30 border-t-foreground mx-auto"
118
+ />
119
+ ) : (
120
+ item.quantity
121
+ )}
122
+ </span>
123
+ <button
124
+ type="button"
125
+ onClick={() => handleQuantityChange(item.quantity + 1)}
126
+ disabled={updating}
127
+ className="text-foreground hover:bg-muted px-2 py-1 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40"
128
+ aria-label={td('increaseQuantity')}
129
+ >
130
+ +
131
+ </button>
132
+ </div>
133
+
134
+ <button
135
+ type="button"
136
+ onClick={handleRemove}
137
+ disabled={removing}
138
+ className="text-destructive hover:text-destructive/80 text-xs transition-colors disabled:opacity-40"
139
+ >
140
+ {removing ? t('removing') : t('remove')}
141
+ </button>
142
+ </div>
143
+ </div>
144
+
145
+ {/* Line total */}
146
+ <div className="flex-shrink-0 text-end">
147
+ <span className="text-foreground text-sm font-medium">
148
+ {formatPrice(lineTotal, { currency }) as string}
149
+ </span>
150
+ </div>
151
+ </div>
152
+ );
153
+ }
@@ -1,70 +1,70 @@
1
- 'use client';
2
-
3
- import { formatPrice } from 'brainerce';
4
- import { useTranslations } from '@/lib/translations';
5
- import { useStoreInfo, useCart } from '@/providers/store-provider';
6
- import { cn } from '@/lib/utils';
7
-
8
- interface CartSummaryProps {
9
- className?: string;
10
- }
11
-
12
- export function CartSummary({ className }: CartSummaryProps) {
13
- const t = useTranslations('cart');
14
- const tc = useTranslations('common');
15
- const { storeInfo } = useStoreInfo();
16
- const { totals } = useCart();
17
- const currency = storeInfo?.currency || 'USD';
18
-
19
- return (
20
- <div className={cn('space-y-3', className)}>
21
- <h3 className="text-foreground text-lg font-semibold">{t('orderSummary')}</h3>
22
-
23
- <div className="space-y-2 text-sm">
24
- {/* Subtotal */}
25
- <div className="flex items-center justify-between">
26
- <span className="text-muted-foreground">{tc('subtotal')}</span>
27
- <span className="text-foreground font-medium">
28
- {formatPrice(totals.subtotal, { currency }) as string}
29
- </span>
30
- </div>
31
-
32
- {/* Discount */}
33
- {totals.discount > 0 && (
34
- <div className="flex items-center justify-between">
35
- <span className="text-muted-foreground">{tc('discount')}</span>
36
- <span className="text-destructive font-medium">
37
- -{formatPrice(totals.discount, { currency }) as string}
38
- </span>
39
- </div>
40
- )}
41
-
42
- {/* Shipping */}
43
- {totals.shipping > 0 && (
44
- <div className="flex items-center justify-between">
45
- <span className="text-muted-foreground">{tc('shipping')}</span>
46
- <span className="text-foreground font-medium">
47
- {formatPrice(totals.shipping, { currency }) as string}
48
- </span>
49
- </div>
50
- )}
51
-
52
- {/* Tax */}
53
- <div className="flex items-center justify-between">
54
- <span className="text-muted-foreground">{tc('tax')}</span>
55
- <span className="text-muted-foreground text-xs">{t('taxAtCheckout')}</span>
56
- </div>
57
-
58
- {/* Divider */}
59
- <div className="border-border mt-2 border-t pt-2">
60
- <div className="flex items-center justify-between">
61
- <span className="text-foreground font-semibold">{tc('total')}</span>
62
- <span className="text-foreground text-base font-semibold">
63
- {formatPrice(totals.total, { currency }) as string}
64
- </span>
65
- </div>
66
- </div>
67
- </div>
68
- </div>
69
- );
70
- }
1
+ 'use client';
2
+
3
+ import { formatPrice } from 'brainerce';
4
+ import { useTranslations } from '@/lib/translations';
5
+ import { useStoreInfo, useCart } from '@/providers/store-provider';
6
+ import { cn } from '@/lib/utils';
7
+
8
+ interface CartSummaryProps {
9
+ className?: string;
10
+ }
11
+
12
+ export function CartSummary({ className }: CartSummaryProps) {
13
+ const t = useTranslations('cart');
14
+ const tc = useTranslations('common');
15
+ const { storeInfo } = useStoreInfo();
16
+ const { totals } = useCart();
17
+ const currency = storeInfo?.currency || 'USD';
18
+
19
+ return (
20
+ <div className={cn('space-y-3', className)}>
21
+ <h3 className="text-foreground text-lg font-semibold">{t('orderSummary')}</h3>
22
+
23
+ <div className="space-y-2 text-sm">
24
+ {/* Subtotal */}
25
+ <div className="flex items-center justify-between">
26
+ <span className="text-muted-foreground">{tc('subtotal')}</span>
27
+ <span className="text-foreground font-medium">
28
+ {formatPrice(totals.subtotal, { currency }) as string}
29
+ </span>
30
+ </div>
31
+
32
+ {/* Discount */}
33
+ {totals.discount > 0 && (
34
+ <div className="flex items-center justify-between">
35
+ <span className="text-muted-foreground">{tc('discount')}</span>
36
+ <span className="text-destructive font-medium">
37
+ -{formatPrice(totals.discount, { currency }) as string}
38
+ </span>
39
+ </div>
40
+ )}
41
+
42
+ {/* Shipping */}
43
+ {totals.shipping > 0 && (
44
+ <div className="flex items-center justify-between">
45
+ <span className="text-muted-foreground">{tc('shipping')}</span>
46
+ <span className="text-foreground font-medium">
47
+ {formatPrice(totals.shipping, { currency }) as string}
48
+ </span>
49
+ </div>
50
+ )}
51
+
52
+ {/* Tax */}
53
+ <div className="flex items-center justify-between">
54
+ <span className="text-muted-foreground">{tc('tax')}</span>
55
+ <span className="text-muted-foreground text-xs">{t('taxAtCheckout')}</span>
56
+ </div>
57
+
58
+ {/* Divider */}
59
+ <div className="border-border mt-2 border-t pt-2">
60
+ <div className="flex items-center justify-between">
61
+ <span className="text-foreground font-semibold">{tc('total')}</span>
62
+ <span className="text-foreground text-base font-semibold">
63
+ {formatPrice(totals.total, { currency }) as string}
64
+ </span>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ );
70
+ }