Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix select inputs
dominik-zeglen3ac606dd740b
diff --git a/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx b/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsxindex 460f6844c6..3d9ee31eed 100644--- a/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx+++ b/saleor/static/dashboard-next/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx@@ -3,19 +3,21 @@ import CardContent from "@material-ui/core/CardContent";import { withStyles } from "@material-ui/core/styles";import * as React from "react";+import { debug } from "util";+import { AttributeType, AttributeValueType } from "../..";import PageHeader from "../../../components/PageHeader";import SingleSelectField from "../../../components/SingleSelectField";import Skeleton from "../../../components/Skeleton";import i18n from "../../../i18n";-import { AttributeType, AttributeValueType } from "../..";-import { debug } from "util";interface ProductVariantAttributesProps {attributes?: Array<{attribute: AttributeType;value: AttributeValueType;}>;- formData?: any;+ data: {+ [key: string]: string;+ };loading?: boolean;onChange(event: any);}@@ -32,7 +34,7 @@ const decorate = withStyles(theme => ({}));const ProductVariantAttributes = decorate<ProductVariantAttributesProps>(- ({ attributes, classes, formData, loading, onChange }) => (+ ({ attributes, classes, data, loading, onChange }) => (<Card><PageHeader title={i18n.t("Attributes")} /><CardContent className={classes.grid}>@@ -41,17 +43,21 @@ const ProductVariantAttributes = decorate<ProductVariantAttributesProps>(const { attribute } = item;return (<SingleSelectField- choices={attribute.values ? attribute.values.map(value => ({- label: value.name,- value: value.slug- })) : []}+ choices={+ attribute.values+ ? attribute.values.map(value => ({+ label: value.name,+ value: value.slug+ }))+ : []+ }onChange={onChange}- value={formData ? formData[attribute.slug].slug : ""}+ value={data[attribute.slug]}label={attribute.name}name={attribute.slug}key={attribute.slug}/>- )+ );})) : (<Skeleton />diff --git a/saleor/static/dashboard-next/products/components/ProductVariantPage/ProductVariantPage.tsx b/saleor/static/dashboard-next/products/components/ProductVariantPage/ProductVariantPage.tsxindex a514513f69..257f9b7a28 100644--- a/saleor/static/dashboard-next/products/components/ProductVariantPage/ProductVariantPage.tsx+++ b/saleor/static/dashboard-next/products/components/ProductVariantPage/ProductVariantPage.tsx@@ -4,7 +4,12 @@ import DeleteIcon from "@material-ui/icons/Delete";import * as CRC from "crc-32";import * as React from "react";-import { AttributeType, AttributeValueType, MoneyType, ProductImageType } from "../../";+import {+ AttributeType,+ AttributeValueType,+ MoneyType,+ ProductImageType+} from "../../";import Container from "../../../components/Container";import Form from "../../../components/Form";import PageHeader from "../../../components/PageHeader";@@ -55,7 +60,7 @@ interface ProductVariantPageProps {};}>;totalCount: number;- }+ };};sku: string;quantity: number;@@ -82,7 +87,7 @@ const decorate = withStyles(theme => ({[theme.breakpoints.down("sm")]: {gridGap: `${theme.spacing.unit}px`,gridTemplateColumns: "1fr"- },+ }}}));@@ -99,22 +104,26 @@ const ProductVariantPage = decorate<ProductVariantPageProps>(onImageSelect,onVariantClick}) => {- const attributes = variant ? variant.attributes.reduce((prev, curr) => {- prev[curr.attribute.slug] = curr.value;- return prev;- }, {}) : {};- const variantImages = variant ? variant.images.edges.map(edge => edge.node.id) : [];+ const attributes = variant+ ? variant.attributes.reduce((prev, curr) => {+ prev[curr.attribute.slug] = curr.value.slug;+ return prev;+ }, {})+ : {};+ const variantImages = variant+ ? variant.images.edges.map(edge => edge.node.id)+ : [];const productImages = variant? variant.product.images.edges- .map(edge => edge.node)- .sort((prev, next) => (prev.sortOrder > next.sortOrder ? 1 : -1))+ .map(edge => edge.node)+ .sort((prev, next) => (prev.sortOrder > next.sortOrder ? 1 : -1)): undefined;const images = productImages? productImages- .filter(image => variantImages.indexOf(image.id) !== -1)- .sort((prev, next) => (prev.sortOrder > next.sortOrder ? 1 : -1))+ .filter(image => variantImages.indexOf(image.id) !== -1)+ .sort((prev, next) => (prev.sortOrder > next.sortOrder ? 1 : -1)): undefined;- const handleImageSelect = (images: string[]) => { };+ const handleImageSelect = (images: string[]) => {};return (<Toggle>{(isModalActive, { toggle: toggleDeleteModal }) => (@@ -122,7 +131,10 @@ const ProductVariantPage = decorate<ProductVariantPageProps>({(isImageSelectModalActive, { toggle: toggleImageSelectModal }) => (<><Container width="md">- <PageHeader title={variant ? variant.name : undefined} onBack={onBack}>+ <PageHeader+ title={variant ? variant.name : undefined}+ onBack={onBack}+ ><IconButton onClick={toggleDeleteModal} disabled={loading}><DeleteIcon /></IconButton>@@ -131,14 +143,15 @@ const ProductVariantPage = decorate<ProductVariantPageProps>(initial={{costPrice:variant && variant.costPrice- ? variant.costPrice.amount+ ? variant.costPrice.amount.toString(): null,priceOverride:variant && variant.priceOverride- ? variant.priceOverride.amount+ ? variant.priceOverride.amount.toString(): null,sku: variant && variant.sku,- stock: variant && variant.quantity ? variant.quantity : "",+ stock:+ variant && variant.quantity ? variant.quantity : "",...attributes}}onSubmit={onSubmit}@@ -156,10 +169,14 @@ const ProductVariantPage = decorate<ProductVariantPageProps>(<ProductVariantNavigationcurrent={variant ? variant.id : undefined}loading={loading}- productId={variant ? variant.product.id : undefined}+ productId={+ variant ? variant.product.id : undefined+ }variants={variant- ? variant.product.variants.edges.map(edge => edge.node)+ ? variant.product.variants.edges.map(+ edge => edge.node+ ): undefined}onRowClick={(variantId: string) => {@@ -171,14 +188,20 @@ const ProductVariantPage = decorate<ProductVariantPageProps>(</div><div><ProductVariantAttributes- attributes={variant ? variant.attributes : undefined}- formData={data}+ attributes={+ variant ? variant.attributes : undefined+ }+ data={data}onChange={change}loading={loading}/><ProductVariantPricepriceOverride={data.priceOverride}- currencySymbol={variant && variant.priceOverride ? variant.priceOverride.currency : ""}+ currencySymbol={+ variant && variant.priceOverride+ ? variant.priceOverride.currency+ : ""+ }costPrice={data.costPrice}loading={loading}onChange={change}@@ -186,7 +209,9 @@ const ProductVariantPage = decorate<ProductVariantPageProps>(<ProductVariantStocksku={data.sku}stock={data.stock}- stockAllocated={variant ? variant.quantityAllocated : undefined}+ stockAllocated={+ variant ? variant.quantityAllocated : undefined+ }loading={loading}onChange={change}/>