Skip to content

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

Update types

Krzysztof Bialoglowicz54b2cfafc121
diff --git a/saleor/static/dashboard-next/discounts/types/VoucherCataloguesAdd.ts b/saleor/static/dashboard-next/discounts/types/VoucherCataloguesAdd.ts
index 97a93d380c..12925a2865 100644
--- a/saleor/static/dashboard-next/discounts/types/VoucherCataloguesAdd.ts
+++ b/saleor/static/dashboard-next/discounts/types/VoucherCataloguesAdd.ts
@@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
-import { CatalogueInput, VoucherDiscountValueType, VoucherType } from "./../../types/globalTypes";
+import { CatalogueInput, DiscountValueTypeEnum, VoucherType } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: VoucherCataloguesAdd
@@ -137,7 +137,7 @@ export interface VoucherCataloguesAdd_voucherCataloguesAdd_voucher {
startDate: any;
endDate: any | null;
usageLimit: number | null;
- discountValueType: VoucherDiscountValueType;
+ discountValueType: DiscountValueTypeEnum;
discountValue: number;
countries: (VoucherCataloguesAdd_voucherCataloguesAdd_voucher_countries | null)[] | null;
minAmountSpent: VoucherCataloguesAdd_voucherCataloguesAdd_voucher_minAmountSpent | null;
diff --git a/saleor/static/dashboard-next/discounts/types/VoucherCataloguesRemove.ts b/saleor/static/dashboard-next/discounts/types/VoucherCataloguesRemove.ts
index 492b43de6f..c3045c96cf 100644
--- a/saleor/static/dashboard-next/discounts/types/VoucherCataloguesRemove.ts
+++ b/saleor/static/dashboard-next/discounts/types/VoucherCataloguesRemove.ts
@@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
-import { CatalogueInput, VoucherDiscountValueType, VoucherType } from "./../../types/globalTypes";
+import { CatalogueInput, DiscountValueTypeEnum, VoucherType } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: VoucherCataloguesRemove
@@ -137,7 +137,7 @@ export interface VoucherCataloguesRemove_voucherCataloguesRemove_voucher {
startDate: any;
endDate: any | null;
usageLimit: number | null;
- discountValueType: VoucherDiscountValueType;
+ discountValueType: DiscountValueTypeEnum;
discountValue: number;
countries: (VoucherCataloguesRemove_voucherCataloguesRemove_voucher_countries | null)[] | null;
minAmountSpent: VoucherCataloguesRemove_voucherCataloguesRemove_voucher_minAmountSpent | null;
diff --git a/saleor/static/dashboard-next/discounts/types/VoucherCreate.ts b/saleor/static/dashboard-next/discounts/types/VoucherCreate.ts
index bd9ac49765..1d14c392ef 100644
--- a/saleor/static/dashboard-next/discounts/types/VoucherCreate.ts
+++ b/saleor/static/dashboard-next/discounts/types/VoucherCreate.ts
@@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
-import { VoucherInput, VoucherDiscountValueType } from "./../../types/globalTypes";
+import { VoucherInput, DiscountValueTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: VoucherCreate
@@ -33,7 +33,7 @@ export interface VoucherCreate_voucherCreate_voucher {
startDate: any;
endDate: any | null;
usageLimit: number | null;
- discountValueType: VoucherDiscountValueType;
+ discountValueType: DiscountValueTypeEnum;
discountValue: number;
countries: (VoucherCreate_voucherCreate_voucher_countries | null)[] | null;
minAmountSpent: VoucherCreate_voucherCreate_voucher_minAmountSpent | null;
diff --git a/saleor/static/dashboard-next/discounts/types/VoucherDetails.ts b/saleor/static/dashboard-next/discounts/types/VoucherDetails.ts
index 090719861b..14b9057a43 100644
--- a/saleor/static/dashboard-next/discounts/types/VoucherDetails.ts
+++ b/saleor/static/dashboard-next/discounts/types/VoucherDetails.ts
@@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
-import { VoucherDiscountValueType, VoucherType } from "./../../types/globalTypes";
+import { DiscountValueTypeEnum, VoucherType } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: VoucherDetails
@@ -131,7 +131,7 @@ export interface VoucherDetails_voucher {
startDate: any;
endDate: any | null;
usageLimit: number | null;
- discountValueType: VoucherDiscountValueType;
+ discountValueType: DiscountValueTypeEnum;
discountValue: number;
countries: (VoucherDetails_voucher_countries | null)[] | null;
minAmountSpent: VoucherDetails_voucher_minAmountSpent | null;
diff --git a/saleor/static/dashboard-next/discounts/types/VoucherDetailsFragment.ts b/saleor/static/dashboard-next/discounts/types/VoucherDetailsFragment.ts
index 4af8ce71d2..aa22137394 100644
--- a/saleor/static/dashboard-next/discounts/types/VoucherDetailsFragment.ts
+++ b/saleor/static/dashboard-next/discounts/types/VoucherDetailsFragment.ts
@@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
-import { VoucherDiscountValueType, VoucherType } from "./../../types/globalTypes";
+import { DiscountValueTypeEnum, VoucherType } from "./../../types/globalTypes";
// ====================================================
// GraphQL fragment: VoucherDetailsFragment
@@ -131,7 +131,7 @@ export interface VoucherDetailsFragment {
startDate: any;
endDate: any | null;
usageLimit: number | null;
- discountValueType: VoucherDiscountValueType;
+ discountValueType: DiscountValueTypeEnum;
discountValue: number;
countries: (VoucherDetailsFragment_countries | null)[] | null;
minAmountSpent: VoucherDetailsFragment_minAmountSpent | null;
diff --git a/saleor/static/dashboard-next/discounts/types/VoucherFragment.ts b/saleor/static/dashboard-next/discounts/types/VoucherFragment.ts
index 54a6179216..dac9ef3cda 100644
--- a/saleor/static/dashboard-next/discounts/types/VoucherFragment.ts
+++ b/saleor/static/dashboard-next/discounts/types/VoucherFragment.ts
@@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
-import { VoucherDiscountValueType } from "./../../types/globalTypes";
+import { DiscountValueTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL fragment: VoucherFragment
@@ -27,7 +27,7 @@ export interface VoucherFragment {
startDate: any;
endDate: any | null;
usageLimit: number | null;
- discountValueType: VoucherDiscountValueType;
+ discountValueType: DiscountValueTypeEnum;
discountValue: number;
countries: (VoucherFragment_countries | null)[] | null;
minAmountSpent: VoucherFragment_minAmountSpent | null;
diff --git a/saleor/static/dashboard-next/discounts/types/VoucherList.ts b/saleor/static/dashboard-next/discounts/types/VoucherList.ts
index 954357a4df..e85387accc 100644
--- a/saleor/static/dashboard-next/discounts/types/VoucherList.ts
+++ b/saleor/static/dashboard-next/discounts/types/VoucherList.ts
@@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
-import { VoucherDiscountValueType } from "./../../types/globalTypes";
+import { DiscountValueTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: VoucherList
@@ -27,7 +27,7 @@ export interface VoucherList_vouchers_edges_node {
startDate: any;
endDate: any | null;
usageLimit: number | null;
- discountValueType: VoucherDiscountValueType;
+ discountValueType: DiscountValueTypeEnum;
discountValue: number;
countries: (VoucherList_vouchers_edges_node_countries | null)[] | null;
minAmountSpent: VoucherList_vouchers_edges_node_minAmountSpent | null;
diff --git a/saleor/static/dashboard-next/discounts/types/VoucherUpdate.ts b/saleor/static/dashboard-next/discounts/types/VoucherUpdate.ts
index cc6be9e1d7..61614b5b34 100644
--- a/saleor/static/dashboard-next/discounts/types/VoucherUpdate.ts
+++ b/saleor/static/dashboard-next/discounts/types/VoucherUpdate.ts
@@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
-import { VoucherInput, VoucherDiscountValueType } from "./../../types/globalTypes";
+import { VoucherInput, DiscountValueTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: VoucherUpdate
@@ -33,7 +33,7 @@ export interface VoucherUpdate_voucherUpdate_voucher {
startDate: any;
endDate: any | null;
usageLimit: number | null;
- discountValueType: VoucherDiscountValueType;
+ discountValueType: DiscountValueTypeEnum;
discountValue: number;
countries: (VoucherUpdate_voucherUpdate_voucher_countries | null)[] | null;
minAmountSpent: VoucherUpdate_voucherUpdate_voucher_minAmountSpent | null;
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx b/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
index 77322e9ca8..42b10c6960 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
@@ -5,10 +5,9 @@ import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import useShop from "@saleor/hooks/useShop";
import i18n from "../../i18n";
-import { decimal, getMutationState, maybe } from "../../misc";
+import { connectDateTime, decimal, getMutationState, maybe } from "../../misc";
import {
DiscountValueTypeEnum,
- VoucherDiscountValueType,
VoucherTypeEnum
} from "../../types/globalTypes";
import VoucherCreatePage from "../components/VoucherCreatePage";
@@ -16,14 +15,6 @@ import { TypedVoucherCreate } from "../mutations";
import { VoucherCreate } from "../types/VoucherCreate";
import { voucherListUrl, voucherUrl } from "../urls";
-function discountValueTypeEnum(
- type: VoucherDiscountValueType
-): DiscountValueTypeEnum {
- return type.toString() === DiscountValueTypeEnum.FIXED
- ? DiscountValueTypeEnum.FIXED
- : DiscountValueTypeEnum.PERCENTAGE;
-}
-
export const VoucherDetails: React.StatelessComponent = () => {
const navigate = useNavigator();
const notify = useNotifier();
@@ -61,17 +52,30 @@ export const VoucherDetails: React.StatelessComponent = () => {
voucherCreate({
variables: {
input: {
+ applyOncePerOrder: formData.applyOncePerOrder,
code: formData.code,
- discountValue: decimal(formData.value),
- discountValueType: discountValueTypeEnum(
- formData.discountType
+ discountValue:
+ formData.discountType.toString() === "SHIPPING"
+ ? 100
+ : decimal(formData.value),
+ discountValueType:
+ formData.discountType.toString() === "SHIPPING"
+ ? DiscountValueTypeEnum.PERCENTAGE
+ : formData.discountType,
+ endDate: connectDateTime(
+ formData.endDate,
+ formData.endTime
),
- endDate:
- formData.endDate === "" ? null : formData.endDate,
minAmountSpent: formData.minAmountSpent,
- startDate:
- formData.startDate === "" ? null : formData.startDate,
- type: VoucherTypeEnum[formData.type]
+ startDate: connectDateTime(
+ formData.startDate,
+ formData.startTime
+ ),
+ type:
+ formData.discountType.toString() === "SHIPPING"
+ ? VoucherTypeEnum.ENTIRE_ORDER
+ : formData.type,
+ usageLimit: formData.usageLimit
}
}
})
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx b/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
index 370d7c3d16..fd7777bd48 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
@@ -23,6 +23,10 @@ import SearchProducts from "../../containers/SearchProducts";
import i18n from "../../i18n";
import { connectDateTime, decimal, getMutationState, maybe } from "../../misc";
import { productUrl } from "../../products/urls";
+import {
+ DiscountValueTypeEnum,
+ VoucherTypeEnum
+} from "../../types/globalTypes";
import DiscountCountrySelectDialog from "../components/DiscountCountrySelectDialog";
import VoucherDetailsPage, {
VoucherDetailsPageTab
@@ -311,18 +315,33 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({
variables: {
id,
input: {
- code: formData.code,
- discountValue: decimal(formData.value),
- discountValueType: formData.discountType,
+ applyOncePerOrder:
+ formData.applyOncePerOrder,
+ discountValue:
+ formData.discountType.toString() ===
+ "SHIPPING"
+ ? 100
+ : decimal(formData.value),
+ discountValueType:
+ formData.discountType.toString() ===
+ "SHIPPING"
+ ? DiscountValueTypeEnum.PERCENTAGE
+ : formData.discountType,
endDate: connectDateTime(
formData.endDate,
formData.endTime
),
+ minAmountSpent: formData.minAmountSpent,
startDate: connectDateTime(
formData.startDate,
formData.startTime
),
- type: formData.type
+ type:
+ formData.discountType.toString() ===
+ "SHIPPING"
+ ? VoucherTypeEnum.ENTIRE_ORDER
+ : formData.type,
+ usageLimit: formData.usageLimit
}
}
});
diff --git a/saleor/static/dashboard-next/types/globalTypes.ts b/saleor/static/dashboard-next/types/globalTypes.ts
index 9648d426c6..e339f73536 100644
--- a/saleor/static/dashboard-next/types/globalTypes.ts
+++ b/saleor/static/dashboard-next/types/globalTypes.ts
@@ -8,28 +8,27 @@
export enum AddressTypeEnum {
BILLING = "BILLING",
- SHIPPING = "SHIPPING"
+ SHIPPING = "SHIPPING",
}
export enum AttributeTypeEnum {
PRODUCT = "PRODUCT",
- VARIANT = "VARIANT"
+ VARIANT = "VARIANT",
}
export enum AuthorizationKeyType {
FACEBOOK = "FACEBOOK",
- GOOGLE_OAUTH2 = "GOOGLE_OAUTH2"
+ GOOGLE_OAUTH2 = "GOOGLE_OAUTH2",
}
export enum DiscountValueTypeEnum {
FIXED = "FIXED",
PERCENTAGE = "PERCENTAGE",
- SHIPPING = "SHIPPING"
}
export enum FulfillmentStatus {
CANCELED = "CANCELED",
- FULFILLED = "FULFILLED"
+ FULFILLED = "FULFILLED",
}
export enum LanguageCodeEnum {
@@ -73,14 +72,14 @@ export enum LanguageCodeEnum {
UK = "UK",
VI = "VI",
ZH_HANS = "ZH_HANS",
- ZH_HANT = "ZH_HANT"
+ ZH_HANT = "ZH_HANT",
}
export enum OrderAction {
CAPTURE = "CAPTURE",
MARK_AS_PAID = "MARK_AS_PAID",
REFUND = "REFUND",
- VOID = "VOID"
+ VOID = "VOID",
}
export enum OrderEventsEmailsEnum {
@@ -89,7 +88,7 @@ export enum OrderEventsEmailsEnum {
ORDER_CONFIRMATION = "ORDER_CONFIRMATION",
PAYMENT_CONFIRMATION = "PAYMENT_CONFIRMATION",
SHIPPING_CONFIRMATION = "SHIPPING_CONFIRMATION",
- TRACKING_UPDATED = "TRACKING_UPDATED"
+ TRACKING_UPDATED = "TRACKING_UPDATED",
}
export enum OrderEventsEnum {
@@ -113,7 +112,7 @@ export enum OrderEventsEnum {
PLACED = "PLACED",
PLACED_FROM_DRAFT = "PLACED_FROM_DRAFT",
TRACKING_UPDATED = "TRACKING_UPDATED",
- UPDATED_ADDRESS = "UPDATED_ADDRESS"
+ UPDATED_ADDRESS = "UPDATED_ADDRESS",
}
export enum OrderStatus {
@@ -121,7 +120,7 @@ export enum OrderStatus {
DRAFT = "DRAFT",
FULFILLED = "FULFILLED",
PARTIALLY_FULFILLED = "PARTIALLY_FULFILLED",
- UNFULFILLED = "UNFULFILLED"
+ UNFULFILLED = "UNFULFILLED",
}
export enum OrderStatusFilter {
@@ -130,7 +129,7 @@ export enum OrderStatusFilter {
PARTIALLY_FULFILLED = "PARTIALLY_FULFILLED",
READY_TO_CAPTURE = "READY_TO_CAPTURE",
READY_TO_FULFILL = "READY_TO_FULFILL",
- UNFULFILLED = "UNFULFILLED"
+ UNFULFILLED = "UNFULFILLED",
}
export enum PaymentChargeStatusEnum {
@@ -138,7 +137,7 @@ export enum PaymentChargeStatusEnum {
FULLY_REFUNDED = "FULLY_REFUNDED",
NOT_CHARGED = "NOT_CHARGED",
PARTIALLY_CHARGED = "PARTIALLY_CHARGED",
- PARTIALLY_REFUNDED = "PARTIALLY_REFUNDED"
+ PARTIALLY_REFUNDED = "PARTIALLY_REFUNDED",
}
export enum PermissionEnum {
@@ -153,22 +152,22 @@ export enum PermissionEnum {
MANAGE_SHIPPING = "MANAGE_SHIPPING",
MANAGE_STAFF = "MANAGE_STAFF",
MANAGE_TRANSLATIONS = "MANAGE_TRANSLATIONS",
- MANAGE_USERS = "MANAGE_USERS"
+ MANAGE_USERS = "MANAGE_USERS",
}
export enum SaleType {
FIXED = "FIXED",
- PERCENTAGE = "PERCENTAGE"
+ PERCENTAGE = "PERCENTAGE",
}
export enum ShippingMethodTypeEnum {
PRICE = "PRICE",
- WEIGHT = "WEIGHT"
+ WEIGHT = "WEIGHT",
}
export enum StockAvailability {
IN_STOCK = "IN_STOCK",
- OUT_OF_STOCK = "OUT_OF_STOCK"
+ OUT_OF_STOCK = "OUT_OF_STOCK",
}
export enum TaxRateType {
@@ -196,13 +195,7 @@ export enum TaxRateType {
SOCIAL_HOUSING = "SOCIAL_HOUSING",
STANDARD = "STANDARD",
WATER = "WATER",
- WINE = "WINE"
-}
-
-export enum VoucherDiscountValueType {
- FIXED = "FIXED",
- PERCENTAGE = "PERCENTAGE",
- SHIPPING = "SHIPPING"
+ WINE = "WINE",
}
export enum VoucherType {
@@ -211,7 +204,7 @@ export enum VoucherType {
ENTIRE_ORDER = "ENTIRE_ORDER",
PRODUCT = "PRODUCT",
SHIPPING = "SHIPPING",
- SPECIFIC_PRODUCT = "SPECIFIC_PRODUCT"
+ SPECIFIC_PRODUCT = "SPECIFIC_PRODUCT",
}
export enum VoucherTypeEnum {
@@ -221,14 +214,14 @@ export enum VoucherTypeEnum {
PRODUCT = "PRODUCT",
SHIPPING = "SHIPPING",
SPECIFIC_PRODUCT = "SPECIFIC_PRODUCT",
- VALUE = "VALUE"
+ VALUE = "VALUE",
}
export enum WeightUnitsEnum {
G = "G",
KG = "KG",
LB = "LB",
- OZ = "OZ"
+ OZ = "OZ",
}
export interface AddressInput {
@@ -583,6 +576,7 @@ export interface VoucherInput {
minAmountSpent?: any | null;
countries?: (string | null)[] | null;
applyOncePerOrder?: boolean | null;
+ usageLimit?: number | null;
}
//==============================================================