Fix vendure variants (#338)

* Fix variant selection in Vendure provider

* Styling of checkout placeholder in Vendure provider
This commit is contained in:
Michael Bromley
2021-05-28 16:19:49 +02:00
committed by GitHub
parent 60dac1654b
commit 925a68a78c
2 changed files with 14 additions and 4 deletions

View File

@@ -20,6 +20,9 @@ async function getProduct({
const product = data.product
if (product) {
const getOptionGroupName = (id: string): string => {
return product.optionGroups.find((og) => og.id === id)!.name
}
return {
product: {
id: product.id,
@@ -33,9 +36,13 @@ async function getProduct({
variants: product.variants.map((v) => ({
id: v.id,
options: v.options.map((o) => ({
// This __typename property is required in order for the correct
// variant selection to work, see `components/product/helpers.ts`
// `getVariant()` function.
__typename: 'MultipleChoiceOption',
id: o.id,
displayName: o.name,
values: o.group.options.map((_o) => ({ label: _o.name })),
displayName: getOptionGroupName(o.groupId),
values: [{ label: o.name }],
})),
})),
price: {