Merge pull request #218 from mirumee/fix/new-variant-attributes

Fix empty attribute values
This commit is contained in:
Marcin Gębala 2019-10-21 10:01:27 +02:00 committed by GitHub
commit cce276db3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -39,4 +39,4 @@ All notable, unreleased changes to this project will be documented in this file.
- Send address update mutation only once - #210 by @dominik-zeglen
- Update sale details design - #207 by @dominik-zeglen
- Improve autocomplete UX - #212 by @dominik-zeglen
- Fix empty attribute values - #218 by @dominik-zeglen

View file

@ -93,17 +93,17 @@ export function getAttributeInputFromProductType(
}
export function getAttributeInputFromVariant(
product: ProductVariant
variant: ProductVariant
): VariantAttributeInput[] {
return maybe(
(): VariantAttributeInput[] =>
product.attributes.map(attribute => ({
variant.attributes.map(attribute => ({
data: {
values: attribute.attribute.values
},
id: attribute.attribute.id,
label: attribute.attribute.name,
value: attribute.value.slug
value: maybe(() => attribute.value.slug, null)
})),
[]
);