Skip to content

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

Set usageLimit and minAmountSpent as string

Krzysztof Bialoglowiczbecad496e6ce
diff --git a/saleor/static/dashboard-next/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx b/saleor/static/dashboard-next/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx
index 166520caeb..9f313e7f82 100644
--- a/saleor/static/dashboard-next/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx
+++ b/saleor/static/dashboard-next/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx
@@ -29,11 +29,11 @@ export interface FormData {
endTime: string;
hasEndDate: boolean;
hasUsageLimit: boolean;
- minAmountSpent: number;
+ minAmountSpent: string;
startDate: string;
startTime: string;
type: VoucherTypeEnum;
- usageLimit: number;
+ usageLimit: string;
value: number;
}
@@ -62,11 +62,11 @@ const VoucherCreatePage: React.StatelessComponent<VoucherCreatePageProps> = ({
endTime: "",
hasEndDate: false,
hasUsageLimit: false,
- minAmountSpent: 0,
+ minAmountSpent: "0",
startDate: "",
startTime: "",
type: VoucherTypeEnum.ENTIRE_ORDER,
- usageLimit: 0,
+ usageLimit: "0",
value: 0
};
diff --git a/saleor/static/dashboard-next/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx b/saleor/static/dashboard-next/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx
index 039e341036..6e8ea046a2 100644
--- a/saleor/static/dashboard-next/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx
+++ b/saleor/static/dashboard-next/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx
@@ -51,11 +51,11 @@ export interface FormData {
endTime: string;
hasEndDate: boolean;
hasUsageLimit: boolean;
- minAmountSpent: number;
+ minAmountSpent: string;
startDate: string;
startTime: string;
type: VoucherTypeEnum;
- usageLimit: number;
+ usageLimit: string;
value: number;
}
@@ -134,11 +134,11 @@ const VoucherDetailsPage: React.StatelessComponent<VoucherDetailsPageProps> = ({
endTime: splitDateTime(maybe(() => voucher.endDate, "")).time,
hasEndDate: maybe(() => !!voucher.endDate),
hasUsageLimit: maybe(() => !!voucher.usageLimit),
- minAmountSpent: maybe(() => voucher.minAmountSpent.amount, 0),
+ minAmountSpent: maybe(() => voucher.minAmountSpent.amount.toString(), "0"),
startDate: splitDateTime(maybe(() => voucher.startDate, "")).date,
startTime: splitDateTime(maybe(() => voucher.startDate, "")).time,
type: maybe(() => voucher.type, VoucherTypeEnum.ENTIRE_ORDER),
- usageLimit: maybe(() => voucher.usageLimit || 0, 0),
+ usageLimit: maybe(() => voucher.usageLimit.toString(), "0"),
value: maybe(() => voucher.discountValue, 0)
};
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx b/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
index e2283fbe2c..723e89b482 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
@@ -65,10 +65,7 @@ export const VoucherDetails: React.StatelessComponent = () => {
endDate: formData.hasEndDate
? joinDateTime(formData.endDate, formData.endTime)
: null,
- minAmountSpent:
- formData.minAmountSpent.length > 0
- ? formData.minAmountSpent.length
- : null,
+ minAmountSpent: parseInt(formData.minAmountSpent, 10),
startDate: joinDateTime(
formData.startDate,
formData.startTime
@@ -77,11 +74,7 @@ export const VoucherDetails: React.StatelessComponent = () => {
formData.discountType.toString() === "SHIPPING"
? VoucherTypeEnum.ENTIRE_ORDER
: formData.type,
- usageLimit:
- formData.hasUsageLimit &&
- formData.hasUsageLimit.length > 0
- ? formData.usageLimit
- : null
+ usageLimit: parseInt(formData.usageLimit, 10)
}
}
})
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx b/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
index 7ad4e05ff1..c80d21d27f 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
@@ -333,10 +333,10 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({
formData.endTime
)
: null,
- minAmountSpent:
- formData.minAmountSpent.length > 0
- ? formData.minAmountSpent
- : null,
+ minAmountSpent: parseInt(
+ formData.minAmountSpent,
+ 10
+ ),
startDate: joinDateTime(
formData.startDate,
formData.startTime
@@ -346,11 +346,10 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({
"SHIPPING"
? VoucherTypeEnum.SHIPPING
: formData.type,
- usageLimit:
- formData.hasUsageLimit &&
- formData.usageLimit.length > 0
- ? formData.usageLimit
- : null
+ usageLimit: parseInt(
+ formData.usageLimit,
+ 10
+ )
}
}
});