Update types
This commit is contained in:
parent
041f8e9963
commit
9b542e7837
15 changed files with 153 additions and 60 deletions
|
@ -1509,6 +1509,20 @@ input DigitalContentUrlCreateInput {
|
|||
content: ID!
|
||||
}
|
||||
|
||||
type DiscountError {
|
||||
field: String
|
||||
message: String
|
||||
code: DiscountErrorCode!
|
||||
}
|
||||
|
||||
enum DiscountErrorCode {
|
||||
ALREADY_EXISTS
|
||||
INVALID
|
||||
NOT_FOUND
|
||||
REQUIRED
|
||||
UNIQUE
|
||||
}
|
||||
|
||||
enum DiscountStatusEnum {
|
||||
ACTIVE
|
||||
EXPIRED
|
||||
|
@ -3816,6 +3830,7 @@ type Sale implements Node {
|
|||
type SaleAddCatalogues {
|
||||
errors: [Error!]!
|
||||
sale: Sale
|
||||
discountErrors: [DiscountError!]!
|
||||
}
|
||||
|
||||
type SaleBulkDelete {
|
||||
|
@ -3836,11 +3851,13 @@ type SaleCountableEdge {
|
|||
|
||||
type SaleCreate {
|
||||
errors: [Error!]!
|
||||
discountErrors: [DiscountError!]!
|
||||
sale: Sale
|
||||
}
|
||||
|
||||
type SaleDelete {
|
||||
errors: [Error!]!
|
||||
discountErrors: [DiscountError!]!
|
||||
sale: Sale
|
||||
}
|
||||
|
||||
|
@ -3865,6 +3882,7 @@ input SaleInput {
|
|||
type SaleRemoveCatalogues {
|
||||
errors: [Error!]!
|
||||
sale: Sale
|
||||
discountErrors: [DiscountError!]!
|
||||
}
|
||||
|
||||
enum SaleSortField {
|
||||
|
@ -3905,6 +3923,7 @@ enum SaleType {
|
|||
|
||||
type SaleUpdate {
|
||||
errors: [Error!]!
|
||||
discountErrors: [DiscountError!]!
|
||||
sale: Sale
|
||||
}
|
||||
|
||||
|
@ -3920,15 +3939,15 @@ input SeoInput {
|
|||
|
||||
type ServiceAccount implements Node & ObjectWithMetadata {
|
||||
id: ID!
|
||||
name: String
|
||||
created: DateTime
|
||||
isActive: Boolean
|
||||
permissions: [PermissionDisplay]
|
||||
tokens: [ServiceAccountToken]
|
||||
privateMetadata: [MetadataItem]!
|
||||
metadata: [MetadataItem]!
|
||||
privateMeta: [MetaStore]! @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.11. use the `privetaMetadata` field instead. ")
|
||||
meta: [MetaStore]! @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.11. use the `metadata` field instead. ")
|
||||
permissions: [PermissionDisplay]
|
||||
name: String
|
||||
}
|
||||
|
||||
type ServiceAccountClearPrivateMeta {
|
||||
|
@ -4701,6 +4720,7 @@ type Voucher implements Node {
|
|||
type VoucherAddCatalogues {
|
||||
errors: [Error!]!
|
||||
voucher: Voucher
|
||||
discountErrors: [DiscountError!]!
|
||||
}
|
||||
|
||||
type VoucherBulkDelete {
|
||||
|
@ -4721,11 +4741,13 @@ type VoucherCountableEdge {
|
|||
|
||||
type VoucherCreate {
|
||||
errors: [Error!]!
|
||||
discountErrors: [DiscountError!]!
|
||||
voucher: Voucher
|
||||
}
|
||||
|
||||
type VoucherDelete {
|
||||
errors: [Error!]!
|
||||
discountErrors: [DiscountError!]!
|
||||
voucher: Voucher
|
||||
}
|
||||
|
||||
|
@ -4765,6 +4787,7 @@ input VoucherInput {
|
|||
type VoucherRemoveCatalogues {
|
||||
errors: [Error!]!
|
||||
voucher: Voucher
|
||||
discountErrors: [DiscountError!]!
|
||||
}
|
||||
|
||||
enum VoucherSortField {
|
||||
|
@ -4808,6 +4831,7 @@ enum VoucherTypeEnum {
|
|||
|
||||
type VoucherUpdate {
|
||||
errors: [Error!]!
|
||||
discountErrors: [DiscountError!]!
|
||||
voucher: Voucher
|
||||
}
|
||||
|
||||
|
|
|
@ -38,13 +38,20 @@ import { VoucherCreate, VoucherCreateVariables } from "./types/VoucherCreate";
|
|||
import { VoucherDelete, VoucherDeleteVariables } from "./types/VoucherDelete";
|
||||
import { VoucherUpdate, VoucherUpdateVariables } from "./types/VoucherUpdate";
|
||||
|
||||
const discountErrorFragment = gql`
|
||||
fragment DiscountErrorFragment on DiscountError {
|
||||
code
|
||||
field
|
||||
}
|
||||
`;
|
||||
|
||||
const saleUpdate = gql`
|
||||
${discountErrorFragment}
|
||||
${saleFragment}
|
||||
mutation SaleUpdate($input: SaleInput!, $id: ID!) {
|
||||
saleUpdate(id: $id, input: $input) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
errors: discountErrors {
|
||||
...DiscountErrorFragment
|
||||
}
|
||||
sale {
|
||||
...SaleFragment
|
||||
|
@ -57,6 +64,7 @@ export const TypedSaleUpdate = TypedMutation<SaleUpdate, SaleUpdateVariables>(
|
|||
);
|
||||
|
||||
const saleCataloguesAdd = gql`
|
||||
${discountErrorFragment}
|
||||
${saleDetailsFragment}
|
||||
mutation SaleCataloguesAdd(
|
||||
$input: CatalogueInput!
|
||||
|
@ -67,9 +75,8 @@ const saleCataloguesAdd = gql`
|
|||
$last: Int
|
||||
) {
|
||||
saleCataloguesAdd(id: $id, input: $input) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
errors: discountErrors {
|
||||
...DiscountErrorFragment
|
||||
}
|
||||
sale {
|
||||
...SaleDetailsFragment
|
||||
|
@ -83,6 +90,7 @@ export const TypedSaleCataloguesAdd = TypedMutation<
|
|||
>(saleCataloguesAdd);
|
||||
|
||||
const saleCataloguesRemove = gql`
|
||||
${discountErrorFragment}
|
||||
${saleDetailsFragment}
|
||||
mutation SaleCataloguesRemove(
|
||||
$input: CatalogueInput!
|
||||
|
@ -93,9 +101,8 @@ const saleCataloguesRemove = gql`
|
|||
$last: Int
|
||||
) {
|
||||
saleCataloguesRemove(id: $id, input: $input) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
errors: discountErrors {
|
||||
...DiscountErrorFragment
|
||||
}
|
||||
sale {
|
||||
...SaleDetailsFragment
|
||||
|
@ -109,12 +116,12 @@ export const TypedSaleCataloguesRemove = TypedMutation<
|
|||
>(saleCataloguesRemove);
|
||||
|
||||
const saleCreate = gql`
|
||||
${discountErrorFragment}
|
||||
${saleFragment}
|
||||
mutation SaleCreate($input: SaleInput!) {
|
||||
saleCreate(input: $input) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
errors: discountErrors {
|
||||
...DiscountErrorFragment
|
||||
}
|
||||
sale {
|
||||
...SaleFragment
|
||||
|
@ -127,11 +134,11 @@ export const TypedSaleCreate = TypedMutation<SaleCreate, SaleCreateVariables>(
|
|||
);
|
||||
|
||||
const saleDelete = gql`
|
||||
${discountErrorFragment}
|
||||
mutation SaleDelete($id: ID!) {
|
||||
saleDelete(id: $id) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
errors: discountErrors {
|
||||
...DiscountErrorFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,12 +163,12 @@ export const TypedSaleBulkDelete = TypedMutation<
|
|||
>(saleBulkDelete);
|
||||
|
||||
const voucherUpdate = gql`
|
||||
${discountErrorFragment}
|
||||
${voucherFragment}
|
||||
mutation VoucherUpdate($input: VoucherInput!, $id: ID!) {
|
||||
voucherUpdate(id: $id, input: $input) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
errors: discountErrors {
|
||||
...DiscountErrorFragment
|
||||
}
|
||||
voucher {
|
||||
...VoucherFragment
|
||||
|
@ -175,6 +182,7 @@ export const TypedVoucherUpdate = TypedMutation<
|
|||
>(voucherUpdate);
|
||||
|
||||
const voucherCataloguesAdd = gql`
|
||||
${discountErrorFragment}
|
||||
${voucherDetailsFragment}
|
||||
mutation VoucherCataloguesAdd(
|
||||
$input: CatalogueInput!
|
||||
|
@ -185,9 +193,8 @@ const voucherCataloguesAdd = gql`
|
|||
$last: Int
|
||||
) {
|
||||
voucherCataloguesAdd(id: $id, input: $input) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
errors: discountErrors {
|
||||
...DiscountErrorFragment
|
||||
}
|
||||
voucher {
|
||||
...VoucherDetailsFragment
|
||||
|
@ -201,6 +208,7 @@ export const TypedVoucherCataloguesAdd = TypedMutation<
|
|||
>(voucherCataloguesAdd);
|
||||
|
||||
const voucherCataloguesRemove = gql`
|
||||
${discountErrorFragment}
|
||||
${voucherDetailsFragment}
|
||||
mutation VoucherCataloguesRemove(
|
||||
$input: CatalogueInput!
|
||||
|
@ -211,9 +219,8 @@ const voucherCataloguesRemove = gql`
|
|||
$last: Int
|
||||
) {
|
||||
voucherCataloguesRemove(id: $id, input: $input) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
errors: discountErrors {
|
||||
...DiscountErrorFragment
|
||||
}
|
||||
voucher {
|
||||
...VoucherDetailsFragment
|
||||
|
@ -227,12 +234,12 @@ export const TypedVoucherCataloguesRemove = TypedMutation<
|
|||
>(voucherCataloguesRemove);
|
||||
|
||||
const voucherCreate = gql`
|
||||
${discountErrorFragment}
|
||||
${voucherFragment}
|
||||
mutation VoucherCreate($input: VoucherInput!) {
|
||||
voucherCreate(input: $input) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
errors: discountErrors {
|
||||
...DiscountErrorFragment
|
||||
}
|
||||
voucher {
|
||||
...VoucherFragment
|
||||
|
@ -246,11 +253,11 @@ export const TypedVoucherCreate = TypedMutation<
|
|||
>(voucherCreate);
|
||||
|
||||
const voucherDelete = gql`
|
||||
${discountErrorFragment}
|
||||
mutation VoucherDelete($id: ID!) {
|
||||
voucherDelete(id: $id) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
errors: discountErrors {
|
||||
...DiscountErrorFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
15
src/discounts/types/DiscountErrorFragment.ts
Normal file
15
src/discounts/types/DiscountErrorFragment.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { DiscountErrorCode } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL fragment: DiscountErrorFragment
|
||||
// ====================================================
|
||||
|
||||
export interface DiscountErrorFragment {
|
||||
__typename: "DiscountError";
|
||||
code: DiscountErrorCode;
|
||||
field: string | null;
|
||||
}
|
|
@ -2,16 +2,16 @@
|
|||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { CatalogueInput, SaleType } from "./../../types/globalTypes";
|
||||
import { CatalogueInput, DiscountErrorCode, SaleType } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL mutation operation: SaleCataloguesAdd
|
||||
// ====================================================
|
||||
|
||||
export interface SaleCataloguesAdd_saleCataloguesAdd_errors {
|
||||
__typename: "Error";
|
||||
__typename: "DiscountError";
|
||||
code: DiscountErrorCode;
|
||||
field: string | null;
|
||||
message: string | null;
|
||||
}
|
||||
|
||||
export interface SaleCataloguesAdd_saleCataloguesAdd_sale_products_edges_node_productType {
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { CatalogueInput, SaleType } from "./../../types/globalTypes";
|
||||
import { CatalogueInput, DiscountErrorCode, SaleType } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL mutation operation: SaleCataloguesRemove
|
||||
// ====================================================
|
||||
|
||||
export interface SaleCataloguesRemove_saleCataloguesRemove_errors {
|
||||
__typename: "Error";
|
||||
__typename: "DiscountError";
|
||||
code: DiscountErrorCode;
|
||||
field: string | null;
|
||||
message: string | null;
|
||||
}
|
||||
|
||||
export interface SaleCataloguesRemove_saleCataloguesRemove_sale_products_edges_node_productType {
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { SaleInput, SaleType } from "./../../types/globalTypes";
|
||||
import { SaleInput, DiscountErrorCode, SaleType } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL mutation operation: SaleCreate
|
||||
// ====================================================
|
||||
|
||||
export interface SaleCreate_saleCreate_errors {
|
||||
__typename: "Error";
|
||||
__typename: "DiscountError";
|
||||
code: DiscountErrorCode;
|
||||
field: string | null;
|
||||
message: string | null;
|
||||
}
|
||||
|
||||
export interface SaleCreate_saleCreate_sale {
|
||||
|
|
|
@ -2,14 +2,16 @@
|
|||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { DiscountErrorCode } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL mutation operation: SaleDelete
|
||||
// ====================================================
|
||||
|
||||
export interface SaleDelete_saleDelete_errors {
|
||||
__typename: "Error";
|
||||
__typename: "DiscountError";
|
||||
code: DiscountErrorCode;
|
||||
field: string | null;
|
||||
message: string | null;
|
||||
}
|
||||
|
||||
export interface SaleDelete_saleDelete {
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { SaleInput, SaleType } from "./../../types/globalTypes";
|
||||
import { SaleInput, DiscountErrorCode, SaleType } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL mutation operation: SaleUpdate
|
||||
// ====================================================
|
||||
|
||||
export interface SaleUpdate_saleUpdate_errors {
|
||||
__typename: "Error";
|
||||
__typename: "DiscountError";
|
||||
code: DiscountErrorCode;
|
||||
field: string | null;
|
||||
message: string | null;
|
||||
}
|
||||
|
||||
export interface SaleUpdate_saleUpdate_sale {
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { CatalogueInput, DiscountValueTypeEnum, VoucherTypeEnum } from "./../../types/globalTypes";
|
||||
import { CatalogueInput, DiscountErrorCode, DiscountValueTypeEnum, VoucherTypeEnum } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL mutation operation: VoucherCataloguesAdd
|
||||
// ====================================================
|
||||
|
||||
export interface VoucherCataloguesAdd_voucherCataloguesAdd_errors {
|
||||
__typename: "Error";
|
||||
__typename: "DiscountError";
|
||||
code: DiscountErrorCode;
|
||||
field: string | null;
|
||||
message: string | null;
|
||||
}
|
||||
|
||||
export interface VoucherCataloguesAdd_voucherCataloguesAdd_voucher_countries {
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { CatalogueInput, DiscountValueTypeEnum, VoucherTypeEnum } from "./../../types/globalTypes";
|
||||
import { CatalogueInput, DiscountErrorCode, DiscountValueTypeEnum, VoucherTypeEnum } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL mutation operation: VoucherCataloguesRemove
|
||||
// ====================================================
|
||||
|
||||
export interface VoucherCataloguesRemove_voucherCataloguesRemove_errors {
|
||||
__typename: "Error";
|
||||
__typename: "DiscountError";
|
||||
code: DiscountErrorCode;
|
||||
field: string | null;
|
||||
message: string | null;
|
||||
}
|
||||
|
||||
export interface VoucherCataloguesRemove_voucherCataloguesRemove_voucher_countries {
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { VoucherInput, DiscountValueTypeEnum } from "./../../types/globalTypes";
|
||||
import { VoucherInput, DiscountErrorCode, DiscountValueTypeEnum } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL mutation operation: VoucherCreate
|
||||
// ====================================================
|
||||
|
||||
export interface VoucherCreate_voucherCreate_errors {
|
||||
__typename: "Error";
|
||||
__typename: "DiscountError";
|
||||
code: DiscountErrorCode;
|
||||
field: string | null;
|
||||
message: string | null;
|
||||
}
|
||||
|
||||
export interface VoucherCreate_voucherCreate_voucher_countries {
|
||||
|
|
|
@ -2,14 +2,16 @@
|
|||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { DiscountErrorCode } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL mutation operation: VoucherDelete
|
||||
// ====================================================
|
||||
|
||||
export interface VoucherDelete_voucherDelete_errors {
|
||||
__typename: "Error";
|
||||
__typename: "DiscountError";
|
||||
code: DiscountErrorCode;
|
||||
field: string | null;
|
||||
message: string | null;
|
||||
}
|
||||
|
||||
export interface VoucherDelete_voucherDelete {
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { VoucherInput, DiscountValueTypeEnum } from "./../../types/globalTypes";
|
||||
import { VoucherInput, DiscountErrorCode, DiscountValueTypeEnum } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL mutation operation: VoucherUpdate
|
||||
// ====================================================
|
||||
|
||||
export interface VoucherUpdate_voucherUpdate_errors {
|
||||
__typename: "Error";
|
||||
__typename: "DiscountError";
|
||||
code: DiscountErrorCode;
|
||||
field: string | null;
|
||||
message: string | null;
|
||||
}
|
||||
|
||||
export interface VoucherUpdate_voucherUpdate_voucher_countries {
|
||||
|
|
|
@ -346,6 +346,14 @@ export enum CountryCode {
|
|||
ZW = "ZW",
|
||||
}
|
||||
|
||||
export enum DiscountErrorCode {
|
||||
ALREADY_EXISTS = "ALREADY_EXISTS",
|
||||
INVALID = "INVALID",
|
||||
NOT_FOUND = "NOT_FOUND",
|
||||
REQUIRED = "REQUIRED",
|
||||
UNIQUE = "UNIQUE",
|
||||
}
|
||||
|
||||
export enum DiscountStatusEnum {
|
||||
ACTIVE = "ACTIVE",
|
||||
EXPIRED = "EXPIRED",
|
||||
|
|
35
src/utils/errors/discounts.ts
Normal file
35
src/utils/errors/discounts.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { IntlShape, defineMessages } from "react-intl";
|
||||
|
||||
import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment";
|
||||
import { DiscountErrorCode } from "@saleor/types/globalTypes";
|
||||
import { commonMessages } from "@saleor/intl";
|
||||
import commonErrorMessages from "./common";
|
||||
|
||||
const messages = defineMessages({
|
||||
alreadyExists: {
|
||||
defaultMessage: "Promo code already exists",
|
||||
description: "error message"
|
||||
}
|
||||
});
|
||||
|
||||
function getDiscountErrorMessage(
|
||||
err: Omit<DiscountErrorFragment, "__typename"> | undefined,
|
||||
intl: IntlShape
|
||||
): string {
|
||||
if (err) {
|
||||
switch (err.code) {
|
||||
case DiscountErrorCode.ALREADY_EXISTS:
|
||||
return intl.formatMessage(messages.alreadyExists);
|
||||
case DiscountErrorCode.REQUIRED:
|
||||
return intl.formatMessage(commonMessages.requiredField);
|
||||
case DiscountErrorCode.INVALID:
|
||||
return intl.formatMessage(commonErrorMessages.invalid);
|
||||
default:
|
||||
return intl.formatMessage(commonErrorMessages.unknownError);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export default getDiscountErrorMessage;
|
Loading…
Reference in a new issue