Skip to content

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

Send null instead of empty string

dominik-zeglen5a775e1ce767
diff --git a/saleor/static/dashboard-next/discounts/views/SaleCreate.tsx b/saleor/static/dashboard-next/discounts/views/SaleCreate.tsx
index 93075be785..c3ed41ab67 100644
--- a/saleor/static/dashboard-next/discounts/views/SaleCreate.tsx
+++ b/saleor/static/dashboard-next/discounts/views/SaleCreate.tsx
@@ -64,7 +64,10 @@ export const SaleDetails: React.StatelessComponent = () => (
? null
: formData.endDate,
name: formData.name,
- startDate: formData.startDate,
+ startDate:
+ formData.startDate === ""
+ ? null
+ : formData.startDate,
type: discountValueTypeEnum(formData.type),
value: formData.value
}
diff --git a/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx b/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx
index 29c3efceca..267890367f 100644
--- a/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx
+++ b/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx
@@ -278,7 +278,10 @@ export const SaleDetails: React.StatelessComponent<SaleDetailsProps> = ({
: formData.endDate,
name: formData.name,
startDate:
- formData.startDate,
+ formData.startDate ===
+ ""
+ ? null
+ : formData.startDate,
type: discountValueTypeEnum(
formData.type
),
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx b/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
index fa65b30e46..f35ba15d63 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
@@ -76,7 +76,10 @@ export const VoucherDetails: React.StatelessComponent = () => (
: formData.endDate,
minAmountSpent: formData.minAmountSpent,
name: formData.name,
- startDate: formData.startDate,
+ startDate:
+ formData.startDate === ""
+ ? null
+ : formData.startDate,
type: VoucherTypeEnum[formData.type]
}
}
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsx b/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsx
index b827705ad2..7015c87903 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsx
@@ -37,6 +37,7 @@ import {
TypedVoucherUpdate
} from "../../mutations";
import { TypedVoucherDetails } from "../../queries";
+import { VoucherCataloguesAdd } from "../../types/VoucherCataloguesAdd";
import { VoucherDelete } from "../../types/VoucherDelete";
import { voucherListUrl, voucherUrl } from "../../urls";
import {
@@ -50,7 +51,6 @@ import {
voucherDeletePath,
voucherDeleteUrl
} from "./urls";
-import { VoucherCataloguesAdd } from "../../types/VoucherCataloguesAdd";
const PAGINATE_BY = 20;
@@ -329,7 +329,10 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({
: formData.endDate,
name: formData.name,
startDate:
- formData.startDate
+ formData.startDate ===
+ ""
+ ? null
+ : formData.startDate
}
}
})