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.
Files changed (40) hide show
  1. package/dist/index.js +22 -2
  2. package/messages/en.json +52 -2
  3. package/messages/he.json +52 -2
  4. package/package.json +1 -1
  5. package/templates/nextjs/base/.env.local.ejs +7 -0
  6. package/templates/nextjs/base/AGENTS.md.ejs +7 -0
  7. package/templates/nextjs/base/CLAUDE.md.ejs +7 -0
  8. package/templates/nextjs/base/src/app/blog/[slug]/page.tsx.ejs +8 -2
  9. package/templates/nextjs/base/src/app/category/[slug]/page.tsx +16 -7
  10. package/templates/nextjs/base/src/app/checkout/page.tsx +1018 -1017
  11. package/templates/nextjs/base/src/app/error.tsx.ejs +53 -0
  12. package/templates/nextjs/base/src/app/pages/[slug]/page.tsx.ejs +8 -2
  13. package/templates/nextjs/base/src/app/products/[slug]/page.tsx +17 -7
  14. package/templates/nextjs/base/src/app/register/page.tsx +67 -64
  15. package/templates/nextjs/base/src/components/account/profile-section.tsx +303 -226
  16. package/templates/nextjs/base/src/components/auth/register-form.tsx +326 -245
  17. package/templates/nextjs/base/src/components/checkout/custom-fields-step.tsx +306 -294
  18. package/templates/nextjs/base/src/components/checkout/date-picker.tsx +13 -1
  19. package/templates/nextjs/base/src/components/checkout/datetime-picker.tsx +61 -21
  20. package/templates/nextjs/base/src/components/shared/birthday-picker.tsx +258 -0
  21. package/templates/nextjs/base/src/core/lib/auth.ts +162 -154
  22. package/templates/nextjs/base/src/core/lib/birthday.ts +74 -0
  23. package/templates/nextjs/base/src/core/lib/site-url.ts +42 -9
  24. package/templates/nextjs/base/src/core/lib/store-info.ts +10 -0
  25. package/templates/nextjs/base/src/ui/layout/newsletter-signup.tsx +143 -0
  26. package/templates/nextjs/base/src/ui/layout/site-footer.tsx.ejs +18 -2
  27. package/templates/nextjs/base/src/ui/product/back-in-stock-form.tsx +173 -0
  28. package/templates/nextjs/base/src/ui/product/product-client-section.tsx +484 -455
  29. package/templates/nextjs/base/src/ui/product/review-form.tsx +136 -12
  30. package/templates/nextjs/base/src/ui/product/reviews-section.tsx.ejs +139 -108
  31. package/templates/nextjs/designs/atelier/ui/layout/site-footer.tsx.ejs +155 -142
  32. package/templates/nextjs/designs/atelier/ui/product/product-client-section.tsx +500 -477
  33. package/templates/nextjs/designs/atelier/ui/product/review-form.tsx +135 -11
  34. package/templates/nextjs/designs/atelier/ui/product/reviews-section.tsx.ejs +179 -148
  35. package/templates/nextjs/ui-canvas/layout/newsletter-signup.tsx +122 -0
  36. package/templates/nextjs/ui-canvas/layout/site-footer.tsx.ejs +87 -83
  37. package/templates/nextjs/ui-canvas/product/back-in-stock-form.tsx +151 -0
  38. package/templates/nextjs/ui-canvas/product/product-client-section.tsx +373 -352
  39. package/templates/nextjs/ui-canvas/product/review-form.tsx +129 -11
  40. package/templates/nextjs/ui-canvas/product/reviews-section.tsx.ejs +127 -96
@@ -1,294 +1,306 @@
1
- 'use client';
2
-
3
- import { useState } from 'react';
4
- import type { CheckoutCustomFieldDefinition } from 'brainerce';
5
- import { useTranslations } from '@/core/lib/translations';
6
- import { cn } from '@/core/lib/utils';
7
- import { DatePicker } from '@/components/checkout/date-picker';
8
- import { DateTimePicker } from '@/components/checkout/datetime-picker';
9
-
10
- /** Inline, dependency-free — this file lives in the base template and must
11
- * not assume any design pack (e.g. Atelier's icon set) is present; canvas
12
- * scaffolds skip design packs entirely. */
13
- const INPUT_CLASS =
14
- 'h-11 w-full rounded-lg border bg-background px-3.5 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary';
15
-
16
- interface CustomFieldsStepProps {
17
- fields: CheckoutCustomFieldDefinition[];
18
- values: Record<string, unknown>;
19
- onChange: (key: string, value: unknown) => void;
20
- onApply: () => void;
21
- onUploadFile?: (file: File) => Promise<{ url: string; key: string }>;
22
- loading?: boolean;
23
- className?: string;
24
- }
25
-
26
- const MAX_IMAGE_SIZE = 5 * 1024 * 1024; // 5 MB
27
- const ACCEPTED_IMAGE_TYPES = 'image/jpeg,image/png,image/webp,image/gif';
28
-
29
- export function CustomFieldsStep({
30
- fields,
31
- values,
32
- onChange,
33
- onApply,
34
- onUploadFile,
35
- loading = false,
36
- className,
37
- }: CustomFieldsStepProps) {
38
- const t = useTranslations('checkout');
39
- const [uploadingKeys, setUploadingKeys] = useState<Set<string>>(new Set());
40
-
41
- const isMissing = fields.some((f) => {
42
- if (!f.required) return false;
43
- const v = values[f.key];
44
- return v === undefined || v === null || v === '';
45
- });
46
-
47
- return (
48
- <div className={cn('space-y-4', className)}>
49
- <p className="text-muted-foreground text-sm">{t('customFieldsSubtitle')}</p>
50
-
51
- {fields.map((field) => {
52
- const value = values[field.key];
53
- const labelEl = (
54
- <label
55
- htmlFor={`cf-${field.key}`}
56
- className="text-foreground mb-1 block text-sm font-medium"
57
- >
58
- {field.name}
59
- {field.required && <span className="text-destructive ms-1">*</span>}
60
- </label>
61
- );
62
- const helpEl = field.description ? (
63
- <p className="text-muted-foreground mt-1 whitespace-pre-line text-xs">
64
- {field.description}
65
- </p>
66
- ) : null;
67
-
68
- switch (field.type) {
69
- case 'TEXT':
70
- return (
71
- <div key={field.key}>
72
- {labelEl}
73
- <input
74
- id={`cf-${field.key}`}
75
- type="text"
76
- value={(value as string) ?? ''}
77
- onChange={(e) => onChange(field.key, e.target.value)}
78
- required={field.required}
79
- minLength={field.minLength ?? undefined}
80
- maxLength={field.maxLength ?? undefined}
81
- className={INPUT_CLASS}
82
- />
83
- {helpEl}
84
- </div>
85
- );
86
-
87
- case 'TEXTAREA':
88
- return (
89
- <div key={field.key}>
90
- {labelEl}
91
- <textarea
92
- id={`cf-${field.key}`}
93
- value={(value as string) ?? ''}
94
- onChange={(e) => onChange(field.key, e.target.value)}
95
- required={field.required}
96
- minLength={field.minLength ?? undefined}
97
- maxLength={field.maxLength ?? undefined}
98
- rows={3}
99
- className="border-border bg-background text-foreground placeholder:text-muted-foreground focus-visible:ring-primary w-full rounded-lg border px-3.5 py-2.5 text-sm focus-visible:outline-none focus-visible:ring-2"
100
- />
101
- {helpEl}
102
- </div>
103
- );
104
-
105
- case 'NUMBER':
106
- return (
107
- <div key={field.key}>
108
- {labelEl}
109
- <input
110
- id={`cf-${field.key}`}
111
- type="number"
112
- value={(value as number | string) ?? ''}
113
- onChange={(e) =>
114
- onChange(field.key, e.target.value === '' ? '' : Number(e.target.value))
115
- }
116
- required={field.required}
117
- min={field.minValue ?? undefined}
118
- max={field.maxValue ?? undefined}
119
- className={INPUT_CLASS}
120
- />
121
- {helpEl}
122
- </div>
123
- );
124
-
125
- case 'BOOLEAN':
126
- return (
127
- <div key={field.key} className="flex items-start gap-2">
128
- <input
129
- id={`cf-${field.key}`}
130
- type="checkbox"
131
- checked={value === true}
132
- onChange={(e) => onChange(field.key, e.target.checked)}
133
- className="mt-1"
134
- />
135
- <div className="flex-1">
136
- <label
137
- htmlFor={`cf-${field.key}`}
138
- className="text-foreground text-sm font-medium"
139
- >
140
- {field.name}
141
- {field.required && <span className="text-destructive ms-1">*</span>}
142
- </label>
143
- {helpEl}
144
- </div>
145
- </div>
146
- );
147
-
148
- case 'SELECT':
149
- return (
150
- <div key={field.key}>
151
- {labelEl}
152
- <select
153
- id={`cf-${field.key}`}
154
- value={(value as string) ?? ''}
155
- onChange={(e) => onChange(field.key, e.target.value)}
156
- required={field.required}
157
- className={INPUT_CLASS}
158
- >
159
- <option value="">{t('customFieldsSelectPlaceholder')}</option>
160
- {field.options?.map((opt) => (
161
- <option key={opt.value} value={opt.value}>
162
- {opt.label}
163
- </option>
164
- ))}
165
- </select>
166
- {helpEl}
167
- </div>
168
- );
169
-
170
- case 'DATE':
171
- return (
172
- <div key={field.key}>
173
- {labelEl}
174
- <DatePicker
175
- id={`cf-${field.key}`}
176
- value={(value as string) ?? ''}
177
- onChange={(v) => onChange(field.key, v)}
178
- required={field.required}
179
- availability={field.dateAvailability}
180
- placeholder={t('customFieldsDatePlaceholder')}
181
- todayLabel={t('customFieldsDateToday')}
182
- clearLabel={t('customFieldsDateClear')}
183
- prevMonthLabel={t('customFieldsDatePrevMonth')}
184
- nextMonthLabel={t('customFieldsDateNextMonth')}
185
- />
186
- {helpEl}
187
- </div>
188
- );
189
-
190
- case 'DATETIME':
191
- return (
192
- <div key={field.key}>
193
- {labelEl}
194
- <DateTimePicker
195
- id={`cf-${field.key}`}
196
- value={(value as string) ?? ''}
197
- onChange={(v) => onChange(field.key, v)}
198
- required={field.required}
199
- availability={field.dateAvailability}
200
- placeholder={t('customFieldsDatePlaceholder')}
201
- todayLabel={t('customFieldsDateToday')}
202
- clearLabel={t('customFieldsDateClear')}
203
- prevMonthLabel={t('customFieldsDatePrevMonth')}
204
- nextMonthLabel={t('customFieldsDateNextMonth')}
205
- timeLabel={t('customFieldsTimeLabel')}
206
- closedLabel={t('customFieldsTimeClosed')}
207
- />
208
- {helpEl}
209
- </div>
210
- );
211
-
212
- case 'IMAGE': {
213
- const isUploading = uploadingKeys.has(field.key);
214
- return (
215
- <div key={field.key}>
216
- {labelEl}
217
- {value ? (
218
- <div className="relative inline-block">
219
- <img
220
- src={value as string}
221
- alt={field.name}
222
- className="border-border max-h-32 rounded border object-contain"
223
- />
224
- <button
225
- type="button"
226
- onClick={() => onChange(field.key, '')}
227
- className="bg-background/80 text-foreground absolute end-1 top-1 rounded-full p-1 text-xs leading-none"
228
- aria-label={t('customFieldsImageRemove')}
229
- >
230
-
231
- </button>
232
- </div>
233
- ) : (
234
- <label
235
- htmlFor={`cf-${field.key}`}
236
- className={cn(
237
- 'border-border flex cursor-pointer flex-col items-center gap-2 rounded border-2 border-dashed p-6 text-center transition-colors',
238
- isUploading ? 'opacity-50' : 'hover:border-primary/40'
239
- )}
240
- >
241
- <span className="text-muted-foreground text-sm">
242
- {isUploading ? t('customFieldsImageUploading') : t('customFieldsImageUpload')}
243
- </span>
244
- <input
245
- id={`cf-${field.key}`}
246
- type="file"
247
- accept={ACCEPTED_IMAGE_TYPES}
248
- disabled={isUploading || !onUploadFile}
249
- className="hidden"
250
- onChange={async (e) => {
251
- const file = e.target.files?.[0];
252
- if (!file || !onUploadFile) return;
253
- if (file.size > MAX_IMAGE_SIZE) {
254
- alert(t('customFieldsImageTooLarge'));
255
- return;
256
- }
257
- setUploadingKeys((prev) => new Set(prev).add(field.key));
258
- try {
259
- const result = await onUploadFile(file);
260
- onChange(field.key, result.url);
261
- } catch {
262
- // Upload failed — user can retry
263
- } finally {
264
- setUploadingKeys((prev) => {
265
- const next = new Set(prev);
266
- next.delete(field.key);
267
- return next;
268
- });
269
- }
270
- }}
271
- />
272
- </label>
273
- )}
274
- {helpEl}
275
- </div>
276
- );
277
- }
278
-
279
- default:
280
- return null;
281
- }
282
- })}
283
-
284
- <button
285
- type="button"
286
- onClick={onApply}
287
- disabled={loading || isMissing}
288
- className="bg-primary text-primary-foreground hover:bg-primary/90 inline-flex h-12 w-full select-none items-center justify-center gap-2 whitespace-nowrap rounded-full px-8 text-base font-semibold transition-colors duration-200 disabled:pointer-events-none disabled:opacity-50"
289
- >
290
- {loading ? t('customFieldsApplying') : t('customFieldsApply')}
291
- </button>
292
- </div>
293
- );
294
- }
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+ import type { CheckoutCustomFieldDefinition } from 'brainerce';
5
+ import { useTranslations } from '@/core/lib/translations';
6
+ import { cn } from '@/core/lib/utils';
7
+ import { DatePicker } from '@/components/checkout/date-picker';
8
+ import { DateTimePicker } from '@/components/checkout/datetime-picker';
9
+
10
+ /** Inline, dependency-free — this file lives in the base template and must
11
+ * not assume any design pack (e.g. Atelier's icon set) is present; canvas
12
+ * scaffolds skip design packs entirely. */
13
+ const INPUT_CLASS =
14
+ 'h-11 w-full rounded-lg border bg-background px-3.5 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary';
15
+
16
+ interface CustomFieldsStepProps {
17
+ fields: CheckoutCustomFieldDefinition[];
18
+ values: Record<string, unknown>;
19
+ onChange: (key: string, value: unknown) => void;
20
+ onApply: () => void;
21
+ onUploadFile?: (file: File) => Promise<{ url: string; key: string }>;
22
+ /**
23
+ * The store's IANA timezone (`storeInfo.timezone`). DATE/DATETIME fields need
24
+ * it to apply a field's leadTimeMinutes/cutoffTime/maxDaysAhead: the SDK
25
+ * skips those bounds when no clock reaches it, so the picker would offer days
26
+ * the API rejects.
27
+ */
28
+ timezone?: string;
29
+ loading?: boolean;
30
+ className?: string;
31
+ }
32
+
33
+ const MAX_IMAGE_SIZE = 5 * 1024 * 1024; // 5 MB
34
+ const ACCEPTED_IMAGE_TYPES = 'image/jpeg,image/png,image/webp,image/gif';
35
+
36
+ export function CustomFieldsStep({
37
+ fields,
38
+ values,
39
+ onChange,
40
+ onApply,
41
+ onUploadFile,
42
+ timezone,
43
+ loading = false,
44
+ className,
45
+ }: CustomFieldsStepProps) {
46
+ const t = useTranslations('checkout');
47
+ const [uploadingKeys, setUploadingKeys] = useState<Set<string>>(new Set());
48
+
49
+ const isMissing = fields.some((f) => {
50
+ if (!f.required) return false;
51
+ const v = values[f.key];
52
+ return v === undefined || v === null || v === '';
53
+ });
54
+
55
+ return (
56
+ <div className={cn('space-y-4', className)}>
57
+ <p className="text-muted-foreground text-sm">{t('customFieldsSubtitle')}</p>
58
+
59
+ {fields.map((field) => {
60
+ const value = values[field.key];
61
+ const labelEl = (
62
+ <label
63
+ htmlFor={`cf-${field.key}`}
64
+ className="text-foreground mb-1 block text-sm font-medium"
65
+ >
66
+ {field.name}
67
+ {field.required && <span className="text-destructive ms-1">*</span>}
68
+ </label>
69
+ );
70
+ const helpEl = field.description ? (
71
+ <p className="text-muted-foreground mt-1 whitespace-pre-line text-xs">
72
+ {field.description}
73
+ </p>
74
+ ) : null;
75
+
76
+ switch (field.type) {
77
+ case 'TEXT':
78
+ return (
79
+ <div key={field.key}>
80
+ {labelEl}
81
+ <input
82
+ id={`cf-${field.key}`}
83
+ type="text"
84
+ value={(value as string) ?? ''}
85
+ onChange={(e) => onChange(field.key, e.target.value)}
86
+ required={field.required}
87
+ minLength={field.minLength ?? undefined}
88
+ maxLength={field.maxLength ?? undefined}
89
+ className={INPUT_CLASS}
90
+ />
91
+ {helpEl}
92
+ </div>
93
+ );
94
+
95
+ case 'TEXTAREA':
96
+ return (
97
+ <div key={field.key}>
98
+ {labelEl}
99
+ <textarea
100
+ id={`cf-${field.key}`}
101
+ value={(value as string) ?? ''}
102
+ onChange={(e) => onChange(field.key, e.target.value)}
103
+ required={field.required}
104
+ minLength={field.minLength ?? undefined}
105
+ maxLength={field.maxLength ?? undefined}
106
+ rows={3}
107
+ className="border-border bg-background text-foreground placeholder:text-muted-foreground focus-visible:ring-primary w-full rounded-lg border px-3.5 py-2.5 text-sm focus-visible:outline-none focus-visible:ring-2"
108
+ />
109
+ {helpEl}
110
+ </div>
111
+ );
112
+
113
+ case 'NUMBER':
114
+ return (
115
+ <div key={field.key}>
116
+ {labelEl}
117
+ <input
118
+ id={`cf-${field.key}`}
119
+ type="number"
120
+ value={(value as number | string) ?? ''}
121
+ onChange={(e) =>
122
+ onChange(field.key, e.target.value === '' ? '' : Number(e.target.value))
123
+ }
124
+ required={field.required}
125
+ min={field.minValue ?? undefined}
126
+ max={field.maxValue ?? undefined}
127
+ className={INPUT_CLASS}
128
+ />
129
+ {helpEl}
130
+ </div>
131
+ );
132
+
133
+ case 'BOOLEAN':
134
+ return (
135
+ <div key={field.key} className="flex items-start gap-2">
136
+ <input
137
+ id={`cf-${field.key}`}
138
+ type="checkbox"
139
+ checked={value === true}
140
+ onChange={(e) => onChange(field.key, e.target.checked)}
141
+ className="mt-1"
142
+ />
143
+ <div className="flex-1">
144
+ <label
145
+ htmlFor={`cf-${field.key}`}
146
+ className="text-foreground text-sm font-medium"
147
+ >
148
+ {field.name}
149
+ {field.required && <span className="text-destructive ms-1">*</span>}
150
+ </label>
151
+ {helpEl}
152
+ </div>
153
+ </div>
154
+ );
155
+
156
+ case 'SELECT':
157
+ return (
158
+ <div key={field.key}>
159
+ {labelEl}
160
+ <select
161
+ id={`cf-${field.key}`}
162
+ value={(value as string) ?? ''}
163
+ onChange={(e) => onChange(field.key, e.target.value)}
164
+ required={field.required}
165
+ className={INPUT_CLASS}
166
+ >
167
+ <option value="">{t('customFieldsSelectPlaceholder')}</option>
168
+ {field.options?.map((opt) => (
169
+ <option key={opt.value} value={opt.value}>
170
+ {opt.label}
171
+ </option>
172
+ ))}
173
+ </select>
174
+ {helpEl}
175
+ </div>
176
+ );
177
+
178
+ case 'DATE':
179
+ return (
180
+ <div key={field.key}>
181
+ {labelEl}
182
+ <DatePicker
183
+ id={`cf-${field.key}`}
184
+ value={(value as string) ?? ''}
185
+ onChange={(v) => onChange(field.key, v)}
186
+ required={field.required}
187
+ availability={field.dateAvailability}
188
+ timezone={timezone}
189
+ placeholder={t('customFieldsDatePlaceholder')}
190
+ todayLabel={t('customFieldsDateToday')}
191
+ clearLabel={t('customFieldsDateClear')}
192
+ prevMonthLabel={t('customFieldsDatePrevMonth')}
193
+ nextMonthLabel={t('customFieldsDateNextMonth')}
194
+ />
195
+ {helpEl}
196
+ </div>
197
+ );
198
+
199
+ case 'DATETIME':
200
+ return (
201
+ <div key={field.key}>
202
+ {labelEl}
203
+ <DateTimePicker
204
+ id={`cf-${field.key}`}
205
+ value={(value as string) ?? ''}
206
+ onChange={(v) => onChange(field.key, v)}
207
+ required={field.required}
208
+ availability={field.dateAvailability}
209
+ timezone={timezone}
210
+ placeholder={t('customFieldsDatePlaceholder')}
211
+ todayLabel={t('customFieldsDateToday')}
212
+ clearLabel={t('customFieldsDateClear')}
213
+ prevMonthLabel={t('customFieldsDatePrevMonth')}
214
+ nextMonthLabel={t('customFieldsDateNextMonth')}
215
+ timeLabel={t('customFieldsTimeLabel')}
216
+ closedLabel={t('customFieldsTimeClosed')}
217
+ noTimesLabel={t('customFieldsTimeNoneLeft')}
218
+ toLabel={t('customFieldsTimeTo')}
219
+ />
220
+ {helpEl}
221
+ </div>
222
+ );
223
+
224
+ case 'IMAGE': {
225
+ const isUploading = uploadingKeys.has(field.key);
226
+ return (
227
+ <div key={field.key}>
228
+ {labelEl}
229
+ {value ? (
230
+ <div className="relative inline-block">
231
+ <img
232
+ src={value as string}
233
+ alt={field.name}
234
+ className="border-border max-h-32 rounded border object-contain"
235
+ />
236
+ <button
237
+ type="button"
238
+ onClick={() => onChange(field.key, '')}
239
+ className="bg-background/80 text-foreground absolute end-1 top-1 rounded-full p-1 text-xs leading-none"
240
+ aria-label={t('customFieldsImageRemove')}
241
+ >
242
+
243
+ </button>
244
+ </div>
245
+ ) : (
246
+ <label
247
+ htmlFor={`cf-${field.key}`}
248
+ className={cn(
249
+ 'border-border flex cursor-pointer flex-col items-center gap-2 rounded border-2 border-dashed p-6 text-center transition-colors',
250
+ isUploading ? 'opacity-50' : 'hover:border-primary/40'
251
+ )}
252
+ >
253
+ <span className="text-muted-foreground text-sm">
254
+ {isUploading ? t('customFieldsImageUploading') : t('customFieldsImageUpload')}
255
+ </span>
256
+ <input
257
+ id={`cf-${field.key}`}
258
+ type="file"
259
+ accept={ACCEPTED_IMAGE_TYPES}
260
+ disabled={isUploading || !onUploadFile}
261
+ className="hidden"
262
+ onChange={async (e) => {
263
+ const file = e.target.files?.[0];
264
+ if (!file || !onUploadFile) return;
265
+ if (file.size > MAX_IMAGE_SIZE) {
266
+ alert(t('customFieldsImageTooLarge'));
267
+ return;
268
+ }
269
+ setUploadingKeys((prev) => new Set(prev).add(field.key));
270
+ try {
271
+ const result = await onUploadFile(file);
272
+ onChange(field.key, result.url);
273
+ } catch {
274
+ // Upload failed — user can retry
275
+ } finally {
276
+ setUploadingKeys((prev) => {
277
+ const next = new Set(prev);
278
+ next.delete(field.key);
279
+ return next;
280
+ });
281
+ }
282
+ }}
283
+ />
284
+ </label>
285
+ )}
286
+ {helpEl}
287
+ </div>
288
+ );
289
+ }
290
+
291
+ default:
292
+ return null;
293
+ }
294
+ })}
295
+
296
+ <button
297
+ type="button"
298
+ onClick={onApply}
299
+ disabled={loading || isMissing}
300
+ className="bg-primary text-primary-foreground hover:bg-primary/90 inline-flex h-12 w-full select-none items-center justify-center gap-2 whitespace-nowrap rounded-full px-8 text-base font-semibold transition-colors duration-200 disabled:pointer-events-none disabled:opacity-50"
301
+ >
302
+ {loading ? t('customFieldsApplying') : t('customFieldsApply')}
303
+ </button>
304
+ </div>
305
+ );
306
+ }
@@ -18,6 +18,12 @@ import { cn } from '@/core/lib/utils';
18
18
  * — min/max date, blocked weekdays AND blocked specific dates in one call, the
19
19
  * exact predicate the server re-runs on submit. Reimplementing any part of it
20
20
  * here is how a picker ends up offering a day the API then rejects with 400.
21
+ *
22
+ * `timezone` is the other half of that predicate. The field's relative bounds
23
+ * (`leadTimeMinutes`, `cutoffTime`, `maxDaysAhead`) resolve against the clock
24
+ * rather than a fixed date, and the SDK skips them entirely when no clock is
25
+ * passed — so leaving it out silently reopens every day a lead time was meant
26
+ * to close.
21
27
  */
22
28
  interface DatePickerProps {
23
29
  id?: string;
@@ -34,6 +40,8 @@ interface DatePickerProps {
34
40
  * already committed to a date.
35
41
  */
36
42
  isDateSelectable?: (dateYYYYMMDD: string) => boolean;
43
+ /** The store's IANA timezone, from `getStoreInfo().timezone`. Never the browser's. */
44
+ timezone?: string;
37
45
  placeholder: string;
38
46
  todayLabel: string;
39
47
  clearLabel: string;
@@ -63,6 +71,7 @@ export function DatePicker({
63
71
  required,
64
72
  availability,
65
73
  isDateSelectable,
74
+ timezone,
66
75
  placeholder,
67
76
  todayLabel,
68
77
  clearLabel,
@@ -109,7 +118,10 @@ export function DatePicker({
109
118
 
110
119
  function isDisabled(y: number, m: number, d: number): boolean {
111
120
  const ymd = toYMD(y, m, d);
112
- if (!isCalendarDateAllowed(ymd, availability)) return true;
121
+ // `now` is deliberately left to the SDK's default so the calendar re-reads
122
+ // the real clock on every render: a shopper who sits on the page past the
123
+ // cutoff sees the day close under them rather than 400 on submit.
124
+ if (!isCalendarDateAllowed(ymd, availability, timezone ? { timezone } : undefined)) return true;
113
125
  return isDateSelectable ? !isDateSelectable(ymd) : false;
114
126
  }
115
127