create-brainerce-store 1.4.1 → 1.5.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 (36) hide show
  1. package/dist/index.js +1 -1
  2. package/messages/en.json +266 -258
  3. package/messages/he.json +266 -258
  4. package/package.json +45 -45
  5. package/templates/nextjs/base/src/app/account/page.tsx +108 -108
  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 +210 -75
  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
@@ -1,198 +1,198 @@
1
- 'use client';
2
-
3
- import { useState } from 'react';
4
- import Image from 'next/image';
5
- import type { Order, OrderStatus } from 'brainerce';
6
- import { formatPrice } from 'brainerce';
7
- import { useTranslations } from '@/lib/translations';
8
- import { cn } from '@/lib/utils';
9
-
10
- const STATUS_CONFIG: Record<OrderStatus, { labelKey: string; className: string }> = {
11
- pending: {
12
- labelKey: 'statusPending',
13
- className: 'bg-yellow-100 text-yellow-800 dark:bg-yellow-950/30 dark:text-yellow-400',
14
- },
15
- processing: {
16
- labelKey: 'statusProcessing',
17
- className: 'bg-blue-100 text-blue-800 dark:bg-blue-950/30 dark:text-blue-400',
18
- },
19
- shipped: {
20
- labelKey: 'statusShipped',
21
- className: 'bg-purple-100 text-purple-800 dark:bg-purple-950/30 dark:text-purple-400',
22
- },
23
- delivered: {
24
- labelKey: 'statusDelivered',
25
- className: 'bg-green-100 text-green-800 dark:bg-green-950/30 dark:text-green-400',
26
- },
27
- cancelled: {
28
- labelKey: 'statusCancelled',
29
- className: 'bg-red-100 text-red-800 dark:bg-red-950/30 dark:text-red-400',
30
- },
31
- refunded: {
32
- labelKey: 'statusRefunded',
33
- className: 'bg-orange-100 text-orange-800 dark:bg-orange-950/30 dark:text-orange-400',
34
- },
35
- };
36
-
37
- interface OrderHistoryProps {
38
- orders: Order[];
39
- className?: string;
40
- }
41
-
42
- export function OrderHistory({ orders, className }: OrderHistoryProps) {
43
- const t = useTranslations('account');
44
- if (orders.length === 0) {
45
- return (
46
- <div className={cn('py-12 text-center', className)}>
47
- <svg
48
- className="text-muted-foreground mx-auto mb-3 h-12 w-12"
49
- fill="none"
50
- viewBox="0 0 24 24"
51
- stroke="currentColor"
52
- >
53
- <path
54
- strokeLinecap="round"
55
- strokeLinejoin="round"
56
- strokeWidth={1.5}
57
- d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"
58
- />
59
- </svg>
60
- <h3 className="text-foreground text-lg font-semibold">{t('noOrders')}</h3>
61
- <p className="text-muted-foreground mt-1 text-sm">{t('noOrdersDesc')}</p>
62
- </div>
63
- );
64
- }
65
-
66
- return (
67
- <div className={cn('space-y-4', className)}>
68
- {orders.map((order) => (
69
- <OrderCard key={order.id} order={order} />
70
- ))}
71
- </div>
72
- );
73
- }
74
-
75
- function OrderCard({ order }: { order: Order }) {
76
- const t = useTranslations('account');
77
- const tc = useTranslations('common');
78
- const [expanded, setExpanded] = useState(false);
79
- const statusConfig = STATUS_CONFIG[order.status] || STATUS_CONFIG.pending;
80
- const currency = order.currency || 'USD';
81
- const totalAmount = order.totalAmount || order.total || '0';
82
-
83
- return (
84
- <div className="border-border overflow-hidden rounded-lg border">
85
- {/* Order header */}
86
- <button
87
- type="button"
88
- onClick={() => setExpanded(!expanded)}
89
- className="hover:bg-muted/50 flex w-full items-center justify-between p-4 text-start transition-colors"
90
- >
91
- <div className="min-w-0 flex-1">
92
- <div className="flex flex-wrap items-center gap-3">
93
- <span className="text-foreground text-sm font-semibold">
94
- {order.orderNumber || `${t('orderPrefix')} ${order.id.slice(0, 8)}`}
95
- </span>
96
- <span
97
- className={cn(
98
- 'inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium',
99
- statusConfig.className
100
- )}
101
- >
102
- {t(
103
- statusConfig.labelKey as
104
- | 'statusPending'
105
- | 'statusProcessing'
106
- | 'statusShipped'
107
- | 'statusDelivered'
108
- | 'statusCancelled'
109
- | 'statusRefunded'
110
- )}
111
- </span>
112
- </div>
113
- <div className="text-muted-foreground mt-1 flex items-center gap-4 text-xs">
114
- <span>
115
- {new Date(order.createdAt).toLocaleDateString(undefined, {
116
- year: 'numeric',
117
- month: 'short',
118
- day: 'numeric',
119
- })}
120
- </span>
121
- <span>
122
- {order.items.length} {order.items.length === 1 ? tc('item') : tc('items')}
123
- </span>
124
- </div>
125
- </div>
126
-
127
- <div className="flex flex-shrink-0 items-center gap-3">
128
- <span className="text-foreground text-sm font-semibold">
129
- {formatPrice(parseFloat(totalAmount), { currency }) as string}
130
- </span>
131
- <svg
132
- className={cn(
133
- 'text-muted-foreground h-4 w-4 transition-transform',
134
- expanded && 'rotate-180'
135
- )}
136
- fill="none"
137
- viewBox="0 0 24 24"
138
- stroke="currentColor"
139
- >
140
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7" />
141
- </svg>
142
- </div>
143
- </button>
144
-
145
- {/* Expanded order items */}
146
- {expanded && (
147
- <div className="border-border bg-muted/30 space-y-3 border-t px-4 py-3">
148
- {order.items.map((item, index) => (
149
- <div key={`${item.productId}-${index}`} className="flex items-center gap-3">
150
- <div className="bg-muted relative h-10 w-10 flex-shrink-0 overflow-hidden rounded">
151
- {item.image ? (
152
- <Image
153
- src={item.image}
154
- alt={item.name || t('productFallback')}
155
- fill
156
- sizes="40px"
157
- className="object-cover"
158
- />
159
- ) : (
160
- <div className="text-muted-foreground absolute inset-0 flex items-center justify-center">
161
- <svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
162
- <path
163
- strokeLinecap="round"
164
- strokeLinejoin="round"
165
- strokeWidth={1.5}
166
- 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"
167
- />
168
- </svg>
169
- </div>
170
- )}
171
- </div>
172
-
173
- <div className="min-w-0 flex-1">
174
- <p className="text-foreground truncate text-sm">
175
- {item.name || t('productFallback')}
176
- </p>
177
- <p className="text-muted-foreground text-xs">
178
- {tc('qty')} {item.quantity}
179
- </p>
180
- </div>
181
-
182
- <span className="text-foreground flex-shrink-0 text-sm">
183
- {formatPrice(parseFloat(item.price), { currency }) as string}
184
- </span>
185
- </div>
186
- ))}
187
-
188
- <div className="border-border flex items-center justify-between border-t pt-2">
189
- <span className="text-muted-foreground text-sm font-medium">{tc('total')}</span>
190
- <span className="text-foreground text-sm font-semibold">
191
- {formatPrice(parseFloat(totalAmount), { currency }) as string}
192
- </span>
193
- </div>
194
- </div>
195
- )}
196
- </div>
197
- );
198
- }
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+ import Image from 'next/image';
5
+ import type { Order, OrderStatus } from 'brainerce';
6
+ import { formatPrice } from 'brainerce';
7
+ import { useTranslations } from '@/lib/translations';
8
+ import { cn } from '@/lib/utils';
9
+
10
+ const STATUS_CONFIG: Record<OrderStatus, { labelKey: string; className: string }> = {
11
+ pending: {
12
+ labelKey: 'statusPending',
13
+ className: 'bg-yellow-100 text-yellow-800 dark:bg-yellow-950/30 dark:text-yellow-400',
14
+ },
15
+ processing: {
16
+ labelKey: 'statusProcessing',
17
+ className: 'bg-blue-100 text-blue-800 dark:bg-blue-950/30 dark:text-blue-400',
18
+ },
19
+ shipped: {
20
+ labelKey: 'statusShipped',
21
+ className: 'bg-purple-100 text-purple-800 dark:bg-purple-950/30 dark:text-purple-400',
22
+ },
23
+ delivered: {
24
+ labelKey: 'statusDelivered',
25
+ className: 'bg-green-100 text-green-800 dark:bg-green-950/30 dark:text-green-400',
26
+ },
27
+ cancelled: {
28
+ labelKey: 'statusCancelled',
29
+ className: 'bg-red-100 text-red-800 dark:bg-red-950/30 dark:text-red-400',
30
+ },
31
+ refunded: {
32
+ labelKey: 'statusRefunded',
33
+ className: 'bg-orange-100 text-orange-800 dark:bg-orange-950/30 dark:text-orange-400',
34
+ },
35
+ };
36
+
37
+ interface OrderHistoryProps {
38
+ orders: Order[];
39
+ className?: string;
40
+ }
41
+
42
+ export function OrderHistory({ orders, className }: OrderHistoryProps) {
43
+ const t = useTranslations('account');
44
+ if (orders.length === 0) {
45
+ return (
46
+ <div className={cn('py-12 text-center', className)}>
47
+ <svg
48
+ className="text-muted-foreground mx-auto mb-3 h-12 w-12"
49
+ fill="none"
50
+ viewBox="0 0 24 24"
51
+ stroke="currentColor"
52
+ >
53
+ <path
54
+ strokeLinecap="round"
55
+ strokeLinejoin="round"
56
+ strokeWidth={1.5}
57
+ d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"
58
+ />
59
+ </svg>
60
+ <h3 className="text-foreground text-lg font-semibold">{t('noOrders')}</h3>
61
+ <p className="text-muted-foreground mt-1 text-sm">{t('noOrdersDesc')}</p>
62
+ </div>
63
+ );
64
+ }
65
+
66
+ return (
67
+ <div className={cn('space-y-4', className)}>
68
+ {orders.map((order) => (
69
+ <OrderCard key={order.id} order={order} />
70
+ ))}
71
+ </div>
72
+ );
73
+ }
74
+
75
+ function OrderCard({ order }: { order: Order }) {
76
+ const t = useTranslations('account');
77
+ const tc = useTranslations('common');
78
+ const [expanded, setExpanded] = useState(false);
79
+ const statusConfig = STATUS_CONFIG[order.status] || STATUS_CONFIG.pending;
80
+ const currency = order.currency || 'USD';
81
+ const totalAmount = order.totalAmount || order.total || '0';
82
+
83
+ return (
84
+ <div className="border-border overflow-hidden rounded-lg border">
85
+ {/* Order header */}
86
+ <button
87
+ type="button"
88
+ onClick={() => setExpanded(!expanded)}
89
+ className="hover:bg-muted/50 flex w-full items-center justify-between p-4 text-start transition-colors"
90
+ >
91
+ <div className="min-w-0 flex-1">
92
+ <div className="flex flex-wrap items-center gap-3">
93
+ <span className="text-foreground text-sm font-semibold">
94
+ {order.orderNumber || `${t('orderPrefix')} ${order.id.slice(0, 8)}`}
95
+ </span>
96
+ <span
97
+ className={cn(
98
+ 'inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium',
99
+ statusConfig.className
100
+ )}
101
+ >
102
+ {t(
103
+ statusConfig.labelKey as
104
+ | 'statusPending'
105
+ | 'statusProcessing'
106
+ | 'statusShipped'
107
+ | 'statusDelivered'
108
+ | 'statusCancelled'
109
+ | 'statusRefunded'
110
+ )}
111
+ </span>
112
+ </div>
113
+ <div className="text-muted-foreground mt-1 flex items-center gap-4 text-xs">
114
+ <span>
115
+ {new Date(order.createdAt).toLocaleDateString(undefined, {
116
+ year: 'numeric',
117
+ month: 'short',
118
+ day: 'numeric',
119
+ })}
120
+ </span>
121
+ <span>
122
+ {order.items.length} {order.items.length === 1 ? tc('item') : tc('items')}
123
+ </span>
124
+ </div>
125
+ </div>
126
+
127
+ <div className="flex flex-shrink-0 items-center gap-3">
128
+ <span className="text-foreground text-sm font-semibold">
129
+ {formatPrice(parseFloat(totalAmount), { currency }) as string}
130
+ </span>
131
+ <svg
132
+ className={cn(
133
+ 'text-muted-foreground h-4 w-4 transition-transform',
134
+ expanded && 'rotate-180'
135
+ )}
136
+ fill="none"
137
+ viewBox="0 0 24 24"
138
+ stroke="currentColor"
139
+ >
140
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7" />
141
+ </svg>
142
+ </div>
143
+ </button>
144
+
145
+ {/* Expanded order items */}
146
+ {expanded && (
147
+ <div className="border-border bg-muted/30 space-y-3 border-t px-4 py-3">
148
+ {order.items.map((item, index) => (
149
+ <div key={`${item.productId}-${index}`} className="flex items-center gap-3">
150
+ <div className="bg-muted relative h-10 w-10 flex-shrink-0 overflow-hidden rounded">
151
+ {item.image ? (
152
+ <Image
153
+ src={item.image}
154
+ alt={item.name || t('productFallback')}
155
+ fill
156
+ sizes="40px"
157
+ className="object-cover"
158
+ />
159
+ ) : (
160
+ <div className="text-muted-foreground absolute inset-0 flex items-center justify-center">
161
+ <svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
162
+ <path
163
+ strokeLinecap="round"
164
+ strokeLinejoin="round"
165
+ strokeWidth={1.5}
166
+ 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"
167
+ />
168
+ </svg>
169
+ </div>
170
+ )}
171
+ </div>
172
+
173
+ <div className="min-w-0 flex-1">
174
+ <p className="text-foreground truncate text-sm">
175
+ {item.name || t('productFallback')}
176
+ </p>
177
+ <p className="text-muted-foreground text-xs">
178
+ {tc('qty')} {item.quantity}
179
+ </p>
180
+ </div>
181
+
182
+ <span className="text-foreground flex-shrink-0 text-sm">
183
+ {formatPrice(parseFloat(item.price), { currency }) as string}
184
+ </span>
185
+ </div>
186
+ ))}
187
+
188
+ <div className="border-border flex items-center justify-between border-t pt-2">
189
+ <span className="text-muted-foreground text-sm font-medium">{tc('total')}</span>
190
+ <span className="text-foreground text-sm font-semibold">
191
+ {formatPrice(parseFloat(totalAmount), { currency }) as string}
192
+ </span>
193
+ </div>
194
+ </div>
195
+ )}
196
+ </div>
197
+ );
198
+ }