saleor-dashboard/src/fragments/discounts.ts
Łukasz Szewczyk ec230e55c0
Add variants to sale view (#1420)
* Update schema and biuld types for sale per variant

* Create variant search module and generate types for it

* Add listing component for sale view

* Create dialog for variant assignment

* Expand sale page with vairnats

* Add new sale fixtures

* Add transaltions for variants on sale view

* Update snapshot

* Refactor sales dialogs and tables, move styles and ittl to local files

* Rework search dialog. Create item/subitem selectable table for variants, update spapshot

* Adjust table columns width

* Standardize the tables

* Unify messages

* Drop whole variant object in favor of just ids, simplify filtring functions

* Update snapshots

Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-09-30 14:51:13 +02:00

214 lines
4 KiB
TypeScript

import { metadataFragment } from "@saleor/fragments/metadata";
import { channelListingProductWithoutPricingFragment } from "@saleor/fragments/products";
import gql from "graphql-tag";
import { pageInfoFragment } from "./pageInfo";
export const saleFragment = gql`
${metadataFragment}
fragment SaleFragment on Sale {
...MetadataFragment
id
name
type
startDate
endDate
channelListings {
id
channel {
id
name
currencyCode
}
discountValue
currency
}
}
`;
export const saleDetailsFragment = gql`
${channelListingProductWithoutPricingFragment}
${pageInfoFragment}
${saleFragment}
fragment SaleDetailsFragment on Sale {
...SaleFragment
variants(after: $after, before: $before, first: $first, last: $last) {
edges {
node {
id
name
product {
id
name
thumbnail {
url
}
productType {
id
name
}
channelListings {
...ChannelListingProductWithoutPricingFragment
}
}
}
}
pageInfo {
...PageInfoFragment
}
totalCount
}
products(after: $after, before: $before, first: $first, last: $last) {
edges {
node {
id
name
productType {
id
name
}
thumbnail {
url
}
channelListings {
...ChannelListingProductWithoutPricingFragment
}
}
}
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`
${metadataFragment}
fragment VoucherFragment on Voucher {
...MetadataFragment
id
code
startDate
endDate
usageLimit
type
discountValueType
countries {
code
country
}
minCheckoutItemsQuantity
channelListings {
id
channel {
id
name
currencyCode
}
discountValue
currency
minSpent {
amount
currency
}
}
}
`;
export const voucherDetailsFragment = gql`
${pageInfoFragment}
${voucherFragment}
${channelListingProductWithoutPricingFragment}
fragment VoucherDetailsFragment on Voucher {
...VoucherFragment
code
usageLimit
used
applyOncePerOrder
applyOncePerCustomer
onlyForStaff
products(after: $after, before: $before, first: $first, last: $last) {
edges {
node {
id
name
productType {
id
name
}
thumbnail {
url
}
channelListings {
...ChannelListingProductWithoutPricingFragment
}
}
}
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
}
}
}
`;