Skip to content

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

Use null instead of zero value

Krzysztof Bialoglowicz952931d677f8
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx b/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
index 2bd42abf7c..f933cb980a 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
@@ -63,7 +63,10 @@ export const VoucherDetails: React.StatelessComponent = () => {
? DiscountValueTypeEnum.PERCENTAGE
: formData.discountType,
endDate: joinDateTime(formData.endDate, formData.endTime),
- minAmountSpent: formData.minAmountSpent,
+ minAmountSpent:
+ formData.minAmountSpent.length > 0
+ ? formData.minAmountSpent.length
+ : null,
startDate: joinDateTime(
formData.startDate,
formData.startTime
@@ -72,9 +75,11 @@ export const VoucherDetails: React.StatelessComponent = () => {
formData.discountType.toString() === "SHIPPING"
? VoucherTypeEnum.ENTIRE_ORDER
: formData.type,
- usageLimit: formData.hasUsageLimit
- ? formData.usageLimit
- : 0
+ usageLimit:
+ formData.hasUsageLimit &&
+ formData.hasUsageLimit.length > 0
+ ? formData.usageLimit
+ : null
}
}
})
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx b/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
index 405a370333..f9992e83ba 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
@@ -331,7 +331,10 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({
formData.endDate,
formData.endTime
),
- minAmountSpent: formData.minAmountSpent,
+ minAmountSpent:
+ formData.minAmountSpent.length > 0
+ ? formData.minAmountSpent
+ : null,
startDate: joinDateTime(
formData.startDate,
formData.startTime
@@ -341,9 +344,11 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({
"SHIPPING"
? VoucherTypeEnum.SHIPPING
: formData.type,
- usageLimit: formData.hasUsageLimit
- ? formData.usageLimit
- : 0
+ usageLimit:
+ formData.hasUsageLimit &&
+ formData.usageLimit.length > 0
+ ? formData.usageLimit
+ : null
}
}
});