Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Hotfix: assume every attribute has one value

dominik-zeglend20ff6796874
diff --git a/saleor/static/dashboard-next/attributes/fixtures.ts b/saleor/static/dashboard-next/attributes/fixtures.ts
index 023ab1ae70..098f311d7e 100644
--- a/saleor/static/dashboard-next/attributes/fixtures.ts
+++ b/saleor/static/dashboard-next/attributes/fixtures.ts
@@ -1,6 +1,5 @@
import { AttributeValueType } from "@saleor/types/globalTypes";
import { AttributeList_attributes_edges_node } from "./types/AttributeList";
-import { AttributeValueType } from "@saleor/types/globalTypes";
export const attribute = {
__typename: "Attribute" as "Attribute",
diff --git a/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx b/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
index 32cb7c8c21..9be4498715 100644
--- a/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
@@ -27,7 +27,7 @@ interface ChoiceType {
export interface FormData {
attributes: Array<{
slug: string;
- value: string;
+ values: string[];
}>;
basePrice: number;
publicationDate: string;
diff --git a/saleor/static/dashboard-next/products/components/ProductOrganization/ProductOrganization.tsx b/saleor/static/dashboard-next/products/components/ProductOrganization/ProductOrganization.tsx
index c0f8473dc5..45c44a3a56 100644
--- a/saleor/static/dashboard-next/products/components/ProductOrganization/ProductOrganization.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductOrganization/ProductOrganization.tsx
@@ -55,7 +55,7 @@ const styles = (theme: Theme) =>
interface ProductOrganizationFormData {
attributes: Array<{
slug: string;
- value: string;
+ values: string[];
}>;
category: ChoiceType;
collections: ChoiceType[];
@@ -128,11 +128,11 @@ const ProductOrganization = withStyles(styles, { name: "ProductOrganization" })(
};
}
const attributeValueMatch = attributeMatch.values.find(
- v => v.slug === value.value
+ v => v.slug === value.values[0]
);
const label = !!attributeValueMatch
? attributeValueMatch.name
- : value.value;
+ : value.values[0];
return {
label,
value
@@ -167,7 +167,7 @@ const ProductOrganization = withStyles(styles, { name: "ProductOrganization" })(
attributes: event.target.value.value.productAttributes.map(
attribute => ({
slug: attribute.slug,
- value: ""
+ values: [""]
})
),
productType: event.target.value
diff --git a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
index 5b1c2dd9f0..e3e9eb8f0f 100644
--- a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
@@ -71,7 +71,7 @@ interface ChoiceType {
export interface FormData {
attributes: Array<{
slug: string;
- value: string;
+ values: string[];
}>;
basePrice: number;
category: ChoiceType | null;
@@ -138,7 +138,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
() =>
product.attributes.map(a => ({
slug: a.attribute.slug,
- value: a.value ? a.value.slug : null
+ values: a.value ? [a.value.slug] : null
})),
[]
),
diff --git a/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx b/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx
index d8c8dc44cc..b90cbcd041 100644
--- a/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx
@@ -33,7 +33,7 @@ interface ProductVariantAttributesProps extends WithStyles<typeof styles> {
attributes?: Array<{
name: string;
slug: string;
- value: string;
+ values: string[];
}>;
};
disabled: boolean;
@@ -68,7 +68,8 @@ const ProductVariantAttributes = withStyles(styles, {
const getAttributeValue = (slug: string) => {
const valueMatch = attributes.find(a => a.slug === slug);
if (valueMatch) {
- const value = data.attributes.find(a => a.slug === slug).value;
+ const value = data.attributes.find(a => a.slug === slug)
+ .values[0];
const labelMatch = valueMatch.values.find(
v => v.slug === value
);
diff --git a/saleor/static/dashboard-next/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx b/saleor/static/dashboard-next/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx
index 03ab9d90b7..4d1307133f 100644
--- a/saleor/static/dashboard-next/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx
@@ -21,7 +21,7 @@ interface FormData {
attributes: Array<{
name: string;
slug: string;
- value: string;
+ values: string[];
}>;
costPrice: string;
images: string[];
@@ -42,9 +42,7 @@ interface ProductVariantCreatePageProps {
onVariantClick: (variantId: string) => void;
}
-const ProductVariantCreatePage: React.StatelessComponent<
- ProductVariantCreatePageProps
-> = ({
+const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = ({
currencySymbol,
errors: formErrors,
loading,
@@ -61,7 +59,7 @@ const ProductVariantCreatePage: React.StatelessComponent<
product.productType.variantAttributes.map(attribute => ({
name: attribute.name,
slug: attribute.slug,
- value: ""
+ values: [""]
})),
[]
),
diff --git a/saleor/static/dashboard-next/products/views/ProductVariant.tsx b/saleor/static/dashboard-next/products/views/ProductVariant.tsx
index cf0906bb9a..01cd2280a5 100644
--- a/saleor/static/dashboard-next/products/views/ProductVariant.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductVariant.tsx
@@ -28,7 +28,7 @@ interface FormData {
id: string;
attributes?: Array<{
slug: string;
- value: string;
+ values: string[];
}>;
costPrice?: string;
priceOverride?: string;
diff --git a/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx b/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx
index bf9a60c7fc..317fd88da6 100644
--- a/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx
@@ -19,7 +19,7 @@ interface ProductUpdateProps {
interface FormData {
attributes: Array<{
slug: string;
- value: string;
+ values: string[];
}>;
costPrice: string;
priceOverride: string;