create-brainerce-store 1.15.0 → 1.15.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-brainerce-store",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "Scaffold a production-ready e-commerce storefront connected to Brainerce",
5
5
  "bin": {
6
6
  "create-brainerce-store": "dist/index.js"
@@ -189,147 +189,159 @@ export function CheckoutForm({
189
189
 
190
190
  {!emailOnly && (
191
191
  <>
192
- {/* Country + Region row */}
193
- <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
194
- <div>
195
- <label htmlFor="country" className="text-foreground mb-1 block text-sm font-medium">
196
- {t('country')} <span className="text-destructive">*</span>
197
- </label>
198
- {hasCountryOptions ? (
199
- <select
200
- id="country"
201
- value={formData.country}
202
- onChange={(e) => updateField('country', e.target.value)}
203
- className={cn(selectClass, errors.country ? 'border-destructive' : 'border-border')}
204
- >
205
- <option value="">{t('selectCountry')}</option>
206
- {destinations.countries.map((c) => (
207
- <option key={c.code} value={c.code}>
208
- {c.name}
209
- </option>
210
- ))}
211
- </select>
212
- ) : (
192
+ {/* Country + Region row */}
193
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
194
+ <div>
195
+ <label htmlFor="country" className="text-foreground mb-1 block text-sm font-medium">
196
+ {t('country')} <span className="text-destructive">*</span>
197
+ </label>
198
+ {hasCountryOptions ? (
199
+ <select
200
+ id="country"
201
+ value={formData.country}
202
+ onChange={(e) => updateField('country', e.target.value)}
203
+ className={cn(
204
+ selectClass,
205
+ errors.country ? 'border-destructive' : 'border-border'
206
+ )}
207
+ >
208
+ <option value="">{t('selectCountry')}</option>
209
+ {destinations.countries.map((c) => (
210
+ <option key={c.code} value={c.code}>
211
+ {c.name}
212
+ </option>
213
+ ))}
214
+ </select>
215
+ ) : (
216
+ <input
217
+ id="country"
218
+ type="text"
219
+ value={formData.country}
220
+ onChange={(e) => updateField('country', e.target.value)}
221
+ className={cn(
222
+ inputClass,
223
+ errors.country ? 'border-destructive' : 'border-border'
224
+ )}
225
+ placeholder={t('countryPlaceholder')}
226
+ />
227
+ )}
228
+ {errors.country && <p className="text-destructive mt-1 text-xs">{errors.country}</p>}
229
+ </div>
230
+
231
+ <div>
232
+ <label htmlFor="region" className="text-foreground mb-1 block text-sm font-medium">
233
+ {t('stateRegion')}
234
+ </label>
235
+ {hasRegionOptions ? (
236
+ <select
237
+ id="region"
238
+ value={formData.region || ''}
239
+ onChange={(e) => updateField('region', e.target.value)}
240
+ className={cn(selectClass, 'border-border')}
241
+ >
242
+ <option value="">{t('selectRegion')}</option>
243
+ {countryRegions.map((r) => (
244
+ <option key={r.code} value={r.code}>
245
+ {r.name}
246
+ </option>
247
+ ))}
248
+ </select>
249
+ ) : (
250
+ <input
251
+ id="region"
252
+ type="text"
253
+ value={formData.region || ''}
254
+ onChange={(e) => updateField('region', e.target.value)}
255
+ className={cn(inputClass, 'border-border')}
256
+ />
257
+ )}
258
+ </div>
259
+ </div>
260
+
261
+ {/* Address line 1 */}
262
+ <div>
263
+ <label htmlFor="line1" className="text-foreground mb-1 block text-sm font-medium">
264
+ {t('address')} <span className="text-destructive">*</span>
265
+ </label>
213
266
  <input
214
- id="country"
267
+ id="line1"
215
268
  type="text"
216
- value={formData.country}
217
- onChange={(e) => updateField('country', e.target.value)}
218
- className={cn(inputClass, errors.country ? 'border-destructive' : 'border-border')}
219
- placeholder={t('countryPlaceholder')}
269
+ value={formData.line1}
270
+ onChange={(e) => updateField('line1', e.target.value)}
271
+ className={cn(inputClass, errors.line1 ? 'border-destructive' : 'border-border')}
272
+ placeholder={t('streetAddress')}
220
273
  />
221
- )}
222
- {errors.country && <p className="text-destructive mt-1 text-xs">{errors.country}</p>}
223
- </div>
274
+ {errors.line1 && <p className="text-destructive mt-1 text-xs">{errors.line1}</p>}
275
+ </div>
224
276
 
225
- <div>
226
- <label htmlFor="region" className="text-foreground mb-1 block text-sm font-medium">
227
- {t('stateRegion')}
228
- </label>
229
- {hasRegionOptions ? (
230
- <select
231
- id="region"
232
- value={formData.region || ''}
233
- onChange={(e) => updateField('region', e.target.value)}
234
- className={cn(selectClass, 'border-border')}
235
- >
236
- <option value="">{t('selectRegion')}</option>
237
- {countryRegions.map((r) => (
238
- <option key={r.code} value={r.code}>
239
- {r.name}
240
- </option>
241
- ))}
242
- </select>
243
- ) : (
277
+ {/* Address line 2 */}
278
+ <div>
279
+ <label htmlFor="line2" className="text-foreground mb-1 block text-sm font-medium">
280
+ {t('apartmentSuite')}
281
+ </label>
244
282
  <input
245
- id="region"
283
+ id="line2"
246
284
  type="text"
247
- value={formData.region || ''}
248
- onChange={(e) => updateField('region', e.target.value)}
285
+ value={formData.line2 || ''}
286
+ onChange={(e) => updateField('line2', e.target.value)}
249
287
  className={cn(inputClass, 'border-border')}
288
+ placeholder={t('aptPlaceholder')}
250
289
  />
251
- )}
252
- </div>
253
- </div>
254
-
255
- {/* Address line 1 */}
256
- <div>
257
- <label htmlFor="line1" className="text-foreground mb-1 block text-sm font-medium">
258
- {t('address')} <span className="text-destructive">*</span>
259
- </label>
260
- <input
261
- id="line1"
262
- type="text"
263
- value={formData.line1}
264
- onChange={(e) => updateField('line1', e.target.value)}
265
- className={cn(inputClass, errors.line1 ? 'border-destructive' : 'border-border')}
266
- placeholder={t('streetAddress')}
267
- />
268
- {errors.line1 && <p className="text-destructive mt-1 text-xs">{errors.line1}</p>}
269
- </div>
270
-
271
- {/* Address line 2 */}
272
- <div>
273
- <label htmlFor="line2" className="text-foreground mb-1 block text-sm font-medium">
274
- {t('apartmentSuite')}
275
- </label>
276
- <input
277
- id="line2"
278
- type="text"
279
- value={formData.line2 || ''}
280
- onChange={(e) => updateField('line2', e.target.value)}
281
- className={cn(inputClass, 'border-border')}
282
- placeholder={t('aptPlaceholder')}
283
- />
284
- </div>
290
+ </div>
285
291
 
286
- {/* City + Postal code row */}
287
- <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
288
- <div>
289
- <label htmlFor="city" className="text-foreground mb-1 block text-sm font-medium">
290
- {t('city')} <span className="text-destructive">*</span>
291
- </label>
292
- <input
293
- id="city"
294
- type="text"
295
- value={formData.city}
296
- onChange={(e) => updateField('city', e.target.value)}
297
- className={cn(inputClass, errors.city ? 'border-destructive' : 'border-border')}
298
- />
299
- {errors.city && <p className="text-destructive mt-1 text-xs">{errors.city}</p>}
300
- </div>
292
+ {/* City + Postal code row */}
293
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
294
+ <div>
295
+ <label htmlFor="city" className="text-foreground mb-1 block text-sm font-medium">
296
+ {t('city')} <span className="text-destructive">*</span>
297
+ </label>
298
+ <input
299
+ id="city"
300
+ type="text"
301
+ value={formData.city}
302
+ onChange={(e) => updateField('city', e.target.value)}
303
+ className={cn(inputClass, errors.city ? 'border-destructive' : 'border-border')}
304
+ />
305
+ {errors.city && <p className="text-destructive mt-1 text-xs">{errors.city}</p>}
306
+ </div>
301
307
 
302
- <div>
303
- <label htmlFor="postalCode" className="text-foreground mb-1 block text-sm font-medium">
304
- {t('postalCode')} <span className="text-destructive">*</span>
305
- </label>
306
- <input
307
- id="postalCode"
308
- type="text"
309
- value={formData.postalCode}
310
- onChange={(e) => updateField('postalCode', e.target.value)}
311
- className={cn(inputClass, errors.postalCode ? 'border-destructive' : 'border-border')}
312
- />
313
- {errors.postalCode && (
314
- <p className="text-destructive mt-1 text-xs">{errors.postalCode}</p>
315
- )}
316
- </div>
317
- </div>
308
+ <div>
309
+ <label
310
+ htmlFor="postalCode"
311
+ className="text-foreground mb-1 block text-sm font-medium"
312
+ >
313
+ {t('postalCode')} <span className="text-destructive">*</span>
314
+ </label>
315
+ <input
316
+ id="postalCode"
317
+ type="text"
318
+ value={formData.postalCode}
319
+ onChange={(e) => updateField('postalCode', e.target.value)}
320
+ className={cn(
321
+ inputClass,
322
+ errors.postalCode ? 'border-destructive' : 'border-border'
323
+ )}
324
+ />
325
+ {errors.postalCode && (
326
+ <p className="text-destructive mt-1 text-xs">{errors.postalCode}</p>
327
+ )}
328
+ </div>
329
+ </div>
318
330
 
319
- {/* Phone */}
320
- <div>
321
- <label htmlFor="phone" className="text-foreground mb-1 block text-sm font-medium">
322
- {t('phone')}
323
- </label>
324
- <input
325
- id="phone"
326
- type="tel"
327
- value={formData.phone || ''}
328
- onChange={(e) => updateField('phone', e.target.value)}
329
- className={cn(inputClass, 'border-border')}
330
- placeholder={t('phonePlaceholder')}
331
- />
332
- </div>
331
+ {/* Phone */}
332
+ <div>
333
+ <label htmlFor="phone" className="text-foreground mb-1 block text-sm font-medium">
334
+ {t('phone')}
335
+ </label>
336
+ <input
337
+ id="phone"
338
+ type="tel"
339
+ value={formData.phone || ''}
340
+ onChange={(e) => updateField('phone', e.target.value)}
341
+ className={cn(inputClass, 'border-border')}
342
+ placeholder={t('phonePlaceholder')}
343
+ />
344
+ </div>
333
345
  </>
334
346
  )}
335
347
 
@@ -1,147 +1,277 @@
1
- 'use client';
2
-
3
- import { useMemo } from 'react';
4
- import type { Product, ProductVariant } from 'brainerce';
5
- import { getVariantOptions, getStockStatus, formatPrice } from 'brainerce';
6
- import { useStoreInfo } from '@/providers/store-provider';
7
- import { cn } from '@/lib/utils';
8
-
9
- interface VariantSelectorProps {
10
- product: Product;
11
- selectedVariant: ProductVariant | null;
12
- onVariantChange: (variant: ProductVariant) => void;
13
- className?: string;
14
- }
15
-
16
- interface AttributeGroup {
17
- name: string;
18
- values: Array<{
19
- value: string;
20
- variants: ProductVariant[];
21
- }>;
22
- }
23
-
24
- export function VariantSelector({
25
- product,
26
- selectedVariant,
27
- onVariantChange,
28
- className,
29
- }: VariantSelectorProps) {
30
- const { storeInfo } = useStoreInfo();
31
- const currency = storeInfo?.currency || 'USD';
32
- const variants = useMemo(() => product.variants || [], [product.variants]);
33
-
34
- // Build attribute groups from product attribute options or variant data
35
- const attributeGroups = useMemo<AttributeGroup[]>(() => {
36
- const groups = new Map<string, Map<string, ProductVariant[]>>();
37
-
38
- for (const variant of variants) {
39
- const options = getVariantOptions(variant);
40
- for (const { name, value } of options) {
41
- if (!groups.has(name)) {
42
- groups.set(name, new Map());
43
- }
44
- const valuesMap = groups.get(name)!;
45
- if (!valuesMap.has(value)) {
46
- valuesMap.set(value, []);
47
- }
48
- valuesMap.get(value)!.push(variant);
49
- }
50
- }
51
-
52
- return Array.from(groups.entries()).map(([name, valuesMap]) => ({
53
- name,
54
- values: Array.from(valuesMap.entries()).map(([value, variantList]) => ({
55
- value,
56
- variants: variantList,
57
- })),
58
- }));
59
- }, [variants]);
60
-
61
- // Get currently selected attribute values
62
- const selectedOptions = useMemo(() => {
63
- if (!selectedVariant) return new Map<string, string>();
64
- const opts = getVariantOptions(selectedVariant);
65
- return new Map(opts.map(({ name, value }) => [name, value]));
66
- }, [selectedVariant]);
67
-
68
- // Find the variant that matches all selected attributes
69
- function findMatchingVariant(
70
- attributeName: string,
71
- newValue: string
72
- ): ProductVariant | undefined {
73
- const nextSelection = new Map(selectedOptions);
74
- nextSelection.set(attributeName, newValue);
75
-
76
- return variants.find((v) => {
77
- const opts = getVariantOptions(v);
78
- return Array.from(nextSelection.entries()).every(([name, value]) =>
79
- opts.some((o) => o.name === name && o.value === value)
80
- );
81
- });
82
- }
83
-
84
- if (attributeGroups.length === 0) return null;
85
-
86
- return (
87
- <div className={cn('space-y-4', className)}>
88
- {attributeGroups.map((group) => (
89
- <div key={group.name}>
90
- <label className="text-foreground mb-2 block text-sm font-medium">
91
- {group.name}
92
- {selectedOptions.get(group.name) && (
93
- <span className="text-muted-foreground ms-1 font-normal">
94
- : {selectedOptions.get(group.name)}
95
- </span>
96
- )}
97
- </label>
98
- <div className="flex flex-wrap gap-2">
99
- {group.values.map(({ value, variants: matchingVariants }) => {
100
- const isSelected = selectedOptions.get(group.name) === value;
101
- const matchedVariant = findMatchingVariant(group.name, value);
102
- const isAvailable = matchedVariant?.inventory?.canPurchase !== false;
103
-
104
- return (
105
- <button
106
- key={value}
107
- type="button"
108
- disabled={!isAvailable}
109
- onClick={() => {
110
- const variant = matchedVariant || matchingVariants[0];
111
- if (variant) onVariantChange(variant);
112
- }}
113
- className={cn(
114
- 'rounded border px-4 py-2 text-sm transition-colors',
115
- isSelected
116
- ? 'border-primary bg-primary text-primary-foreground'
117
- : isAvailable
118
- ? 'border-border bg-background text-foreground hover:border-primary'
119
- : 'border-border bg-muted text-muted-foreground cursor-not-allowed line-through opacity-50'
120
- )}
121
- >
122
- {value}
123
- </button>
124
- );
125
- })}
126
- </div>
127
- </div>
128
- ))}
129
-
130
- {/* Variant-specific info */}
131
- {selectedVariant && (
132
- <div className="text-muted-foreground flex items-center gap-3 pt-1 text-sm">
133
- {selectedVariant.price && (
134
- <span>
135
- {
136
- formatPrice(selectedVariant.salePrice || selectedVariant.price, {
137
- currency,
138
- }) as string
139
- }
140
- </span>
141
- )}
142
- <span>{getStockStatus(selectedVariant.inventory)}</span>
143
- </div>
144
- )}
145
- </div>
146
- );
147
- }
1
+ 'use client';
2
+
3
+ import { useMemo } from 'react';
4
+ import type { Product, ProductVariant } from 'brainerce';
5
+ import { getVariantOptions, getProductSwatches, getStockStatus, formatPrice } from 'brainerce';
6
+ import { useStoreInfo } from '@/providers/store-provider';
7
+ import { cn } from '@/lib/utils';
8
+
9
+ interface VariantSelectorProps {
10
+ product: Product;
11
+ selectedVariant: ProductVariant | null;
12
+ onVariantChange: (variant: ProductVariant) => void;
13
+ className?: string;
14
+ }
15
+
16
+ interface AttributeGroup {
17
+ name: string;
18
+ displayType: string;
19
+ values: Array<{
20
+ value: string;
21
+ swatchColor?: string | null;
22
+ swatchColor2?: string | null;
23
+ swatchImageUrl?: string | null;
24
+ variants: ProductVariant[];
25
+ }>;
26
+ }
27
+
28
+ export function VariantSelector({
29
+ product,
30
+ selectedVariant,
31
+ onVariantChange,
32
+ className,
33
+ }: VariantSelectorProps) {
34
+ const { storeInfo } = useStoreInfo();
35
+ const currency = storeInfo?.currency || 'USD';
36
+ const variants = useMemo(() => product.variants || [], [product.variants]);
37
+
38
+ // Get swatch metadata from product attribute options
39
+ const swatchData = useMemo(() => getProductSwatches(product), [product]);
40
+ const swatchMap = useMemo(() => {
41
+ const map = new Map<
42
+ string,
43
+ {
44
+ displayType: string;
45
+ options: Map<
46
+ string,
47
+ {
48
+ swatchColor?: string | null;
49
+ swatchColor2?: string | null;
50
+ swatchImageUrl?: string | null;
51
+ }
52
+ >;
53
+ }
54
+ >();
55
+ for (const attr of swatchData) {
56
+ const optMap = new Map<
57
+ string,
58
+ {
59
+ swatchColor?: string | null;
60
+ swatchColor2?: string | null;
61
+ swatchImageUrl?: string | null;
62
+ }
63
+ >();
64
+ for (const opt of attr.options) {
65
+ optMap.set(opt.name, {
66
+ swatchColor: opt.swatchColor,
67
+ swatchColor2: opt.swatchColor2,
68
+ swatchImageUrl: opt.swatchImageUrl,
69
+ });
70
+ }
71
+ map.set(attr.attributeName, { displayType: attr.displayType, options: optMap });
72
+ }
73
+ return map;
74
+ }, [swatchData]);
75
+
76
+ // Build attribute groups from variant data, enriched with swatch info
77
+ const attributeGroups = useMemo<AttributeGroup[]>(() => {
78
+ const groups = new Map<string, Map<string, ProductVariant[]>>();
79
+
80
+ for (const variant of variants) {
81
+ const options = getVariantOptions(variant);
82
+ for (const { name, value } of options) {
83
+ if (!groups.has(name)) {
84
+ groups.set(name, new Map());
85
+ }
86
+ const valuesMap = groups.get(name)!;
87
+ if (!valuesMap.has(value)) {
88
+ valuesMap.set(value, []);
89
+ }
90
+ valuesMap.get(value)!.push(variant);
91
+ }
92
+ }
93
+
94
+ return Array.from(groups.entries()).map(([name, valuesMap]) => {
95
+ const attrSwatch = swatchMap.get(name);
96
+ return {
97
+ name,
98
+ displayType: attrSwatch?.displayType || 'DROPDOWN',
99
+ values: Array.from(valuesMap.entries()).map(([value, variantList]) => {
100
+ const optSwatch = attrSwatch?.options.get(value);
101
+ return {
102
+ value,
103
+ swatchColor: optSwatch?.swatchColor,
104
+ swatchColor2: optSwatch?.swatchColor2,
105
+ swatchImageUrl: optSwatch?.swatchImageUrl,
106
+ variants: variantList,
107
+ };
108
+ }),
109
+ };
110
+ });
111
+ }, [variants, swatchMap]);
112
+
113
+ // Get currently selected attribute values
114
+ const selectedOptions = useMemo(() => {
115
+ if (!selectedVariant) return new Map<string, string>();
116
+ const opts = getVariantOptions(selectedVariant);
117
+ return new Map(opts.map(({ name, value }) => [name, value]));
118
+ }, [selectedVariant]);
119
+
120
+ // Find the variant that matches all selected attributes
121
+ function findMatchingVariant(
122
+ attributeName: string,
123
+ newValue: string
124
+ ): ProductVariant | undefined {
125
+ const nextSelection = new Map(selectedOptions);
126
+ nextSelection.set(attributeName, newValue);
127
+
128
+ return variants.find((v) => {
129
+ const opts = getVariantOptions(v);
130
+ return Array.from(nextSelection.entries()).every(([name, value]) =>
131
+ opts.some((o) => o.name === name && o.value === value)
132
+ );
133
+ });
134
+ }
135
+
136
+ if (attributeGroups.length === 0) return null;
137
+
138
+ return (
139
+ <div className={cn('space-y-4', className)}>
140
+ {attributeGroups.map((group) => (
141
+ <div key={group.name}>
142
+ <label className="text-foreground mb-2 block text-sm font-medium">
143
+ {group.name}
144
+ {selectedOptions.get(group.name) && (
145
+ <span className="text-muted-foreground ms-1 font-normal">
146
+ : {selectedOptions.get(group.name)}
147
+ </span>
148
+ )}
149
+ </label>
150
+ <div className="flex flex-wrap gap-2">
151
+ {group.values.map(
152
+ ({
153
+ value,
154
+ swatchColor,
155
+ swatchColor2,
156
+ swatchImageUrl,
157
+ variants: matchingVariants,
158
+ }) => {
159
+ const isSelected = selectedOptions.get(group.name) === value;
160
+ const matchedVariant = findMatchingVariant(group.name, value);
161
+ const isAvailable = matchedVariant?.inventory?.canPurchase !== false;
162
+
163
+ // Color swatch rendering
164
+ if (group.displayType === 'COLOR_SWATCH' && swatchColor) {
165
+ return (
166
+ <button
167
+ key={value}
168
+ type="button"
169
+ disabled={!isAvailable}
170
+ title={value}
171
+ onClick={() => {
172
+ const variant = matchedVariant || matchingVariants[0];
173
+ if (variant) onVariantChange(variant);
174
+ }}
175
+ className={cn(
176
+ 'h-9 w-9 rounded-full border-2 transition-all',
177
+ isSelected
178
+ ? 'border-primary ring-primary/30 ring-2'
179
+ : isAvailable
180
+ ? 'border-border hover:border-primary'
181
+ : 'cursor-not-allowed opacity-40'
182
+ )}
183
+ style={{
184
+ background: swatchColor2
185
+ ? `linear-gradient(135deg, ${swatchColor} 50%, ${swatchColor2} 50%)`
186
+ : swatchColor,
187
+ }}
188
+ >
189
+ {!isAvailable && (
190
+ <span
191
+ className="bg-muted-foreground block h-full w-full rounded-full opacity-50"
192
+ style={{
193
+ backgroundImage:
194
+ 'linear-gradient(135deg, transparent 45%, currentColor 45%, currentColor 55%, transparent 55%)',
195
+ }}
196
+ />
197
+ )}
198
+ </button>
199
+ );
200
+ }
201
+
202
+ // Image swatch rendering
203
+ if (group.displayType === 'IMAGE_SWATCH' && swatchImageUrl) {
204
+ return (
205
+ <button
206
+ key={value}
207
+ type="button"
208
+ disabled={!isAvailable}
209
+ title={value}
210
+ onClick={() => {
211
+ const variant = matchedVariant || matchingVariants[0];
212
+ if (variant) onVariantChange(variant);
213
+ }}
214
+ className={cn(
215
+ 'h-10 w-10 overflow-hidden rounded-lg border-2 transition-all',
216
+ isSelected
217
+ ? 'border-primary ring-primary/30 ring-2'
218
+ : isAvailable
219
+ ? 'border-border hover:border-primary'
220
+ : 'cursor-not-allowed opacity-40'
221
+ )}
222
+ >
223
+ <img
224
+ src={swatchImageUrl}
225
+ alt={value}
226
+ className="h-full w-full object-cover"
227
+ />
228
+ </button>
229
+ );
230
+ }
231
+
232
+ // Default button rendering (BUTTON, DROPDOWN, or fallback)
233
+ return (
234
+ <button
235
+ key={value}
236
+ type="button"
237
+ disabled={!isAvailable}
238
+ onClick={() => {
239
+ const variant = matchedVariant || matchingVariants[0];
240
+ if (variant) onVariantChange(variant);
241
+ }}
242
+ className={cn(
243
+ 'rounded border px-4 py-2 text-sm transition-colors',
244
+ isSelected
245
+ ? 'border-primary bg-primary text-primary-foreground'
246
+ : isAvailable
247
+ ? 'border-border bg-background text-foreground hover:border-primary'
248
+ : 'border-border bg-muted text-muted-foreground cursor-not-allowed line-through opacity-50'
249
+ )}
250
+ >
251
+ {value}
252
+ </button>
253
+ );
254
+ }
255
+ )}
256
+ </div>
257
+ </div>
258
+ ))}
259
+
260
+ {/* Variant-specific info */}
261
+ {selectedVariant && (
262
+ <div className="text-muted-foreground flex items-center gap-3 pt-1 text-sm">
263
+ {selectedVariant.price && (
264
+ <span>
265
+ {
266
+ formatPrice(selectedVariant.salePrice || selectedVariant.price, {
267
+ currency,
268
+ }) as string
269
+ }
270
+ </span>
271
+ )}
272
+ <span>{getStockStatus(selectedVariant.inventory)}</span>
273
+ </div>
274
+ )}
275
+ </div>
276
+ );
277
+ }