saleor-dashboard/src/discounts/queries.ts

124 lines
2.4 KiB
TypeScript
Raw Normal View History

import {
saleDetailsFragment,
saleFragment,
voucherDetailsFragment,
voucherFragment
} from "@saleor/fragments/discounts";
import { pageInfoFragment } from "@saleor/fragments/pageInfo";
import makeQuery from "@saleor/hooks/makeQuery";
2019-06-19 14:40:52 +00:00
import gql from "graphql-tag";
import { TypedQuery } from "../queries";
2019-06-19 14:40:52 +00:00
import { SaleDetails, SaleDetailsVariables } from "./types/SaleDetails";
import { SaleList, SaleListVariables } from "./types/SaleList";
import {
VoucherDetails,
VoucherDetailsVariables
} from "./types/VoucherDetails";
import { VoucherList, VoucherListVariables } from "./types/VoucherList";
export const saleList = gql`
${pageInfoFragment}
${saleFragment}
2019-09-11 15:52:02 +00:00
query SaleList(
$after: String
$before: String
$first: Int
$last: Int
$filter: SaleFilterInput
2019-12-17 17:13:56 +00:00
$sort: SaleSortingInput
2019-09-11 15:52:02 +00:00
) {
sales(
after: $after
before: $before
first: $first
last: $last
filter: $filter
2019-12-17 17:13:56 +00:00
sortBy: $sort
2019-09-11 15:52:02 +00:00
) {
2019-06-19 14:40:52 +00:00
edges {
node {
...SaleFragment
}
}
pageInfo {
...PageInfoFragment
}
}
}
`;
2019-12-17 17:13:56 +00:00
export const useSaleListQuery = makeQuery<SaleList, SaleListVariables>(
saleList
);
2019-06-19 14:40:52 +00:00
export const voucherList = gql`
${pageInfoFragment}
${voucherFragment}
2019-09-12 10:06:28 +00:00
query VoucherList(
$after: String
$before: String
$first: Int
$last: Int
$filter: VoucherFilterInput
2019-12-17 17:13:56 +00:00
$sort: VoucherSortingInput
2019-09-12 10:06:28 +00:00
) {
vouchers(
after: $after
before: $before
first: $first
last: $last
filter: $filter
2019-12-17 17:13:56 +00:00
sortBy: $sort
2019-09-12 10:06:28 +00:00
) {
2019-06-19 14:40:52 +00:00
edges {
node {
...VoucherFragment
}
}
pageInfo {
...PageInfoFragment
}
}
}
`;
2019-12-17 17:13:56 +00:00
export const useVoucherListQuery = makeQuery<VoucherList, VoucherListVariables>(
2019-06-19 14:40:52 +00:00
voucherList
);
export const saleDetails = gql`
${saleDetailsFragment}
query SaleDetails(
$id: ID!
$after: String
$before: String
$first: Int
$last: Int
) {
sale(id: $id) {
...SaleDetailsFragment
}
}
`;
export const TypedSaleDetails = TypedQuery<SaleDetails, SaleDetailsVariables>(
saleDetails
);
const voucherDetails = gql`
${voucherDetailsFragment}
query VoucherDetails(
$id: ID!
$after: String
$before: String
$first: Int
$last: Int
) {
voucher(id: $id) {
...VoucherDetailsFragment
}
}
`;
export const TypedVoucherDetails = TypedQuery<
VoucherDetails,
VoucherDetailsVariables
>(voucherDetails);