Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix variant creation
dominik-zeglenb4cb759ceb22
diff --git a/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx b/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsxindex d8c8dc44cc..d8321a0a10 100644--- a/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx+++ b/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx@@ -61,7 +61,8 @@ const ProductVariantAttributes = withStyles(styles, {<Card className={classes.card}><CardTitle title={i18n.t("General Information")} /><CardContent className={classes.grid}>- {attributes === undefined && data.attributes.length === 0 ? (+ {attributes === undefined &&+ (console.log(data) || data.attributes.length) === 0 ? (<Skeleton />) : (data.attributes.map((attribute, attributeIndex) => {diff --git a/saleor/static/dashboard-next/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx b/saleor/static/dashboard-next/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsxindex 5ea1ef7fba..b9da7369ce 100644--- a/saleor/static/dashboard-next/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx+++ b/saleor/static/dashboard-next/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx@@ -19,6 +19,7 @@ import ProductVariantStock from "../ProductVariantStock";interface FormData {attributes?: Array<{+ name: string;slug: string;value: string;}>;@@ -55,11 +56,14 @@ const ProductVariantCreatePage: React.StatelessComponent<onVariantClick}) => {const initialForm = {- attributes: maybe(() =>- product.productType.variantAttributes.map(attribute => ({- slug: attribute.slug,- value: ""- }))+ attributes: maybe(+ () =>+ product.productType.variantAttributes.map(attribute => ({+ name: attribute.name,+ slug: attribute.slug,+ value: ""+ })),+ []),costPrice: "",images: maybe(() => product.images.map(image => image.id)),diff --git a/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx b/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsxindex 848f1480eb..b4ded981b4 100644--- a/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx+++ b/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx@@ -60,7 +60,10 @@ export const ProductVariant: React.StatelessComponent<ProductUpdateProps> = ({const handleSubmit = (formData: FormData) =>variantCreate({variables: {- attributes: formData.attributes,+ attributes: formData.attributes.map(attribute => ({+ slug: attribute.slug,+ value: attribute.value+ })),costPrice: decimal(formData.costPrice),priceOverride: decimal(formData.priceOverride),product: productId,