Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve code readability
dominik-zeglen319411255b1c
diff --git a/saleor/static/dashboard-next/misc.ts b/saleor/static/dashboard-next/misc.tsindex caac21b5d3..0abba90e13 100644--- a/saleor/static/dashboard-next/misc.ts+++ b/saleor/static/dashboard-next/misc.ts@@ -102,3 +102,7 @@ export function renderCollection<T>(}return collection.map(renderItem);}++export function decimal(value: string) {+ return value === "" ? null : value;+}diff --git a/saleor/static/dashboard-next/products/views/ProductCreate.tsx b/saleor/static/dashboard-next/products/views/ProductCreate.tsxindex 9b0864822d..883012a753 100644--- a/saleor/static/dashboard-next/products/views/ProductCreate.tsx+++ b/saleor/static/dashboard-next/products/views/ProductCreate.tsx@@ -9,6 +9,7 @@ import ProductCreatePage from "../components/ProductCreatePage";import { productListUrl, productUrl } from "../index";import { TypedProductCreateMutation } from "../mutations";import { productCreateQuery, TypedProductCreateQuery } from "../queries";+import { decimal } from "../../misc";interface ProductUpdateProps {id: string;@@ -71,7 +72,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({description: formData.description,isPublished: formData.available,name: formData.name,- price: formData.price,+ price: decimal(formData.price),productType: formData.productType.value.id}});diff --git a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx b/saleor/static/dashboard-next/products/views/ProductUpdate.tsxindex 6701fe3061..e4a43ddaff 100644--- a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx+++ b/saleor/static/dashboard-next/products/views/ProductUpdate.tsx@@ -18,6 +18,7 @@ import {productVariantEditUrl} from "../index";import { productDetailsQuery, TypedProductDetailsQuery } from "../queries";+import { decimal } from "../../misc";interface ProductUpdateProps {id: string;@@ -112,7 +113,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({id: product.id,isPublished: data.available,name: data.name,- price: data.price+ price: decimal(data.price)});}};diff --git a/saleor/static/dashboard-next/products/views/ProductVariant.tsx b/saleor/static/dashboard-next/products/views/ProductVariant.tsxindex bea3c823a5..13b9af79e6 100644--- a/saleor/static/dashboard-next/products/views/ProductVariant.tsx+++ b/saleor/static/dashboard-next/products/views/ProductVariant.tsx@@ -10,6 +10,7 @@ import i18n from "../../i18n";import ProductVariantPage from "../components/ProductVariantPage";import ProductVariantOperations from "../containers/ProductVariantOperations";import { productVariantQuery, TypedProductVariantQuery } from "../queries";+import { decimal } from "../../misc";interface ProductUpdateProps {variantId: string;@@ -128,11 +129,9 @@ export const ProductVariant: React.StatelessComponent<ProductUpdateProps> = ({attributes: data.attributes? data.attributes: null,- costPrice: data.costPrice ? data.costPrice : null,+ costPrice: decimal(data.costPrice),id: variantId,- priceOverride: data.priceOverride- ? data.priceOverride- : null,+ priceOverride: decimal(data.priceOverride),product: productId,quantity: data.stock,sku: data.sku,diff --git a/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx b/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsxindex 335c8014d0..8f18e7d286 100644--- a/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx+++ b/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx@@ -12,6 +12,7 @@ import {productVariantCreateQuery,TypedProductVariantCreateQuery} from "../queries";+import { decimal } from "../../misc";interface ProductUpdateProps {productId: string;@@ -77,12 +78,8 @@ export const ProductVariant: React.StatelessComponent<ProductUpdateProps> = ({variantCreate({variables: {attributes: formData.attributes,- costPrice: formData.costPrice- ? formData.costPrice- : null,- priceOverride: formData.priceOverride- ? formData.priceOverride- : null,+ costPrice: decimal(formData.costPrice),+ priceOverride: decimal(formData.priceOverride),product: productId,quantity: formData.stock,sku: formData.sku,