2019-06-19 14:40:52 +00:00
|
|
|
import gql from "graphql-tag";
|
|
|
|
|
2019-12-17 17:13:56 +00:00
|
|
|
import makeQuery from "@saleor/hooks/makeQuery";
|
2019-06-19 14:40:52 +00:00
|
|
|
import { pageInfoFragment, TypedQuery } from "../queries";
|
|
|
|
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 saleFragment = gql`
|
|
|
|
fragment SaleFragment on Sale {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
type
|
|
|
|
startDate
|
|
|
|
endDate
|
|
|
|
value
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const saleDetailsFragment = gql`
|
|
|
|
${pageInfoFragment}
|
|
|
|
${saleFragment}
|
|
|
|
fragment SaleDetailsFragment on Sale {
|
|
|
|
...SaleFragment
|
|
|
|
products(after: $after, before: $before, first: $first, last: $last) {
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
isPublished
|
|
|
|
productType {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
thumbnail {
|
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pageInfo {
|
|
|
|
...PageInfoFragment
|
|
|
|
}
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
categories(after: $after, before: $before, first: $first, last: $last) {
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
products {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pageInfo {
|
|
|
|
...PageInfoFragment
|
|
|
|
}
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
collections(after: $after, before: $before, first: $first, last: $last) {
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
products {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pageInfo {
|
|
|
|
...PageInfoFragment
|
|
|
|
}
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const voucherFragment = gql`
|
|
|
|
fragment VoucherFragment on Voucher {
|
|
|
|
id
|
2019-08-09 11:14:35 +00:00
|
|
|
code
|
2019-06-19 14:40:52 +00:00
|
|
|
startDate
|
|
|
|
endDate
|
|
|
|
usageLimit
|
|
|
|
discountValueType
|
|
|
|
discountValue
|
|
|
|
countries {
|
|
|
|
code
|
|
|
|
country
|
|
|
|
}
|
|
|
|
minAmountSpent {
|
|
|
|
currency
|
|
|
|
amount
|
|
|
|
}
|
2019-08-09 11:14:35 +00:00
|
|
|
minCheckoutItemsQuantity
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const voucherDetailsFragment = gql`
|
|
|
|
${pageInfoFragment}
|
|
|
|
${voucherFragment}
|
|
|
|
fragment VoucherDetailsFragment on Voucher {
|
|
|
|
...VoucherFragment
|
|
|
|
type
|
|
|
|
code
|
|
|
|
usageLimit
|
|
|
|
used
|
|
|
|
applyOncePerOrder
|
2019-08-09 11:14:35 +00:00
|
|
|
applyOncePerCustomer
|
2019-06-19 14:40:52 +00:00
|
|
|
products(after: $after, before: $before, first: $first, last: $last) {
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
productType {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
isPublished
|
|
|
|
thumbnail {
|
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
totalCount
|
|
|
|
pageInfo {
|
|
|
|
...PageInfoFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
collections(after: $after, before: $before, first: $first, last: $last) {
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
products {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
totalCount
|
|
|
|
pageInfo {
|
|
|
|
...PageInfoFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
categories(after: $after, before: $before, first: $first, last: $last) {
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
products {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
totalCount
|
|
|
|
pageInfo {
|
|
|
|
...PageInfoFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
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);
|