2019-06-19 14:40:52 +00:00
|
|
|
import {
|
|
|
|
saleDetailsFragment,
|
|
|
|
saleFragment,
|
|
|
|
voucherDetailsFragment,
|
|
|
|
voucherFragment
|
2020-07-07 10:14:12 +00:00
|
|
|
} from "@saleor/fragments/discounts";
|
|
|
|
import { discountErrorFragment } from "@saleor/fragments/errors";
|
|
|
|
import gql from "graphql-tag";
|
|
|
|
|
|
|
|
import { TypedMutation } from "../mutations";
|
2019-06-19 14:40:52 +00:00
|
|
|
import {
|
|
|
|
SaleBulkDelete,
|
|
|
|
SaleBulkDeleteVariables
|
|
|
|
} from "./types/SaleBulkDelete";
|
|
|
|
import {
|
|
|
|
SaleCataloguesAdd,
|
|
|
|
SaleCataloguesAddVariables
|
|
|
|
} from "./types/SaleCataloguesAdd";
|
|
|
|
import {
|
|
|
|
SaleCataloguesRemove,
|
|
|
|
SaleCataloguesRemoveVariables
|
|
|
|
} from "./types/SaleCataloguesRemove";
|
|
|
|
import { SaleCreate, SaleCreateVariables } from "./types/SaleCreate";
|
|
|
|
import { SaleDelete, SaleDeleteVariables } from "./types/SaleDelete";
|
|
|
|
import { SaleUpdate, SaleUpdateVariables } from "./types/SaleUpdate";
|
|
|
|
import {
|
|
|
|
VoucherBulkDelete,
|
|
|
|
VoucherBulkDeleteVariables
|
|
|
|
} from "./types/VoucherBulkDelete";
|
|
|
|
import {
|
|
|
|
VoucherCataloguesAdd,
|
|
|
|
VoucherCataloguesAddVariables
|
|
|
|
} from "./types/VoucherCataloguesAdd";
|
|
|
|
import {
|
|
|
|
VoucherCataloguesRemove,
|
|
|
|
VoucherCataloguesRemoveVariables
|
|
|
|
} from "./types/VoucherCataloguesRemove";
|
|
|
|
import { VoucherCreate, VoucherCreateVariables } from "./types/VoucherCreate";
|
|
|
|
import { VoucherDelete, VoucherDeleteVariables } from "./types/VoucherDelete";
|
|
|
|
import { VoucherUpdate, VoucherUpdateVariables } from "./types/VoucherUpdate";
|
|
|
|
|
|
|
|
const saleUpdate = gql`
|
2020-03-23 17:59:10 +00:00
|
|
|
${discountErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${saleFragment}
|
|
|
|
mutation SaleUpdate($input: SaleInput!, $id: ID!) {
|
|
|
|
saleUpdate(id: $id, input: $input) {
|
2020-03-23 17:59:10 +00:00
|
|
|
errors: discountErrors {
|
|
|
|
...DiscountErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
sale {
|
|
|
|
...SaleFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedSaleUpdate = TypedMutation<SaleUpdate, SaleUpdateVariables>(
|
|
|
|
saleUpdate
|
|
|
|
);
|
|
|
|
|
|
|
|
const saleCataloguesAdd = gql`
|
2020-03-23 17:59:10 +00:00
|
|
|
${discountErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${saleDetailsFragment}
|
|
|
|
mutation SaleCataloguesAdd(
|
|
|
|
$input: CatalogueInput!
|
|
|
|
$id: ID!
|
|
|
|
$after: String
|
|
|
|
$before: String
|
|
|
|
$first: Int
|
|
|
|
$last: Int
|
|
|
|
) {
|
|
|
|
saleCataloguesAdd(id: $id, input: $input) {
|
2020-03-23 17:59:10 +00:00
|
|
|
errors: discountErrors {
|
|
|
|
...DiscountErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
sale {
|
|
|
|
...SaleDetailsFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedSaleCataloguesAdd = TypedMutation<
|
|
|
|
SaleCataloguesAdd,
|
|
|
|
SaleCataloguesAddVariables
|
|
|
|
>(saleCataloguesAdd);
|
|
|
|
|
|
|
|
const saleCataloguesRemove = gql`
|
2020-03-23 17:59:10 +00:00
|
|
|
${discountErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${saleDetailsFragment}
|
|
|
|
mutation SaleCataloguesRemove(
|
|
|
|
$input: CatalogueInput!
|
|
|
|
$id: ID!
|
|
|
|
$after: String
|
|
|
|
$before: String
|
|
|
|
$first: Int
|
|
|
|
$last: Int
|
|
|
|
) {
|
|
|
|
saleCataloguesRemove(id: $id, input: $input) {
|
2020-03-23 17:59:10 +00:00
|
|
|
errors: discountErrors {
|
|
|
|
...DiscountErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
sale {
|
|
|
|
...SaleDetailsFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedSaleCataloguesRemove = TypedMutation<
|
|
|
|
SaleCataloguesRemove,
|
|
|
|
SaleCataloguesRemoveVariables
|
|
|
|
>(saleCataloguesRemove);
|
|
|
|
|
|
|
|
const saleCreate = gql`
|
2020-03-23 17:59:10 +00:00
|
|
|
${discountErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${saleFragment}
|
|
|
|
mutation SaleCreate($input: SaleInput!) {
|
|
|
|
saleCreate(input: $input) {
|
2020-03-23 17:59:10 +00:00
|
|
|
errors: discountErrors {
|
|
|
|
...DiscountErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
sale {
|
|
|
|
...SaleFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedSaleCreate = TypedMutation<SaleCreate, SaleCreateVariables>(
|
|
|
|
saleCreate
|
|
|
|
);
|
|
|
|
|
|
|
|
const saleDelete = gql`
|
2020-03-23 17:59:10 +00:00
|
|
|
${discountErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation SaleDelete($id: ID!) {
|
|
|
|
saleDelete(id: $id) {
|
2020-03-23 17:59:10 +00:00
|
|
|
errors: discountErrors {
|
|
|
|
...DiscountErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedSaleDelete = TypedMutation<SaleDelete, SaleDeleteVariables>(
|
|
|
|
saleDelete
|
|
|
|
);
|
|
|
|
|
|
|
|
const saleBulkDelete = gql`
|
|
|
|
mutation SaleBulkDelete($ids: [ID]!) {
|
|
|
|
saleBulkDelete(ids: $ids) {
|
|
|
|
errors {
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedSaleBulkDelete = TypedMutation<
|
|
|
|
SaleBulkDelete,
|
|
|
|
SaleBulkDeleteVariables
|
|
|
|
>(saleBulkDelete);
|
|
|
|
|
|
|
|
const voucherUpdate = gql`
|
2020-03-23 17:59:10 +00:00
|
|
|
${discountErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${voucherFragment}
|
|
|
|
mutation VoucherUpdate($input: VoucherInput!, $id: ID!) {
|
|
|
|
voucherUpdate(id: $id, input: $input) {
|
2020-03-23 17:59:10 +00:00
|
|
|
errors: discountErrors {
|
|
|
|
...DiscountErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
voucher {
|
|
|
|
...VoucherFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedVoucherUpdate = TypedMutation<
|
|
|
|
VoucherUpdate,
|
|
|
|
VoucherUpdateVariables
|
|
|
|
>(voucherUpdate);
|
|
|
|
|
|
|
|
const voucherCataloguesAdd = gql`
|
2020-03-23 17:59:10 +00:00
|
|
|
${discountErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${voucherDetailsFragment}
|
|
|
|
mutation VoucherCataloguesAdd(
|
|
|
|
$input: CatalogueInput!
|
|
|
|
$id: ID!
|
|
|
|
$after: String
|
|
|
|
$before: String
|
|
|
|
$first: Int
|
|
|
|
$last: Int
|
|
|
|
) {
|
|
|
|
voucherCataloguesAdd(id: $id, input: $input) {
|
2020-03-23 17:59:10 +00:00
|
|
|
errors: discountErrors {
|
|
|
|
...DiscountErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
voucher {
|
|
|
|
...VoucherDetailsFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedVoucherCataloguesAdd = TypedMutation<
|
|
|
|
VoucherCataloguesAdd,
|
|
|
|
VoucherCataloguesAddVariables
|
|
|
|
>(voucherCataloguesAdd);
|
|
|
|
|
|
|
|
const voucherCataloguesRemove = gql`
|
2020-03-23 17:59:10 +00:00
|
|
|
${discountErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${voucherDetailsFragment}
|
|
|
|
mutation VoucherCataloguesRemove(
|
|
|
|
$input: CatalogueInput!
|
|
|
|
$id: ID!
|
|
|
|
$after: String
|
|
|
|
$before: String
|
|
|
|
$first: Int
|
|
|
|
$last: Int
|
|
|
|
) {
|
|
|
|
voucherCataloguesRemove(id: $id, input: $input) {
|
2020-03-23 17:59:10 +00:00
|
|
|
errors: discountErrors {
|
|
|
|
...DiscountErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
voucher {
|
|
|
|
...VoucherDetailsFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedVoucherCataloguesRemove = TypedMutation<
|
|
|
|
VoucherCataloguesRemove,
|
|
|
|
VoucherCataloguesRemoveVariables
|
|
|
|
>(voucherCataloguesRemove);
|
|
|
|
|
|
|
|
const voucherCreate = gql`
|
2020-03-23 17:59:10 +00:00
|
|
|
${discountErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
${voucherFragment}
|
|
|
|
mutation VoucherCreate($input: VoucherInput!) {
|
|
|
|
voucherCreate(input: $input) {
|
2020-03-23 17:59:10 +00:00
|
|
|
errors: discountErrors {
|
|
|
|
...DiscountErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
voucher {
|
|
|
|
...VoucherFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedVoucherCreate = TypedMutation<
|
|
|
|
VoucherCreate,
|
|
|
|
VoucherCreateVariables
|
|
|
|
>(voucherCreate);
|
|
|
|
|
|
|
|
const voucherDelete = gql`
|
2020-03-23 17:59:10 +00:00
|
|
|
${discountErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation VoucherDelete($id: ID!) {
|
|
|
|
voucherDelete(id: $id) {
|
2020-03-23 17:59:10 +00:00
|
|
|
errors: discountErrors {
|
|
|
|
...DiscountErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedVoucherDelete = TypedMutation<
|
|
|
|
VoucherDelete,
|
|
|
|
VoucherDeleteVariables
|
|
|
|
>(voucherDelete);
|
|
|
|
|
|
|
|
const voucherBulkDelete = gql`
|
|
|
|
mutation VoucherBulkDelete($ids: [ID]!) {
|
|
|
|
voucherBulkDelete(ids: $ids) {
|
|
|
|
errors {
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedVoucherBulkDelete = TypedMutation<
|
|
|
|
VoucherBulkDelete,
|
|
|
|
VoucherBulkDeleteVariables
|
|
|
|
>(voucherBulkDelete);
|