Fix: color option

This commit is contained in:
cond0r
2021-02-04 17:44:17 +02:00
parent 029a8372a2
commit 553a1fd9d3
3 changed files with 15 additions and 10 deletions

View File

@@ -22,14 +22,17 @@ const normalizeProductOption = ({
name: displayName,
values,
...rest
}: ProductOption) => ({
__typename: 'MultipleChoiceOption',
displayName,
values: values.map((value) => ({
label: value,
})),
...rest,
})
}: ProductOption) => {
return {
__typename: 'MultipleChoiceOption',
displayName,
values: values.map((value) => ({
label: value,
hexColors: displayName === 'Color' ? [value] : null,
})),
...rest,
}
}
const normalizeProductImages = ({ edges }: ImageConnection) =>
edges?.map(({ node: { originalSrc: url, ...rest } }) => ({

View File

@@ -29,6 +29,8 @@ const getProduct = async (options: {
const product = data?.productByHandle
console.info(normalizeProduct(product))
return {
product: product ? normalizeProduct(product) : null,
}