Fix types
This commit is contained in:
parent
035271adf0
commit
1f3d3be072
5 changed files with 50 additions and 7 deletions
|
@ -188,6 +188,7 @@ const ProductOrganization = withStyles(styles, { name: "ProductOrganization" })(
|
||||||
onChange={onCollectionChange}
|
onChange={onCollectionChange}
|
||||||
fetchChoices={fetchCollections}
|
fetchChoices={fetchCollections}
|
||||||
data-tc="collections"
|
data-tc="collections"
|
||||||
|
{...fetchMoreCollections}
|
||||||
/>
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
|
@ -19,7 +19,7 @@ import useFormset from "@saleor/hooks/useFormset";
|
||||||
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { maybe } from "@saleor/misc";
|
import { maybe } from "@saleor/misc";
|
||||||
import { ListActions, UserError } from "@saleor/types";
|
import { FetchMoreProps, ListActions, UserError } from "@saleor/types";
|
||||||
import createMultiAutocompleteSelectHandler from "@saleor/utils/handlers/multiAutocompleteSelectChangeHandler";
|
import createMultiAutocompleteSelectHandler from "@saleor/utils/handlers/multiAutocompleteSelectChangeHandler";
|
||||||
import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler";
|
import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler";
|
||||||
import {
|
import {
|
||||||
|
@ -53,6 +53,8 @@ export interface ProductUpdatePageProps extends ListActions {
|
||||||
collections: SearchCollections_search_edges_node[];
|
collections: SearchCollections_search_edges_node[];
|
||||||
categories: SearchCategories_search_edges_node[];
|
categories: SearchCategories_search_edges_node[];
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
|
fetchMoreCategories: FetchMoreProps;
|
||||||
|
fetchMoreCollections: FetchMoreProps;
|
||||||
variants: ProductDetails_product_variants[];
|
variants: ProductDetails_product_variants[];
|
||||||
images: ProductDetails_product_images[];
|
images: ProductDetails_product_images[];
|
||||||
product: ProductDetails_product;
|
product: ProductDetails_product;
|
||||||
|
@ -86,6 +88,8 @@ export const ProductUpdatePage: React.FC<ProductUpdatePageProps> = ({
|
||||||
errors: userErrors,
|
errors: userErrors,
|
||||||
fetchCategories,
|
fetchCategories,
|
||||||
fetchCollections,
|
fetchCollections,
|
||||||
|
fetchMoreCategories,
|
||||||
|
fetchMoreCollections,
|
||||||
images,
|
images,
|
||||||
header,
|
header,
|
||||||
placeholderImage,
|
placeholderImage,
|
||||||
|
@ -285,6 +289,8 @@ export const ProductUpdatePage: React.FC<ProductUpdatePageProps> = ({
|
||||||
errors={errors}
|
errors={errors}
|
||||||
fetchCategories={fetchCategories}
|
fetchCategories={fetchCategories}
|
||||||
fetchCollections={fetchCollections}
|
fetchCollections={fetchCollections}
|
||||||
|
fetchMoreCategories={fetchMoreCategories}
|
||||||
|
fetchMoreCollections={fetchMoreCollections}
|
||||||
productType={maybe(() => product.productType)}
|
productType={maybe(() => product.productType)}
|
||||||
onCategoryChange={handleCategorySelect}
|
onCategoryChange={handleCategorySelect}
|
||||||
onCollectionChange={handleCollectionSelect}
|
onCollectionChange={handleCollectionSelect}
|
||||||
|
|
|
@ -68,9 +68,17 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SearchCategories variables={DEFAULT_INITIAL_SEARCH_DATA}>
|
<SearchCategories variables={DEFAULT_INITIAL_SEARCH_DATA}>
|
||||||
{({ search: searchCategories, result: searchCategoriesOpts }) => (
|
{({
|
||||||
|
loadMore: loadMoreCategories,
|
||||||
|
search: searchCategories,
|
||||||
|
result: searchCategoriesOpts
|
||||||
|
}) => (
|
||||||
<SearchCollections variables={DEFAULT_INITIAL_SEARCH_DATA}>
|
<SearchCollections variables={DEFAULT_INITIAL_SEARCH_DATA}>
|
||||||
{({ search: searchCollections, result: searchCollectionsOpts }) => (
|
{({
|
||||||
|
loadMore: loadMoreCollections,
|
||||||
|
search: searchCollections,
|
||||||
|
result: searchCollectionsOpts
|
||||||
|
}) => (
|
||||||
<TypedProductDetailsQuery
|
<TypedProductDetailsQuery
|
||||||
displayLoader
|
displayLoader
|
||||||
require={["product"]}
|
require={["product"]}
|
||||||
|
@ -295,6 +303,24 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
|
||||||
selected={listElements.length}
|
selected={listElements.length}
|
||||||
toggle={toggle}
|
toggle={toggle}
|
||||||
toggleAll={toggleAll}
|
toggleAll={toggleAll}
|
||||||
|
fetchMoreCategories={{
|
||||||
|
hasMore: maybe(
|
||||||
|
() =>
|
||||||
|
searchCategoriesOpts.data.search.pageInfo
|
||||||
|
.hasNextPage
|
||||||
|
),
|
||||||
|
loading: searchCategoriesOpts.loading,
|
||||||
|
onFetchMore: loadMoreCategories
|
||||||
|
}}
|
||||||
|
fetchMoreCollections={{
|
||||||
|
hasMore: maybe(
|
||||||
|
() =>
|
||||||
|
searchCollectionsOpts.data.search.pageInfo
|
||||||
|
.hasNextPage
|
||||||
|
),
|
||||||
|
loading: searchCollectionsOpts.loading,
|
||||||
|
onFetchMore: loadMoreCollections
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<ActionDialog
|
<ActionDialog
|
||||||
open={params.action === "remove"}
|
open={params.action === "remove"}
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
import { storiesOf } from "@storybook/react";
|
import { storiesOf } from "@storybook/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
|
import { fetchMoreProps } from "@saleor/fixtures";
|
||||||
import ProductCreatePage, {
|
import ProductCreatePage, {
|
||||||
ProductCreatePageSubmitData
|
ProductCreatePageSubmitData
|
||||||
} from "../../../products/components/ProductCreatePage";
|
} from "../../../products/components/ProductCreatePage";
|
||||||
|
|
||||||
import { formError } from "../../misc";
|
|
||||||
|
|
||||||
import { product as productFixture } from "../../../products/fixtures";
|
import { product as productFixture } from "../../../products/fixtures";
|
||||||
import { productTypes } from "../../../productTypes/fixtures";
|
import { productTypes } from "../../../productTypes/fixtures";
|
||||||
import Decorator from "../../Decorator";
|
import Decorator from "../../Decorator";
|
||||||
|
import { formError } from "../../misc";
|
||||||
|
|
||||||
const product = productFixture("");
|
const product = productFixture("");
|
||||||
|
|
||||||
|
@ -25,6 +24,9 @@ storiesOf("Views / Products / Create product", module)
|
||||||
fetchCategories={() => undefined}
|
fetchCategories={() => undefined}
|
||||||
fetchCollections={() => undefined}
|
fetchCollections={() => undefined}
|
||||||
fetchProductTypes={() => undefined}
|
fetchProductTypes={() => undefined}
|
||||||
|
fetchMoreCategories={fetchMoreProps}
|
||||||
|
fetchMoreCollections={fetchMoreProps}
|
||||||
|
fetchMoreProductTypes={fetchMoreProps}
|
||||||
productTypes={productTypes}
|
productTypes={productTypes}
|
||||||
categories={[product.category]}
|
categories={[product.category]}
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
|
@ -42,6 +44,9 @@ storiesOf("Views / Products / Create product", module)
|
||||||
fetchCategories={() => undefined}
|
fetchCategories={() => undefined}
|
||||||
fetchCollections={() => undefined}
|
fetchCollections={() => undefined}
|
||||||
fetchProductTypes={() => undefined}
|
fetchProductTypes={() => undefined}
|
||||||
|
fetchMoreCategories={fetchMoreProps}
|
||||||
|
fetchMoreCollections={fetchMoreProps}
|
||||||
|
fetchMoreProductTypes={fetchMoreProps}
|
||||||
productTypes={productTypes}
|
productTypes={productTypes}
|
||||||
categories={[product.category]}
|
categories={[product.category]}
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
|
@ -61,6 +66,9 @@ storiesOf("Views / Products / Create product", module)
|
||||||
fetchCategories={() => undefined}
|
fetchCategories={() => undefined}
|
||||||
fetchCollections={() => undefined}
|
fetchCollections={() => undefined}
|
||||||
fetchProductTypes={() => undefined}
|
fetchProductTypes={() => undefined}
|
||||||
|
fetchMoreCategories={fetchMoreProps}
|
||||||
|
fetchMoreCollections={fetchMoreProps}
|
||||||
|
fetchMoreProductTypes={fetchMoreProps}
|
||||||
productTypes={productTypes}
|
productTypes={productTypes}
|
||||||
categories={[product.category]}
|
categories={[product.category]}
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import React from "react";
|
||||||
|
|
||||||
import placeholderImage from "@assets/images/placeholder255x255.png";
|
import placeholderImage from "@assets/images/placeholder255x255.png";
|
||||||
import { collections } from "@saleor/collections/fixtures";
|
import { collections } from "@saleor/collections/fixtures";
|
||||||
import { listActionsProps } from "@saleor/fixtures";
|
import { fetchMoreProps, listActionsProps } from "@saleor/fixtures";
|
||||||
import ProductUpdatePage, {
|
import ProductUpdatePage, {
|
||||||
ProductUpdatePageProps
|
ProductUpdatePageProps
|
||||||
} from "@saleor/products/components/ProductUpdatePage";
|
} from "@saleor/products/components/ProductUpdatePage";
|
||||||
|
@ -20,6 +20,8 @@ const props: ProductUpdatePageProps = {
|
||||||
errors: [],
|
errors: [],
|
||||||
fetchCategories: () => undefined,
|
fetchCategories: () => undefined,
|
||||||
fetchCollections: () => undefined,
|
fetchCollections: () => undefined,
|
||||||
|
fetchMoreCategories: fetchMoreProps,
|
||||||
|
fetchMoreCollections: fetchMoreProps,
|
||||||
header: product.name,
|
header: product.name,
|
||||||
images: product.images,
|
images: product.images,
|
||||||
onBack: () => undefined,
|
onBack: () => undefined,
|
||||||
|
|
Loading…
Reference in a new issue