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,184 +1,184 @@
1
- 'use client';
2
-
3
- import { useState, useMemo } from 'react';
4
- import { useTranslations } from '@/lib/translations';
5
- import { cn } from '@/lib/utils';
6
- import { LoadingSpinner } from '@/components/shared/loading-spinner';
7
-
8
- interface RegisterData {
9
- firstName: string;
10
- lastName: string;
11
- email: string;
12
- password: string;
13
- }
14
-
15
- interface RegisterFormProps {
16
- onSubmit: (data: RegisterData) => Promise<void>;
17
- error?: string | null;
18
- className?: string;
19
- }
20
-
21
- function getPasswordStrength(password: string): { label: string; color: string; width: string } {
22
- if (password.length === 0) return { label: '', color: '', width: 'w-0' };
23
- if (password.length < 6) return { label: 'tooShort', color: 'bg-destructive', width: 'w-1/4' };
24
-
25
- let score = 0;
26
- if (password.length >= 8) score++;
27
- if (/[A-Z]/.test(password)) score++;
28
- if (/[0-9]/.test(password)) score++;
29
- if (/[^A-Za-z0-9]/.test(password)) score++;
30
-
31
- if (score <= 1) return { label: 'weak', color: 'bg-orange-500', width: 'w-1/3' };
32
- if (score <= 2) return { label: 'fair', color: 'bg-yellow-500', width: 'w-1/2' };
33
- if (score <= 3) return { label: 'good', color: 'bg-primary', width: 'w-3/4' };
34
- return { label: 'strong', color: 'bg-green-500', width: 'w-full' };
35
- }
36
-
37
- export function RegisterForm({ onSubmit, error, className }: RegisterFormProps) {
38
- const t = useTranslations('auth');
39
- const tf = useTranslations('checkoutForm');
40
- const [firstName, setFirstName] = useState('');
41
- const [lastName, setLastName] = useState('');
42
- const [email, setEmail] = useState('');
43
- const [password, setPassword] = useState('');
44
- const [loading, setLoading] = useState(false);
45
-
46
- const strength = useMemo(() => getPasswordStrength(password), [password]);
47
-
48
- async function handleSubmit(e: React.FormEvent) {
49
- e.preventDefault();
50
- if (loading) return;
51
-
52
- try {
53
- setLoading(true);
54
- await onSubmit({ firstName, lastName, email, password });
55
- } finally {
56
- setLoading(false);
57
- }
58
- }
59
-
60
- return (
61
- <form onSubmit={handleSubmit} className={cn('space-y-4', className)}>
62
- {error && (
63
- <div className="bg-destructive/10 border-destructive/20 text-destructive rounded-lg border px-4 py-3 text-sm">
64
- {error}
65
- </div>
66
- )}
67
-
68
- <div className="grid grid-cols-2 gap-3">
69
- <div>
70
- <label
71
- htmlFor="register-first-name"
72
- className="text-foreground mb-1.5 block text-sm font-medium"
73
- >
74
- {tf('firstName')}
75
- </label>
76
- <input
77
- id="register-first-name"
78
- type="text"
79
- required
80
- value={firstName}
81
- onChange={(e) => setFirstName(e.target.value)}
82
- placeholder={t('firstNamePlaceholder')}
83
- autoComplete="given-name"
84
- className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
85
- />
86
- </div>
87
-
88
- <div>
89
- <label
90
- htmlFor="register-last-name"
91
- className="text-foreground mb-1.5 block text-sm font-medium"
92
- >
93
- {tf('lastName')}
94
- </label>
95
- <input
96
- id="register-last-name"
97
- type="text"
98
- required
99
- value={lastName}
100
- onChange={(e) => setLastName(e.target.value)}
101
- placeholder={t('lastNamePlaceholder')}
102
- autoComplete="family-name"
103
- className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
104
- />
105
- </div>
106
- </div>
107
-
108
- <div>
109
- <label
110
- htmlFor="register-email"
111
- className="text-foreground mb-1.5 block text-sm font-medium"
112
- >
113
- {t('email')}
114
- </label>
115
- <input
116
- id="register-email"
117
- type="email"
118
- required
119
- value={email}
120
- onChange={(e) => setEmail(e.target.value)}
121
- placeholder={t('emailPlaceholder')}
122
- autoComplete="email"
123
- className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
124
- />
125
- </div>
126
-
127
- <div>
128
- <label
129
- htmlFor="register-password"
130
- className="text-foreground mb-1.5 block text-sm font-medium"
131
- >
132
- {t('password')}
133
- </label>
134
- <input
135
- id="register-password"
136
- type="password"
137
- required
138
- minLength={6}
139
- value={password}
140
- onChange={(e) => setPassword(e.target.value)}
141
- placeholder={t('atLeastChars')}
142
- autoComplete="new-password"
143
- className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
144
- />
145
- {password.length > 0 && (
146
- <div className="mt-2">
147
- <div className="bg-muted h-1.5 w-full overflow-hidden rounded-full">
148
- <div
149
- className={cn(
150
- 'h-full rounded-full transition-all duration-300',
151
- strength.color,
152
- strength.width
153
- )}
154
- />
155
- </div>
156
- <p className="text-muted-foreground mt-1 text-xs">
157
- {strength.label
158
- ? t(strength.label as 'tooShort' | 'weak' | 'fair' | 'good' | 'strong')
159
- : ''}
160
- </p>
161
- </div>
162
- )}
163
- </div>
164
-
165
- <button
166
- type="submit"
167
- disabled={loading}
168
- className="bg-primary text-primary-foreground flex h-10 w-full items-center justify-center gap-2 rounded text-sm font-medium transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50"
169
- >
170
- {loading ? (
171
- <>
172
- <LoadingSpinner
173
- size="sm"
174
- className="border-primary-foreground/30 border-t-primary-foreground"
175
- />
176
- {t('creatingAccount')}
177
- </>
178
- ) : (
179
- t('createAccount')
180
- )}
181
- </button>
182
- </form>
183
- );
184
- }
1
+ 'use client';
2
+
3
+ import { useState, useMemo } from 'react';
4
+ import { useTranslations } from '@/lib/translations';
5
+ import { cn } from '@/lib/utils';
6
+ import { LoadingSpinner } from '@/components/shared/loading-spinner';
7
+
8
+ interface RegisterData {
9
+ firstName: string;
10
+ lastName: string;
11
+ email: string;
12
+ password: string;
13
+ }
14
+
15
+ interface RegisterFormProps {
16
+ onSubmit: (data: RegisterData) => Promise<void>;
17
+ error?: string | null;
18
+ className?: string;
19
+ }
20
+
21
+ function getPasswordStrength(password: string): { label: string; color: string; width: string } {
22
+ if (password.length === 0) return { label: '', color: '', width: 'w-0' };
23
+ if (password.length < 6) return { label: 'tooShort', color: 'bg-destructive', width: 'w-1/4' };
24
+
25
+ let score = 0;
26
+ if (password.length >= 8) score++;
27
+ if (/[A-Z]/.test(password)) score++;
28
+ if (/[0-9]/.test(password)) score++;
29
+ if (/[^A-Za-z0-9]/.test(password)) score++;
30
+
31
+ if (score <= 1) return { label: 'weak', color: 'bg-orange-500', width: 'w-1/3' };
32
+ if (score <= 2) return { label: 'fair', color: 'bg-yellow-500', width: 'w-1/2' };
33
+ if (score <= 3) return { label: 'good', color: 'bg-primary', width: 'w-3/4' };
34
+ return { label: 'strong', color: 'bg-green-500', width: 'w-full' };
35
+ }
36
+
37
+ export function RegisterForm({ onSubmit, error, className }: RegisterFormProps) {
38
+ const t = useTranslations('auth');
39
+ const tf = useTranslations('checkoutForm');
40
+ const [firstName, setFirstName] = useState('');
41
+ const [lastName, setLastName] = useState('');
42
+ const [email, setEmail] = useState('');
43
+ const [password, setPassword] = useState('');
44
+ const [loading, setLoading] = useState(false);
45
+
46
+ const strength = useMemo(() => getPasswordStrength(password), [password]);
47
+
48
+ async function handleSubmit(e: React.FormEvent) {
49
+ e.preventDefault();
50
+ if (loading) return;
51
+
52
+ try {
53
+ setLoading(true);
54
+ await onSubmit({ firstName, lastName, email, password });
55
+ } finally {
56
+ setLoading(false);
57
+ }
58
+ }
59
+
60
+ return (
61
+ <form onSubmit={handleSubmit} className={cn('space-y-4', className)}>
62
+ {error && (
63
+ <div className="bg-destructive/10 border-destructive/20 text-destructive rounded-lg border px-4 py-3 text-sm">
64
+ {error}
65
+ </div>
66
+ )}
67
+
68
+ <div className="grid grid-cols-2 gap-3">
69
+ <div>
70
+ <label
71
+ htmlFor="register-first-name"
72
+ className="text-foreground mb-1.5 block text-sm font-medium"
73
+ >
74
+ {tf('firstName')}
75
+ </label>
76
+ <input
77
+ id="register-first-name"
78
+ type="text"
79
+ required
80
+ value={firstName}
81
+ onChange={(e) => setFirstName(e.target.value)}
82
+ placeholder={t('firstNamePlaceholder')}
83
+ autoComplete="given-name"
84
+ className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
85
+ />
86
+ </div>
87
+
88
+ <div>
89
+ <label
90
+ htmlFor="register-last-name"
91
+ className="text-foreground mb-1.5 block text-sm font-medium"
92
+ >
93
+ {tf('lastName')}
94
+ </label>
95
+ <input
96
+ id="register-last-name"
97
+ type="text"
98
+ required
99
+ value={lastName}
100
+ onChange={(e) => setLastName(e.target.value)}
101
+ placeholder={t('lastNamePlaceholder')}
102
+ autoComplete="family-name"
103
+ className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
104
+ />
105
+ </div>
106
+ </div>
107
+
108
+ <div>
109
+ <label
110
+ htmlFor="register-email"
111
+ className="text-foreground mb-1.5 block text-sm font-medium"
112
+ >
113
+ {t('email')}
114
+ </label>
115
+ <input
116
+ id="register-email"
117
+ type="email"
118
+ required
119
+ value={email}
120
+ onChange={(e) => setEmail(e.target.value)}
121
+ placeholder={t('emailPlaceholder')}
122
+ autoComplete="email"
123
+ className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
124
+ />
125
+ </div>
126
+
127
+ <div>
128
+ <label
129
+ htmlFor="register-password"
130
+ className="text-foreground mb-1.5 block text-sm font-medium"
131
+ >
132
+ {t('password')}
133
+ </label>
134
+ <input
135
+ id="register-password"
136
+ type="password"
137
+ required
138
+ minLength={6}
139
+ value={password}
140
+ onChange={(e) => setPassword(e.target.value)}
141
+ placeholder={t('atLeastChars')}
142
+ autoComplete="new-password"
143
+ className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
144
+ />
145
+ {password.length > 0 && (
146
+ <div className="mt-2">
147
+ <div className="bg-muted h-1.5 w-full overflow-hidden rounded-full">
148
+ <div
149
+ className={cn(
150
+ 'h-full rounded-full transition-all duration-300',
151
+ strength.color,
152
+ strength.width
153
+ )}
154
+ />
155
+ </div>
156
+ <p className="text-muted-foreground mt-1 text-xs">
157
+ {strength.label
158
+ ? t(strength.label as 'tooShort' | 'weak' | 'fair' | 'good' | 'strong')
159
+ : ''}
160
+ </p>
161
+ </div>
162
+ )}
163
+ </div>
164
+
165
+ <button
166
+ type="submit"
167
+ disabled={loading}
168
+ className="bg-primary text-primary-foreground flex h-10 w-full items-center justify-center gap-2 rounded text-sm font-medium transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50"
169
+ >
170
+ {loading ? (
171
+ <>
172
+ <LoadingSpinner
173
+ size="sm"
174
+ className="border-primary-foreground/30 border-t-primary-foreground"
175
+ />
176
+ {t('creatingAccount')}
177
+ </>
178
+ ) : (
179
+ t('createAccount')
180
+ )}
181
+ </button>
182
+ </form>
183
+ );
184
+ }