create-brainerce-store 1.67.0 → 1.71.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.
- package/dist/index.js +22 -2
- package/messages/en.json +52 -2
- package/messages/he.json +52 -2
- package/package.json +1 -1
- package/templates/nextjs/base/.env.local.ejs +7 -0
- package/templates/nextjs/base/AGENTS.md.ejs +7 -0
- package/templates/nextjs/base/CLAUDE.md.ejs +7 -0
- package/templates/nextjs/base/src/app/blog/[slug]/page.tsx.ejs +8 -2
- package/templates/nextjs/base/src/app/category/[slug]/page.tsx +16 -7
- package/templates/nextjs/base/src/app/checkout/page.tsx +1018 -1017
- package/templates/nextjs/base/src/app/error.tsx.ejs +53 -0
- package/templates/nextjs/base/src/app/pages/[slug]/page.tsx.ejs +8 -2
- package/templates/nextjs/base/src/app/products/[slug]/page.tsx +17 -7
- package/templates/nextjs/base/src/app/register/page.tsx +67 -64
- package/templates/nextjs/base/src/components/account/profile-section.tsx +303 -226
- package/templates/nextjs/base/src/components/auth/register-form.tsx +326 -245
- package/templates/nextjs/base/src/components/checkout/custom-fields-step.tsx +306 -294
- package/templates/nextjs/base/src/components/checkout/date-picker.tsx +13 -1
- package/templates/nextjs/base/src/components/checkout/datetime-picker.tsx +61 -21
- package/templates/nextjs/base/src/components/shared/birthday-picker.tsx +258 -0
- package/templates/nextjs/base/src/core/lib/auth.ts +162 -154
- package/templates/nextjs/base/src/core/lib/birthday.ts +74 -0
- package/templates/nextjs/base/src/core/lib/site-url.ts +42 -9
- package/templates/nextjs/base/src/core/lib/store-info.ts +10 -0
- package/templates/nextjs/base/src/ui/layout/newsletter-signup.tsx +143 -0
- package/templates/nextjs/base/src/ui/layout/site-footer.tsx.ejs +18 -2
- package/templates/nextjs/base/src/ui/product/back-in-stock-form.tsx +173 -0
- package/templates/nextjs/base/src/ui/product/product-client-section.tsx +484 -455
- package/templates/nextjs/base/src/ui/product/review-form.tsx +136 -12
- package/templates/nextjs/base/src/ui/product/reviews-section.tsx.ejs +139 -108
- package/templates/nextjs/designs/atelier/ui/layout/site-footer.tsx.ejs +155 -142
- package/templates/nextjs/designs/atelier/ui/product/product-client-section.tsx +500 -477
- package/templates/nextjs/designs/atelier/ui/product/review-form.tsx +135 -11
- package/templates/nextjs/designs/atelier/ui/product/reviews-section.tsx.ejs +179 -148
- package/templates/nextjs/ui-canvas/layout/newsletter-signup.tsx +122 -0
- package/templates/nextjs/ui-canvas/layout/site-footer.tsx.ejs +87 -83
- package/templates/nextjs/ui-canvas/product/back-in-stock-form.tsx +151 -0
- package/templates/nextjs/ui-canvas/product/product-client-section.tsx +373 -352
- package/templates/nextjs/ui-canvas/product/review-form.tsx +129 -11
- package/templates/nextjs/ui-canvas/product/reviews-section.tsx.ejs +127 -96
|
@@ -1,245 +1,326 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useState, useMemo } from 'react';
|
|
4
|
-
import { useTranslations } from '@/core/lib/translations';
|
|
5
|
-
import { cn } from '@/core/lib/utils';
|
|
6
|
-
import { LoadingSpinner } from '@/ui/shared/loading-spinner';
|
|
7
|
-
import { getPasswordError } from '@/core/lib/validation';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
return { label: '
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<div>
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useMemo } from 'react';
|
|
4
|
+
import { useTranslations } from '@/core/lib/translations';
|
|
5
|
+
import { cn } from '@/core/lib/utils';
|
|
6
|
+
import { LoadingSpinner } from '@/ui/shared/loading-spinner';
|
|
7
|
+
import { getPasswordError } from '@/core/lib/validation';
|
|
8
|
+
import { useStoreInfo } from '@/core/providers/store-provider';
|
|
9
|
+
import { toBirthdayNumber } from '@/core/lib/birthday';
|
|
10
|
+
import { BirthdayPicker } from '@/components/shared/birthday-picker';
|
|
11
|
+
|
|
12
|
+
interface RegisterData {
|
|
13
|
+
firstName: string;
|
|
14
|
+
lastName: string;
|
|
15
|
+
email: string;
|
|
16
|
+
password: string;
|
|
17
|
+
acceptsMarketing: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Birthday month and day, never a year. Sent together or left out entirely:
|
|
20
|
+
* one without the other is rejected with HTTP 400. Omitted rather than
|
|
21
|
+
* nulled when the shopper leaves the field empty, because `registerCustomer()`
|
|
22
|
+
* takes numbers only.
|
|
23
|
+
*/
|
|
24
|
+
birthMonth?: number;
|
|
25
|
+
birthDay?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface RegisterFormProps {
|
|
29
|
+
onSubmit: (data: RegisterData) => Promise<void>;
|
|
30
|
+
error?: string | null;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getPasswordStrength(password: string): { label: string; color: string; width: string } {
|
|
35
|
+
if (password.length === 0) return { label: '', color: '', width: 'w-0' };
|
|
36
|
+
if (password.length < 8) return { label: 'tooShort', color: 'bg-destructive', width: 'w-1/4' };
|
|
37
|
+
|
|
38
|
+
let score = 0;
|
|
39
|
+
if (password.length >= 8) score++;
|
|
40
|
+
if (/[A-Z]/.test(password)) score++;
|
|
41
|
+
if (/[0-9]/.test(password)) score++;
|
|
42
|
+
if (/[^A-Za-z0-9]/.test(password)) score++;
|
|
43
|
+
|
|
44
|
+
if (score <= 1) return { label: 'weak', color: 'bg-orange-500', width: 'w-1/3' };
|
|
45
|
+
if (score <= 2) return { label: 'fair', color: 'bg-yellow-500', width: 'w-1/2' };
|
|
46
|
+
if (score <= 3) return { label: 'good', color: 'bg-primary', width: 'w-3/4' };
|
|
47
|
+
return { label: 'strong', color: 'bg-green-500', width: 'w-full' };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function RegisterForm({ onSubmit, error, className }: RegisterFormProps) {
|
|
51
|
+
const t = useTranslations('auth');
|
|
52
|
+
const tf = useTranslations('checkoutForm');
|
|
53
|
+
const tc = useTranslations('common');
|
|
54
|
+
const { storeInfo } = useStoreInfo();
|
|
55
|
+
const [firstName, setFirstName] = useState('');
|
|
56
|
+
const [lastName, setLastName] = useState('');
|
|
57
|
+
const [email, setEmail] = useState('');
|
|
58
|
+
const [password, setPassword] = useState('');
|
|
59
|
+
const [privacyAccepted, setPrivacyAccepted] = useState(false);
|
|
60
|
+
const [privacyError, setPrivacyError] = useState(false);
|
|
61
|
+
const [passwordError, setPasswordError] = useState<string | null>(null);
|
|
62
|
+
const [acceptsMarketing, setAcceptsMarketing] = useState(false);
|
|
63
|
+
const [birthMonth, setBirthMonth] = useState('');
|
|
64
|
+
const [birthDay, setBirthDay] = useState('');
|
|
65
|
+
const [birthdayError, setBirthdayError] = useState<string | null>(null);
|
|
66
|
+
const [loading, setLoading] = useState(false);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The merchant can make the birthday mandatory at registration on this sales
|
|
70
|
+
* channel; the backend then rejects a register call without it. The flag is a
|
|
71
|
+
* rendering hint only, and absent means optional, so the fields stay optional
|
|
72
|
+
* unless it is explicitly true.
|
|
73
|
+
*/
|
|
74
|
+
const birthdayRequired = storeInfo?.requireBirthday === true;
|
|
75
|
+
|
|
76
|
+
const strength = useMemo(() => getPasswordStrength(password), [password]);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The picker hands back both halves at once, or two nulls when the shopper
|
|
80
|
+
* clears the field. State stays as strings so the submit path below is
|
|
81
|
+
* unchanged.
|
|
82
|
+
*/
|
|
83
|
+
function selectBirthday(month: number | null, day: number | null) {
|
|
84
|
+
setBirthMonth(month ? String(month) : '');
|
|
85
|
+
setBirthDay(day ? String(day) : '');
|
|
86
|
+
setBirthdayError(null);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function handleSubmit(e: React.FormEvent) {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
if (loading) return;
|
|
92
|
+
|
|
93
|
+
const pwCode = getPasswordError(password);
|
|
94
|
+
if (pwCode) {
|
|
95
|
+
setPasswordError(t(pwCode));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
setPasswordError(null);
|
|
99
|
+
|
|
100
|
+
const month = toBirthdayNumber(birthMonth);
|
|
101
|
+
const day = toBirthdayNumber(birthDay);
|
|
102
|
+
|
|
103
|
+
if (birthdayRequired && (month === null || day === null)) {
|
|
104
|
+
setBirthdayError(tc('birthdayRequired'));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// Half a birthday is an HTTP 400 at the API, so catch it here rather than
|
|
108
|
+
// letting the shopper find out from a failed registration.
|
|
109
|
+
if ((month === null) !== (day === null)) {
|
|
110
|
+
setBirthdayError(tc('birthdayIncomplete'));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
setBirthdayError(null);
|
|
114
|
+
|
|
115
|
+
if (!privacyAccepted) {
|
|
116
|
+
setPrivacyError(true);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
setLoading(true);
|
|
122
|
+
await onSubmit({
|
|
123
|
+
firstName,
|
|
124
|
+
lastName,
|
|
125
|
+
email,
|
|
126
|
+
password,
|
|
127
|
+
acceptsMarketing,
|
|
128
|
+
// Omitted, never nulled, when the shopper left the field empty:
|
|
129
|
+
// `registerCustomer()` takes numbers only.
|
|
130
|
+
...(month !== null && day !== null ? { birthMonth: month, birthDay: day } : {}),
|
|
131
|
+
});
|
|
132
|
+
} finally {
|
|
133
|
+
setLoading(false);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<form onSubmit={handleSubmit} className={cn('space-y-4', className)}>
|
|
139
|
+
{error && (
|
|
140
|
+
<div className="bg-destructive/10 border-destructive/20 text-destructive rounded-lg border px-4 py-3 text-sm">
|
|
141
|
+
{error}
|
|
142
|
+
</div>
|
|
143
|
+
)}
|
|
144
|
+
|
|
145
|
+
<div className="grid grid-cols-2 gap-3">
|
|
146
|
+
<div>
|
|
147
|
+
<label
|
|
148
|
+
htmlFor="register-first-name"
|
|
149
|
+
className="text-foreground mb-1.5 block text-sm font-medium"
|
|
150
|
+
>
|
|
151
|
+
{tf('firstName')}
|
|
152
|
+
</label>
|
|
153
|
+
<input
|
|
154
|
+
id="register-first-name"
|
|
155
|
+
type="text"
|
|
156
|
+
required
|
|
157
|
+
value={firstName}
|
|
158
|
+
onChange={(e) => setFirstName(e.target.value)}
|
|
159
|
+
placeholder={t('firstNamePlaceholder')}
|
|
160
|
+
autoComplete="given-name"
|
|
161
|
+
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"
|
|
162
|
+
/>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<div>
|
|
166
|
+
<label
|
|
167
|
+
htmlFor="register-last-name"
|
|
168
|
+
className="text-foreground mb-1.5 block text-sm font-medium"
|
|
169
|
+
>
|
|
170
|
+
{tf('lastName')}
|
|
171
|
+
</label>
|
|
172
|
+
<input
|
|
173
|
+
id="register-last-name"
|
|
174
|
+
type="text"
|
|
175
|
+
required
|
|
176
|
+
value={lastName}
|
|
177
|
+
onChange={(e) => setLastName(e.target.value)}
|
|
178
|
+
placeholder={t('lastNamePlaceholder')}
|
|
179
|
+
autoComplete="family-name"
|
|
180
|
+
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"
|
|
181
|
+
/>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<div>
|
|
186
|
+
<label
|
|
187
|
+
htmlFor="register-email"
|
|
188
|
+
className="text-foreground mb-1.5 block text-sm font-medium"
|
|
189
|
+
>
|
|
190
|
+
{t('email')}
|
|
191
|
+
</label>
|
|
192
|
+
<input
|
|
193
|
+
id="register-email"
|
|
194
|
+
type="email"
|
|
195
|
+
required
|
|
196
|
+
value={email}
|
|
197
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
198
|
+
placeholder={t('emailPlaceholder')}
|
|
199
|
+
autoComplete="email"
|
|
200
|
+
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"
|
|
201
|
+
/>
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
<div>
|
|
205
|
+
<label
|
|
206
|
+
htmlFor="register-password"
|
|
207
|
+
className="text-foreground mb-1.5 block text-sm font-medium"
|
|
208
|
+
>
|
|
209
|
+
{t('password')}
|
|
210
|
+
</label>
|
|
211
|
+
<input
|
|
212
|
+
id="register-password"
|
|
213
|
+
type="password"
|
|
214
|
+
required
|
|
215
|
+
minLength={8}
|
|
216
|
+
value={password}
|
|
217
|
+
onChange={(e) => {
|
|
218
|
+
setPassword(e.target.value);
|
|
219
|
+
if (passwordError) setPasswordError(null);
|
|
220
|
+
}}
|
|
221
|
+
placeholder={t('atLeastChars')}
|
|
222
|
+
autoComplete="new-password"
|
|
223
|
+
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"
|
|
224
|
+
/>
|
|
225
|
+
{password.length > 0 && (
|
|
226
|
+
<div className="mt-2">
|
|
227
|
+
<div className="bg-muted h-1.5 w-full overflow-hidden rounded-full">
|
|
228
|
+
<div
|
|
229
|
+
className={cn(
|
|
230
|
+
'h-full rounded-full transition-all duration-300',
|
|
231
|
+
strength.color,
|
|
232
|
+
strength.width
|
|
233
|
+
)}
|
|
234
|
+
/>
|
|
235
|
+
</div>
|
|
236
|
+
<p className="text-muted-foreground mt-1 text-xs">
|
|
237
|
+
{strength.label
|
|
238
|
+
? t(strength.label as 'tooShort' | 'weak' | 'fair' | 'good' | 'strong')
|
|
239
|
+
: ''}
|
|
240
|
+
</p>
|
|
241
|
+
</div>
|
|
242
|
+
)}
|
|
243
|
+
{passwordError && <p className="text-destructive mt-1 text-xs">{passwordError}</p>}
|
|
244
|
+
</div>
|
|
245
|
+
|
|
246
|
+
{/* Birthday: month and day only, never a year. Optional unless the
|
|
247
|
+
merchant made it mandatory on this sales channel. */}
|
|
248
|
+
<div>
|
|
249
|
+
<label
|
|
250
|
+
htmlFor="register-birthday"
|
|
251
|
+
className="text-foreground mb-1.5 block text-sm font-medium"
|
|
252
|
+
>
|
|
253
|
+
{tc('birthday')}
|
|
254
|
+
{birthdayRequired && <span className="text-destructive"> *</span>}
|
|
255
|
+
</label>
|
|
256
|
+
<BirthdayPicker
|
|
257
|
+
id="register-birthday"
|
|
258
|
+
month={toBirthdayNumber(birthMonth)}
|
|
259
|
+
day={toBirthdayNumber(birthDay)}
|
|
260
|
+
onChange={selectBirthday}
|
|
261
|
+
required={birthdayRequired}
|
|
262
|
+
invalid={birthdayError !== null}
|
|
263
|
+
/>
|
|
264
|
+
<p className="text-muted-foreground mt-1.5 text-xs">{tc('birthdayGiftNote')}</p>
|
|
265
|
+
{birthdayError && <p className="text-destructive mt-1 text-xs">{birthdayError}</p>}
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
{/* Privacy Policy (required) */}
|
|
269
|
+
<div>
|
|
270
|
+
<label className="flex cursor-pointer items-start gap-2">
|
|
271
|
+
<input
|
|
272
|
+
type="checkbox"
|
|
273
|
+
checked={privacyAccepted}
|
|
274
|
+
onChange={(e) => {
|
|
275
|
+
setPrivacyAccepted(e.target.checked);
|
|
276
|
+
setPrivacyError(false);
|
|
277
|
+
}}
|
|
278
|
+
className="accent-primary mt-0.5"
|
|
279
|
+
/>
|
|
280
|
+
<span className="text-muted-foreground text-sm">
|
|
281
|
+
{t('privacyAcceptPrefix')}{' '}
|
|
282
|
+
<a
|
|
283
|
+
href="/privacy"
|
|
284
|
+
target="_blank"
|
|
285
|
+
rel="noopener noreferrer"
|
|
286
|
+
className="text-primary underline underline-offset-2"
|
|
287
|
+
>
|
|
288
|
+
{t('privacyPolicyLink')}
|
|
289
|
+
</a>{' '}
|
|
290
|
+
<span className="text-destructive">*</span>
|
|
291
|
+
</span>
|
|
292
|
+
</label>
|
|
293
|
+
{privacyError && <p className="text-destructive mt-1 text-xs">{t('privacyRequired')}</p>}
|
|
294
|
+
</div>
|
|
295
|
+
|
|
296
|
+
{/* Marketing consent (optional) */}
|
|
297
|
+
<label className="flex cursor-pointer items-start gap-2">
|
|
298
|
+
<input
|
|
299
|
+
type="checkbox"
|
|
300
|
+
checked={acceptsMarketing}
|
|
301
|
+
onChange={(e) => setAcceptsMarketing(e.target.checked)}
|
|
302
|
+
className="accent-primary mt-0.5"
|
|
303
|
+
/>
|
|
304
|
+
<span className="text-muted-foreground text-sm">{t('acceptsMarketing')}</span>
|
|
305
|
+
</label>
|
|
306
|
+
|
|
307
|
+
<button
|
|
308
|
+
type="submit"
|
|
309
|
+
disabled={loading}
|
|
310
|
+
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"
|
|
311
|
+
>
|
|
312
|
+
{loading ? (
|
|
313
|
+
<>
|
|
314
|
+
<LoadingSpinner
|
|
315
|
+
size="sm"
|
|
316
|
+
className="border-primary-foreground/30 border-t-primary-foreground"
|
|
317
|
+
/>
|
|
318
|
+
{t('creatingAccount')}
|
|
319
|
+
</>
|
|
320
|
+
) : (
|
|
321
|
+
t('createAccount')
|
|
322
|
+
)}
|
|
323
|
+
</button>
|
|
324
|
+
</form>
|
|
325
|
+
);
|
|
326
|
+
}
|