Merge pull request #249 from mirumee/fix/subcategories-pagination
Fix subcategories pagination
This commit is contained in:
commit
09295a5d16
6 changed files with 37 additions and 14 deletions
|
@ -6,6 +6,7 @@ All notable, unreleased changes to this project will be documented in this file.
|
||||||
|
|
||||||
- Fix minor bugs - #244 by @dominik-zeglen
|
- Fix minor bugs - #244 by @dominik-zeglen
|
||||||
- Fix tax settings updating - #243 by @dominik-zeglen
|
- Fix tax settings updating - #243 by @dominik-zeglen
|
||||||
|
- Fix subcategories pagination - #249 by @dominik-zeglen
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,14 @@ export const category: (
|
||||||
},
|
},
|
||||||
children: {
|
children: {
|
||||||
__typename: "CategoryCountableConnection",
|
__typename: "CategoryCountableConnection",
|
||||||
edges: []
|
edges: [],
|
||||||
|
pageInfo: {
|
||||||
|
__typename: "PageInfo",
|
||||||
|
endCursor: "YXJyYXljb25uZWN0aW9uOjk=",
|
||||||
|
hasNextPage: false,
|
||||||
|
hasPreviousPage: false,
|
||||||
|
startCursor: "YXJyYXljb25uZWN0aW9uOjA="
|
||||||
|
}
|
||||||
},
|
},
|
||||||
descriptionJson: JSON.stringify(content),
|
descriptionJson: JSON.stringify(content),
|
||||||
id: "Q2F0ZWdvcnk6NA==",
|
id: "Q2F0ZWdvcnk6NA==",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import gql from "graphql-tag";
|
import gql from "graphql-tag";
|
||||||
|
|
||||||
import { TypedQuery } from "../queries";
|
import { pageInfoFragment, TypedQuery } from "../queries";
|
||||||
import {
|
import {
|
||||||
CategoryDetails,
|
CategoryDetails,
|
||||||
CategoryDetailsVariables
|
CategoryDetailsVariables
|
||||||
|
@ -38,6 +38,7 @@ export const categoryDetailsFragment = gql`
|
||||||
|
|
||||||
export const rootCategories = gql`
|
export const rootCategories = gql`
|
||||||
${categoryFragment}
|
${categoryFragment}
|
||||||
|
${pageInfoFragment}
|
||||||
query RootCategories(
|
query RootCategories(
|
||||||
$first: Int
|
$first: Int
|
||||||
$after: String
|
$after: String
|
||||||
|
@ -59,10 +60,7 @@ export const rootCategories = gql`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pageInfo {
|
pageInfo {
|
||||||
endCursor
|
...PageInfoFragment
|
||||||
hasNextPage
|
|
||||||
hasPreviousPage
|
|
||||||
startCursor
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +72,7 @@ export const TypedRootCategoriesQuery = TypedQuery<RootCategories, {}>(
|
||||||
export const categoryDetails = gql`
|
export const categoryDetails = gql`
|
||||||
${categoryFragment}
|
${categoryFragment}
|
||||||
${categoryDetailsFragment}
|
${categoryDetailsFragment}
|
||||||
|
${pageInfoFragment}
|
||||||
query CategoryDetails(
|
query CategoryDetails(
|
||||||
$id: ID!
|
$id: ID!
|
||||||
$first: Int
|
$first: Int
|
||||||
|
@ -83,19 +82,19 @@ export const categoryDetails = gql`
|
||||||
) {
|
) {
|
||||||
category(id: $id) {
|
category(id: $id) {
|
||||||
...CategoryDetailsFragment
|
...CategoryDetailsFragment
|
||||||
children(first: 20) {
|
children(first: $first, after: $after, last: $last, before: $before) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
...CategoryFragment
|
...CategoryFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pageInfo {
|
||||||
|
...PageInfoFragment
|
||||||
|
}
|
||||||
}
|
}
|
||||||
products(first: $first, after: $after, last: $last, before: $before) {
|
products(first: $first, after: $after, last: $last, before: $before) {
|
||||||
pageInfo {
|
pageInfo {
|
||||||
endCursor
|
...PageInfoFragment
|
||||||
hasNextPage
|
|
||||||
hasPreviousPage
|
|
||||||
startCursor
|
|
||||||
}
|
}
|
||||||
edges {
|
edges {
|
||||||
cursor
|
cursor
|
||||||
|
|
|
@ -40,9 +40,18 @@ export interface CategoryDetails_category_children_edges {
|
||||||
node: CategoryDetails_category_children_edges_node;
|
node: CategoryDetails_category_children_edges_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CategoryDetails_category_children_pageInfo {
|
||||||
|
__typename: "PageInfo";
|
||||||
|
endCursor: string | null;
|
||||||
|
hasNextPage: boolean;
|
||||||
|
hasPreviousPage: boolean;
|
||||||
|
startCursor: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CategoryDetails_category_children {
|
export interface CategoryDetails_category_children {
|
||||||
__typename: "CategoryCountableConnection";
|
__typename: "CategoryCountableConnection";
|
||||||
edges: CategoryDetails_category_children_edges[];
|
edges: CategoryDetails_category_children_edges[];
|
||||||
|
pageInfo: CategoryDetails_category_children_pageInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CategoryDetails_category_products_pageInfo {
|
export interface CategoryDetails_category_products_pageInfo {
|
||||||
|
|
|
@ -162,7 +162,9 @@ export const CategoryDetails: React.FC<CategoryDetailsProps> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const { loadNextPage, loadPreviousPage, pageInfo } = paginate(
|
const { loadNextPage, loadPreviousPage, pageInfo } = paginate(
|
||||||
maybe(() => data.category.products.pageInfo),
|
params.activeTab === CategoryPageTab.categories
|
||||||
|
? maybe(() => data.category.children.pageInfo)
|
||||||
|
: maybe(() => data.category.products.pageInfo),
|
||||||
paginationState,
|
paginationState,
|
||||||
params
|
params
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,7 +2,12 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { SiteDomainInput, ShopSettingsInput, AddressInput, AuthorizationKeyType } from "./../../types/globalTypes";
|
import {
|
||||||
|
SiteDomainInput,
|
||||||
|
ShopSettingsInput,
|
||||||
|
AddressInput,
|
||||||
|
AuthorizationKeyType
|
||||||
|
} from "./../../types/globalTypes";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL mutation operation: ShopSettingsUpdate
|
// GraphQL mutation operation: ShopSettingsUpdate
|
||||||
|
@ -143,5 +148,5 @@ export interface ShopSettingsUpdate {
|
||||||
export interface ShopSettingsUpdateVariables {
|
export interface ShopSettingsUpdateVariables {
|
||||||
shopDomainInput: SiteDomainInput;
|
shopDomainInput: SiteDomainInput;
|
||||||
shopSettingsInput: ShopSettingsInput;
|
shopSettingsInput: ShopSettingsInput;
|
||||||
addressInput: AddressInput;
|
addressInput?: AddressInput | null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue