create-brainerce-store 1.74.0 → 1.76.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.
@@ -1,326 +1,358 @@
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
- }
1
+ 'use client';
2
+
3
+ import { useState, useMemo, useEffect } 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
+ import { readReferralCookie } from '@/core/lib/referral';
12
+
13
+ interface RegisterData {
14
+ firstName: string;
15
+ lastName: string;
16
+ email: string;
17
+ password: string;
18
+ acceptsMarketing: boolean;
19
+ /**
20
+ * Birthday month and day, never a year. Sent together or left out entirely:
21
+ * one without the other is rejected with HTTP 400. Omitted rather than
22
+ * nulled when the shopper leaves the field empty, because `registerCustomer()`
23
+ * takes numbers only.
24
+ */
25
+ birthMonth?: number;
26
+ birthDay?: number;
27
+ /**
28
+ * Loyalty referral share code, captured from a `?ref=` link that may have
29
+ * been clicked days ago. Omitted when nothing was captured; never invented.
30
+ */
31
+ referralCode?: string;
32
+ }
33
+
34
+ interface RegisterFormProps {
35
+ onSubmit: (data: RegisterData) => Promise<void>;
36
+ error?: string | null;
37
+ className?: string;
38
+ }
39
+
40
+ function getPasswordStrength(password: string): { label: string; color: string; width: string } {
41
+ if (password.length === 0) return { label: '', color: '', width: 'w-0' };
42
+ if (password.length < 8) return { label: 'tooShort', color: 'bg-destructive', width: 'w-1/4' };
43
+
44
+ let score = 0;
45
+ if (password.length >= 8) score++;
46
+ if (/[A-Z]/.test(password)) score++;
47
+ if (/[0-9]/.test(password)) score++;
48
+ if (/[^A-Za-z0-9]/.test(password)) score++;
49
+
50
+ if (score <= 1) return { label: 'weak', color: 'bg-orange-500', width: 'w-1/3' };
51
+ if (score <= 2) return { label: 'fair', color: 'bg-yellow-500', width: 'w-1/2' };
52
+ if (score <= 3) return { label: 'good', color: 'bg-primary', width: 'w-3/4' };
53
+ return { label: 'strong', color: 'bg-green-500', width: 'w-full' };
54
+ }
55
+
56
+ export function RegisterForm({ onSubmit, error, className }: RegisterFormProps) {
57
+ const t = useTranslations('auth');
58
+ const tf = useTranslations('checkoutForm');
59
+ const tc = useTranslations('common');
60
+ const { storeInfo } = useStoreInfo();
61
+ const [firstName, setFirstName] = useState('');
62
+ const [lastName, setLastName] = useState('');
63
+ const [email, setEmail] = useState('');
64
+ const [password, setPassword] = useState('');
65
+ const [privacyAccepted, setPrivacyAccepted] = useState(false);
66
+ const [privacyError, setPrivacyError] = useState(false);
67
+ const [passwordError, setPasswordError] = useState<string | null>(null);
68
+ const [acceptsMarketing, setAcceptsMarketing] = useState(false);
69
+ const [birthMonth, setBirthMonth] = useState('');
70
+ const [birthDay, setBirthDay] = useState('');
71
+ const [birthdayError, setBirthdayError] = useState<string | null>(null);
72
+ const [loading, setLoading] = useState(false);
73
+ const [referralCode, setReferralCode] = useState<string | null>(null);
74
+
75
+ /**
76
+ * A referral code captured from a `?ref=` link, possibly on a different day.
77
+ * Read in an effect rather than during render because it comes from
78
+ * `document.cookie`, which does not exist during SSR: reading it inline would
79
+ * render one thing on the server and another on the client and trip a
80
+ * hydration mismatch.
81
+ */
82
+ useEffect(() => {
83
+ setReferralCode(readReferralCookie());
84
+ }, []);
85
+
86
+ /**
87
+ * The merchant can make the birthday mandatory at registration on this sales
88
+ * channel; the backend then rejects a register call without it. The flag is a
89
+ * rendering hint only, and absent means optional, so the fields stay optional
90
+ * unless it is explicitly true.
91
+ */
92
+ const birthdayRequired = storeInfo?.requireBirthday === true;
93
+
94
+ const strength = useMemo(() => getPasswordStrength(password), [password]);
95
+
96
+ /**
97
+ * The picker hands back both halves at once, or two nulls when the shopper
98
+ * clears the field. State stays as strings so the submit path below is
99
+ * unchanged.
100
+ */
101
+ function selectBirthday(month: number | null, day: number | null) {
102
+ setBirthMonth(month ? String(month) : '');
103
+ setBirthDay(day ? String(day) : '');
104
+ setBirthdayError(null);
105
+ }
106
+
107
+ async function handleSubmit(e: React.FormEvent) {
108
+ e.preventDefault();
109
+ if (loading) return;
110
+
111
+ const pwCode = getPasswordError(password);
112
+ if (pwCode) {
113
+ setPasswordError(t(pwCode));
114
+ return;
115
+ }
116
+ setPasswordError(null);
117
+
118
+ const month = toBirthdayNumber(birthMonth);
119
+ const day = toBirthdayNumber(birthDay);
120
+
121
+ if (birthdayRequired && (month === null || day === null)) {
122
+ setBirthdayError(tc('birthdayRequired'));
123
+ return;
124
+ }
125
+ // Half a birthday is an HTTP 400 at the API, so catch it here rather than
126
+ // letting the shopper find out from a failed registration.
127
+ if ((month === null) !== (day === null)) {
128
+ setBirthdayError(tc('birthdayIncomplete'));
129
+ return;
130
+ }
131
+ setBirthdayError(null);
132
+
133
+ if (!privacyAccepted) {
134
+ setPrivacyError(true);
135
+ return;
136
+ }
137
+
138
+ try {
139
+ setLoading(true);
140
+ await onSubmit({
141
+ firstName,
142
+ lastName,
143
+ email,
144
+ password,
145
+ acceptsMarketing,
146
+ // Omitted, never nulled, when the shopper left the field empty:
147
+ // `registerCustomer()` takes numbers only.
148
+ ...(month !== null && day !== null ? { birthMonth: month, birthDay: day } : {}),
149
+ // Same rule for the referral: send it only when one was captured. The
150
+ // API validates it after the fact, so a stale code cannot cost this
151
+ // shopper their registration.
152
+ ...(referralCode ? { referralCode } : {}),
153
+ });
154
+ } finally {
155
+ setLoading(false);
156
+ }
157
+ }
158
+
159
+ return (
160
+ <form onSubmit={handleSubmit} className={cn('space-y-4', className)}>
161
+ {error && (
162
+ <div className="bg-destructive/10 border-destructive/20 text-destructive rounded-lg border px-4 py-3 text-sm">
163
+ {error}
164
+ </div>
165
+ )}
166
+
167
+ {/* A referral captured earlier is about to be applied. Worth saying out
168
+ loud: the shopper was promised a welcome gift on a page they may have
169
+ left days ago, and silence here reads as the offer having expired.
170
+ Renders nothing when no code was captured. */}
171
+ {referralCode && (
172
+ <p className="border-primary/20 bg-primary/5 text-muted-foreground rounded-lg border px-4 py-3 text-sm">
173
+ {t('referralApplied')}
174
+ </p>
175
+ )}
176
+
177
+ <div className="grid grid-cols-2 gap-3">
178
+ <div>
179
+ <label
180
+ htmlFor="register-first-name"
181
+ className="text-foreground mb-1.5 block text-sm font-medium"
182
+ >
183
+ {tf('firstName')}
184
+ </label>
185
+ <input
186
+ id="register-first-name"
187
+ type="text"
188
+ required
189
+ value={firstName}
190
+ onChange={(e) => setFirstName(e.target.value)}
191
+ placeholder={t('firstNamePlaceholder')}
192
+ autoComplete="given-name"
193
+ 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"
194
+ />
195
+ </div>
196
+
197
+ <div>
198
+ <label
199
+ htmlFor="register-last-name"
200
+ className="text-foreground mb-1.5 block text-sm font-medium"
201
+ >
202
+ {tf('lastName')}
203
+ </label>
204
+ <input
205
+ id="register-last-name"
206
+ type="text"
207
+ required
208
+ value={lastName}
209
+ onChange={(e) => setLastName(e.target.value)}
210
+ placeholder={t('lastNamePlaceholder')}
211
+ autoComplete="family-name"
212
+ 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"
213
+ />
214
+ </div>
215
+ </div>
216
+
217
+ <div>
218
+ <label
219
+ htmlFor="register-email"
220
+ className="text-foreground mb-1.5 block text-sm font-medium"
221
+ >
222
+ {t('email')}
223
+ </label>
224
+ <input
225
+ id="register-email"
226
+ type="email"
227
+ required
228
+ value={email}
229
+ onChange={(e) => setEmail(e.target.value)}
230
+ placeholder={t('emailPlaceholder')}
231
+ autoComplete="email"
232
+ 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"
233
+ />
234
+ </div>
235
+
236
+ <div>
237
+ <label
238
+ htmlFor="register-password"
239
+ className="text-foreground mb-1.5 block text-sm font-medium"
240
+ >
241
+ {t('password')}
242
+ </label>
243
+ <input
244
+ id="register-password"
245
+ type="password"
246
+ required
247
+ minLength={8}
248
+ value={password}
249
+ onChange={(e) => {
250
+ setPassword(e.target.value);
251
+ if (passwordError) setPasswordError(null);
252
+ }}
253
+ placeholder={t('atLeastChars')}
254
+ autoComplete="new-password"
255
+ 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"
256
+ />
257
+ {password.length > 0 && (
258
+ <div className="mt-2">
259
+ <div className="bg-muted h-1.5 w-full overflow-hidden rounded-full">
260
+ <div
261
+ className={cn(
262
+ 'h-full rounded-full transition-all duration-300',
263
+ strength.color,
264
+ strength.width
265
+ )}
266
+ />
267
+ </div>
268
+ <p className="text-muted-foreground mt-1 text-xs">
269
+ {strength.label
270
+ ? t(strength.label as 'tooShort' | 'weak' | 'fair' | 'good' | 'strong')
271
+ : ''}
272
+ </p>
273
+ </div>
274
+ )}
275
+ {passwordError && <p className="text-destructive mt-1 text-xs">{passwordError}</p>}
276
+ </div>
277
+
278
+ {/* Birthday: month and day only, never a year. Optional unless the
279
+ merchant made it mandatory on this sales channel. */}
280
+ <div>
281
+ <label
282
+ htmlFor="register-birthday"
283
+ className="text-foreground mb-1.5 block text-sm font-medium"
284
+ >
285
+ {tc('birthday')}
286
+ {birthdayRequired && <span className="text-destructive"> *</span>}
287
+ </label>
288
+ <BirthdayPicker
289
+ id="register-birthday"
290
+ month={toBirthdayNumber(birthMonth)}
291
+ day={toBirthdayNumber(birthDay)}
292
+ onChange={selectBirthday}
293
+ required={birthdayRequired}
294
+ invalid={birthdayError !== null}
295
+ />
296
+ <p className="text-muted-foreground mt-1.5 text-xs">{tc('birthdayGiftNote')}</p>
297
+ {birthdayError && <p className="text-destructive mt-1 text-xs">{birthdayError}</p>}
298
+ </div>
299
+
300
+ {/* Privacy Policy (required) */}
301
+ <div>
302
+ <label className="flex cursor-pointer items-start gap-2">
303
+ <input
304
+ type="checkbox"
305
+ checked={privacyAccepted}
306
+ onChange={(e) => {
307
+ setPrivacyAccepted(e.target.checked);
308
+ setPrivacyError(false);
309
+ }}
310
+ className="accent-primary mt-0.5"
311
+ />
312
+ <span className="text-muted-foreground text-sm">
313
+ {t('privacyAcceptPrefix')}{' '}
314
+ <a
315
+ href="/privacy"
316
+ target="_blank"
317
+ rel="noopener noreferrer"
318
+ className="text-primary underline underline-offset-2"
319
+ >
320
+ {t('privacyPolicyLink')}
321
+ </a>{' '}
322
+ <span className="text-destructive">*</span>
323
+ </span>
324
+ </label>
325
+ {privacyError && <p className="text-destructive mt-1 text-xs">{t('privacyRequired')}</p>}
326
+ </div>
327
+
328
+ {/* Marketing consent (optional) */}
329
+ <label className="flex cursor-pointer items-start gap-2">
330
+ <input
331
+ type="checkbox"
332
+ checked={acceptsMarketing}
333
+ onChange={(e) => setAcceptsMarketing(e.target.checked)}
334
+ className="accent-primary mt-0.5"
335
+ />
336
+ <span className="text-muted-foreground text-sm">{t('acceptsMarketing')}</span>
337
+ </label>
338
+
339
+ <button
340
+ type="submit"
341
+ disabled={loading}
342
+ 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"
343
+ >
344
+ {loading ? (
345
+ <>
346
+ <LoadingSpinner
347
+ size="sm"
348
+ className="border-primary-foreground/30 border-t-primary-foreground"
349
+ />
350
+ {t('creatingAccount')}
351
+ </>
352
+ ) : (
353
+ t('createAccount')
354
+ )}
355
+ </button>
356
+ </form>
357
+ );
358
+ }