
* Add component backbone * Make step component generic and typed * Add step tabs * Add settings view * Encapsulate all dialog components in one directory * Move types to separate file * Add mutations * Use gql types * Add error handling * Do not keep separate types file * Allow products to be exported * Fix types * Update snapshots * Update to latest schema * Add disabled option * Use wizard hook * Update type definitions * Queue export check task * Fix bug causing jobs to be endless and duplicated * Fix minor bugs * Add accordion component * Allow selection of fields to be exported * Add attribute export * Update snapshots * Update messages * Update changelog * Add missing key * Add quick peek to accordioin * Sort imports * Remove unused files * Add chiips to attribute selection * Change menu positioning * Add product counter * Add select all option * Update snapshots * Update messages * Remove unused import * Add chips * Add test tags * Update snapshots * Change number of max chips * Add accordion tags * Update messages
315 lines
6.4 KiB
TypeScript
315 lines
6.4 KiB
TypeScript
import { pageInfoFragment } from "@saleor/fragments/pageInfo";
|
|
import {
|
|
fragmentMoney,
|
|
fragmentVariant,
|
|
productFragment,
|
|
productFragmentDetails,
|
|
productVariantAttributesFragment
|
|
} from "@saleor/fragments/products";
|
|
import { warehouseFragment } from "@saleor/fragments/warehouses";
|
|
import makeQuery from "@saleor/hooks/makeQuery";
|
|
import gql from "graphql-tag";
|
|
|
|
import { TypedQuery } from "../queries";
|
|
import { CountAllProducts } from "./types/CountAllProducts";
|
|
import {
|
|
CreateMultipleVariantsData,
|
|
CreateMultipleVariantsDataVariables
|
|
} from "./types/CreateMultipleVariantsData";
|
|
import {
|
|
GridAttributes,
|
|
GridAttributesVariables
|
|
} from "./types/GridAttributes";
|
|
import {
|
|
InitialProductFilterData,
|
|
InitialProductFilterDataVariables
|
|
} from "./types/InitialProductFilterData";
|
|
import {
|
|
ProductDetails,
|
|
ProductDetailsVariables
|
|
} from "./types/ProductDetails";
|
|
import {
|
|
ProductImageById,
|
|
ProductImageByIdVariables
|
|
} from "./types/ProductImageById";
|
|
import { ProductList, ProductListVariables } from "./types/ProductList";
|
|
import {
|
|
ProductVariantCreateData,
|
|
ProductVariantCreateDataVariables
|
|
} from "./types/ProductVariantCreateData";
|
|
import {
|
|
ProductVariantDetails,
|
|
ProductVariantDetailsVariables
|
|
} from "./types/ProductVariantDetails";
|
|
|
|
const initialProductFilterDataQuery = gql`
|
|
query InitialProductFilterData(
|
|
$categories: [ID!]
|
|
$collections: [ID!]
|
|
$productTypes: [ID!]
|
|
) {
|
|
attributes(first: 100, filter: { filterableInDashboard: true }) {
|
|
edges {
|
|
node {
|
|
id
|
|
name
|
|
slug
|
|
values {
|
|
id
|
|
name
|
|
slug
|
|
}
|
|
}
|
|
}
|
|
}
|
|
categories(first: 100, filter: { ids: $categories }) {
|
|
edges {
|
|
node {
|
|
id
|
|
name
|
|
}
|
|
}
|
|
}
|
|
collections(first: 100, filter: { ids: $collections }) {
|
|
edges {
|
|
node {
|
|
id
|
|
name
|
|
}
|
|
}
|
|
}
|
|
productTypes(first: 100, filter: { ids: $productTypes }) {
|
|
edges {
|
|
node {
|
|
id
|
|
name
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
export const useInitialProductFilterDataQuery = makeQuery<
|
|
InitialProductFilterData,
|
|
InitialProductFilterDataVariables
|
|
>(initialProductFilterDataQuery);
|
|
|
|
const productListQuery = gql`
|
|
${fragmentMoney}
|
|
${productFragment}
|
|
query ProductList(
|
|
$first: Int
|
|
$after: String
|
|
$last: Int
|
|
$before: String
|
|
$filter: ProductFilterInput
|
|
$sort: ProductOrder
|
|
) {
|
|
products(
|
|
before: $before
|
|
after: $after
|
|
first: $first
|
|
last: $last
|
|
filter: $filter
|
|
sortBy: $sort
|
|
) {
|
|
edges {
|
|
node {
|
|
...ProductFragment
|
|
attributes {
|
|
attribute {
|
|
id
|
|
}
|
|
values {
|
|
id
|
|
name
|
|
}
|
|
}
|
|
pricing {
|
|
priceRangeUndiscounted {
|
|
start {
|
|
gross {
|
|
...Money
|
|
}
|
|
}
|
|
stop {
|
|
gross {
|
|
...Money
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pageInfo {
|
|
hasPreviousPage
|
|
hasNextPage
|
|
startCursor
|
|
endCursor
|
|
}
|
|
totalCount
|
|
}
|
|
}
|
|
`;
|
|
export const TypedProductListQuery = TypedQuery<
|
|
ProductList,
|
|
ProductListVariables
|
|
>(productListQuery);
|
|
|
|
const countAllProductsQuery = gql`
|
|
query CountAllProducts {
|
|
products {
|
|
totalCount
|
|
}
|
|
}
|
|
`;
|
|
export const useCountAllProducts = makeQuery<CountAllProducts, null>(
|
|
countAllProductsQuery
|
|
);
|
|
|
|
const productDetailsQuery = gql`
|
|
${productFragmentDetails}
|
|
query ProductDetails($id: ID!) {
|
|
product(id: $id) {
|
|
...Product
|
|
}
|
|
}
|
|
`;
|
|
export const TypedProductDetailsQuery = TypedQuery<
|
|
ProductDetails,
|
|
ProductDetailsVariables
|
|
>(productDetailsQuery);
|
|
|
|
const productVariantQuery = gql`
|
|
${fragmentVariant}
|
|
query ProductVariantDetails($id: ID!) {
|
|
productVariant(id: $id) {
|
|
...ProductVariant
|
|
}
|
|
}
|
|
`;
|
|
export const TypedProductVariantQuery = TypedQuery<
|
|
ProductVariantDetails,
|
|
ProductVariantDetailsVariables
|
|
>(productVariantQuery);
|
|
|
|
const productVariantCreateQuery = gql`
|
|
query ProductVariantCreateData($id: ID!) {
|
|
product(id: $id) {
|
|
id
|
|
images {
|
|
id
|
|
sortOrder
|
|
url
|
|
}
|
|
name
|
|
productType {
|
|
id
|
|
variantAttributes {
|
|
id
|
|
slug
|
|
name
|
|
valueRequired
|
|
values {
|
|
id
|
|
name
|
|
slug
|
|
}
|
|
}
|
|
}
|
|
thumbnail {
|
|
url
|
|
}
|
|
variants {
|
|
id
|
|
name
|
|
sku
|
|
images {
|
|
id
|
|
url
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
export const TypedProductVariantCreateQuery = TypedQuery<
|
|
ProductVariantCreateData,
|
|
ProductVariantCreateDataVariables
|
|
>(productVariantCreateQuery);
|
|
|
|
const productImageQuery = gql`
|
|
query ProductImageById($productId: ID!, $imageId: ID!) {
|
|
product(id: $productId) {
|
|
id
|
|
name
|
|
mainImage: imageById(id: $imageId) {
|
|
id
|
|
alt
|
|
url
|
|
}
|
|
images {
|
|
id
|
|
url(size: 48)
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
export const TypedProductImageQuery = TypedQuery<
|
|
ProductImageById,
|
|
ProductImageByIdVariables
|
|
>(productImageQuery);
|
|
|
|
const availableInGridAttributes = gql`
|
|
${pageInfoFragment}
|
|
query GridAttributes($first: Int!, $after: String, $ids: [ID!]!) {
|
|
availableInGrid: attributes(
|
|
first: $first
|
|
after: $after
|
|
filter: { availableInGrid: true, isVariantOnly: false }
|
|
) {
|
|
edges {
|
|
node {
|
|
id
|
|
name
|
|
}
|
|
}
|
|
pageInfo {
|
|
...PageInfoFragment
|
|
}
|
|
totalCount
|
|
}
|
|
|
|
grid: attributes(first: 25, filter: { ids: $ids }) {
|
|
edges {
|
|
node {
|
|
id
|
|
name
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
export const AvailableInGridAttributesQuery = TypedQuery<
|
|
GridAttributes,
|
|
GridAttributesVariables
|
|
>(availableInGridAttributes);
|
|
|
|
const createMultipleVariantsData = gql`
|
|
${productVariantAttributesFragment}
|
|
${warehouseFragment}
|
|
query CreateMultipleVariantsData($id: ID!) {
|
|
product(id: $id) {
|
|
...ProductVariantAttributesFragment
|
|
}
|
|
warehouses(first: 20) {
|
|
edges {
|
|
node {
|
|
...WarehouseFragment
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
export const useCreateMultipleVariantsData = makeQuery<
|
|
CreateMultipleVariantsData,
|
|
CreateMultipleVariantsDataVariables
|
|
>(createMultipleVariantsData);
|