@@ -34,10 +34,11 @@ import { ProductImageSkeleton } from './ProductImage.skeleton'
34
34
import Price from '@storystore/ui/dist/components/Price'
35
35
import Button from '@storystore/ui/dist/components/Button'
36
36
import Breadcrumbs from '@storystore/ui/dist/components/Breadcrumbs'
37
- import Form , { Input } from '@storystore/ui/dist/components/Form'
37
+ import Form , { Input , Select } from '@storystore/ui/dist/components/Form'
38
38
import { useStoryStore } from '~/hooks/useStoryStore/useStoryStore'
39
39
import TextSwatches from '@storystore/ui/dist/components/Form/TextSwatches'
40
40
import ThumbSwatches from '@storystore/ui/dist/components/Form/ThumbSwatches'
41
+ import ColorSwatches from '@storystore/ui/dist/components/Form/ColorSwatches'
41
42
import PageBuilder from '~/components/PageBuilder'
42
43
43
44
const ProductCarousel = dynamic ( ( ) => import ( '@storystore/ui/dist/components/ProductCarousel' ) , { ssr : false } )
@@ -253,20 +254,23 @@ export const Product: FunctionComponent<ProductProps> = ({ urlKey }) => {
253
254
label : selected ? `${ label } : ${ selected . label } ` : label ,
254
255
name : `options.${ code } ` ,
255
256
rules : { required } ,
256
- items : items ?. map ( ( { id, label, value, image } : any ) => ( {
257
- _id : id ,
258
- label,
259
- type : 'radio' ,
260
- value,
261
- image : image && {
262
- alt : image . label || '' ,
263
- src : resolveImage ( image . url , {
264
- width : 200 ,
265
- } ) ,
266
- width : 160 ,
267
- height : 198 ,
268
- } ,
269
- } ) ) ,
257
+ items : items ?. map ( ( { id, label, value, swatch } : any ) => {
258
+ return {
259
+ _id : id ,
260
+ label,
261
+ type : 'radio' ,
262
+ value,
263
+ color : swatch ?. color ,
264
+ image : swatch ?. image && {
265
+ alt : label || '' ,
266
+ src : resolveImage ( swatch . image , {
267
+ width : 200 ,
268
+ } ) ,
269
+ width : 160 ,
270
+ height : 198 ,
271
+ } ,
272
+ }
273
+ } ) ,
270
274
} ,
271
275
}
272
276
} )
@@ -275,8 +279,10 @@ export const Product: FunctionComponent<ProductProps> = ({ urlKey }) => {
275
279
return (
276
280
< fieldset key = { _id || index } >
277
281
< Field >
278
- { type === 'text' && < TextSwatches { ...swatches } /> }
279
- { type === 'thumb' && < ThumbSwatches { ...swatches } /> }
282
+ { type === 'TextSwatchData' && < TextSwatches { ...swatches } /> }
283
+ { type === 'ImageSwatchData' && < ThumbSwatches { ...swatches } /> }
284
+ { type === 'ColorSwatchData' && < ColorSwatches { ...swatches } /> }
285
+ { type === undefined && < Select { ...swatches } /> }
280
286
</ Field >
281
287
</ fieldset >
282
288
)
0 commit comments