saleor: fix the variants

This commit is contained in:
Zaiste 2021-05-12 11:40:51 +02:00
parent 3b559e9853
commit 42ae126b7b
No known key found for this signature in database
GPG Key ID: 15DF7EBC7F2FFE35

View File

@ -32,10 +32,11 @@ const ProductView: FC<Props> = ({ product }) => {
useEffect(() => {
// Selects the default option
product.variants[0].options?.forEach((v) => {
const options = product.variants[0].options || [];
options.forEach((v) => {
setChoices((choices) => ({
...choices,
[v.displayName.toLowerCase()]: v.values[0].label.toLowerCase(),
[v.displayName.toLowerCase()]: v.values[0]?.label.toLowerCase(),
}))
})
}, [])