Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix product assign modal

dominik-zeglena8a6a68056ec
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeCreate.ts b/saleor/static/dashboard-next/attributes/types/AttributeCreate.ts
index a1c9bf24c9..ef230528cc 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeCreate.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeCreate.ts
@@ -19,7 +19,7 @@ export interface AttributeCreate_attributeCreate_attribute_values {
id: string;
name: string | null;
slug: string | null;
- sortOrder: number | null;
+ sortOrder: number;
type: AttributeValueType | null;
value: string | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeDetails.ts b/saleor/static/dashboard-next/attributes/types/AttributeDetails.ts
index 4681577803..b392e31db8 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeDetails.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeDetails.ts
@@ -13,7 +13,7 @@ export interface AttributeDetails_attribute_values {
id: string;
name: string | null;
slug: string | null;
- sortOrder: number | null;
+ sortOrder: number;
type: AttributeValueType | null;
value: string | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeDetailsFragment.ts b/saleor/static/dashboard-next/attributes/types/AttributeDetailsFragment.ts
index 0746b51e4b..a36c08232b 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeDetailsFragment.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeDetailsFragment.ts
@@ -13,7 +13,7 @@ export interface AttributeDetailsFragment_values {
id: string;
name: string | null;
slug: string | null;
- sortOrder: number | null;
+ sortOrder: number;
type: AttributeValueType | null;
value: string | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeUpdate.ts b/saleor/static/dashboard-next/attributes/types/AttributeUpdate.ts
index 8e3ccb759d..87a9e98ba0 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeUpdate.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeUpdate.ts
@@ -19,7 +19,7 @@ export interface AttributeUpdate_attributeUpdate_attribute_values {
id: string;
name: string | null;
slug: string | null;
- sortOrder: number | null;
+ sortOrder: number;
type: AttributeValueType | null;
value: string | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeValueCreate.ts b/saleor/static/dashboard-next/attributes/types/AttributeValueCreate.ts
index e18fa3eed6..a1e4fad0a5 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeValueCreate.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeValueCreate.ts
@@ -19,7 +19,7 @@ export interface AttributeValueCreate_attributeValueCreate_attribute_values {
id: string;
name: string | null;
slug: string | null;
- sortOrder: number | null;
+ sortOrder: number;
type: AttributeValueType | null;
value: string | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeValueDelete.ts b/saleor/static/dashboard-next/attributes/types/AttributeValueDelete.ts
index 10b15a8df8..99c120dafc 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeValueDelete.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeValueDelete.ts
@@ -19,7 +19,7 @@ export interface AttributeValueDelete_attributeValueDelete_attribute_values {
id: string;
name: string | null;
slug: string | null;
- sortOrder: number | null;
+ sortOrder: number;
type: AttributeValueType | null;
value: string | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeValueUpdate.ts b/saleor/static/dashboard-next/attributes/types/AttributeValueUpdate.ts
index 080481963f..84184b83a6 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeValueUpdate.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeValueUpdate.ts
@@ -19,7 +19,7 @@ export interface AttributeValueUpdate_attributeValueUpdate_attribute_values {
id: string;
name: string | null;
slug: string | null;
- sortOrder: number | null;
+ sortOrder: number;
type: AttributeValueType | null;
value: string | null;
}
diff --git a/saleor/static/dashboard-next/components/AssignAttributeDialog/AssignAttributeDialog.tsx b/saleor/static/dashboard-next/components/AssignAttributeDialog/AssignAttributeDialog.tsx
index b77adbf52f..98aced300d 100644
--- a/saleor/static/dashboard-next/components/AssignAttributeDialog/AssignAttributeDialog.tsx
+++ b/saleor/static/dashboard-next/components/AssignAttributeDialog/AssignAttributeDialog.tsx
@@ -5,167 +5,175 @@ import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import DialogContentText from "@material-ui/core/DialogContentText";
import DialogTitle from "@material-ui/core/DialogTitle";
-import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
+import { Theme } from "@material-ui/core/styles";
import Table from "@material-ui/core/Table";
import TableBody from "@material-ui/core/TableBody";
import TableCell from "@material-ui/core/TableCell";
import TableRow from "@material-ui/core/TableRow";
import TextField from "@material-ui/core/TextField";
+import Typography from "@material-ui/core/Typography";
+import makeStyles from "@material-ui/styles/makeStyles";
import * as React from "react";
+import InfiniteScroll from "react-infinite-scroller";
import ConfirmButton, {
ConfirmButtonTransitionState
} from "@saleor/components/ConfirmButton";
-import Form from "@saleor/components/Form";
-import FormSpacer from "@saleor/components/FormSpacer";
+import useSearchQuery from "@saleor/hooks/useSearchQuery";
import { maybe, renderCollection } from "@saleor/misc";
+import { FetchMoreProps } from "@saleor/types";
import { SearchAttributes_attributes_edges_node } from "../../containers/SearchAttributes/types/SearchAttributes";
import i18n from "../../i18n";
import Checkbox from "../Checkbox";
-interface FormData {
- query: string;
-}
-
-const styles = createStyles({
+const useStyles = makeStyles((theme: Theme) => ({
checkboxCell: {
paddingLeft: 0
},
- overflow: {
- overflowY: "visible"
+ loadMoreLoaderContainer: {
+ alignItems: "center",
+ display: "flex",
+ height: theme.spacing.unit * 3,
+ justifyContent: "center"
+ },
+ scrollArea: {
+ overflowY: "scroll"
},
wideCell: {
width: "100%"
}
-});
+}));
-export interface AssignAttributeDialogProps {
+export interface AssignAttributeDialogProps extends FetchMoreProps {
confirmButtonState: ConfirmButtonTransitionState;
errors: string[];
open: boolean;
attributes: SearchAttributes_attributes_edges_node[];
- loading: boolean;
selected: string[];
onClose: () => void;
- onFetch: (value: string) => void;
- onSubmit: (data: FormData) => void;
+ onSubmit: () => void;
onToggle: (id: string) => void;
}
-const initialForm: FormData = {
- query: ""
-};
-const AssignAttributeDialog = withStyles(styles, {
- name: "AssignAttributeDialog"
-})(
- ({
- attributes,
- classes,
- confirmButtonState,
- errors,
- loading,
- open,
- selected,
- onClose,
- onFetch,
- onSubmit,
- onToggle
- }: AssignAttributeDialogProps & WithStyles<typeof styles>) => (
- <Dialog
- onClose={onClose}
- open={open}
- classes={{ paper: classes.overflow }}
- fullWidth
- maxWidth="sm"
- >
- <Form initial={initialForm} onSubmit={onSubmit}>
- {({ data, change }) => (
- <>
- <DialogTitle>{i18n.t("Assign Attribute")}</DialogTitle>
- <DialogContent className={classes.overflow}>
- <TextField
- name="query"
- value={data.query}
- onChange={event => change(event, () => onFetch(data.query))}
- label={i18n.t("Search Attributes", {
- context: "attribute search input label"
- })}
- placeholder={i18n.t("Search by attribute name", {
- context: "attribute search input placeholder"
- })}
- fullWidth
- InputProps={{
- autoComplete: "off",
- endAdornment: loading && <CircularProgress size={16} />
- }}
- />
- <FormSpacer />
- <Table>
- <TableBody>
- {renderCollection(
- attributes,
- attribute => {
- if (!attribute) {
- return null;
- }
- const isChecked = !!selected.find(
- selectedAttribute => selectedAttribute === attribute.id
- );
+const AssignAttributeDialog: React.FC<AssignAttributeDialogProps> = ({
+ attributes,
+ confirmButtonState,
+ errors,
+ hasMore,
+ loading,
+ open,
+ selected,
+ onClose,
+ onFetch,
+ onFetchMore,
+ onSubmit,
+ onToggle
+}: AssignAttributeDialogProps) => {
+ const classes = useStyles({});
+ const [query, onQueryChange] = useSearchQuery(onFetch);
+
+ return (
+ <Dialog onClose={onClose} open={open} fullWidth maxWidth="sm">
+ <DialogTitle>{i18n.t("Assign Attribute")}</DialogTitle>
+ <DialogContent>
+ <TextField
+ name="query"
+ value={query}
+ onChange={onQueryChange}
+ label={i18n.t("Search Attributes", {
+ context: "attribute search input label"
+ })}
+ placeholder={i18n.t("Search by attribute name", {
+ context: "attribute search input placeholder"
+ })}
+ fullWidth
+ InputProps={{
+ autoComplete: "off",
+ endAdornment: loading && <CircularProgress size={16} />
+ }}
+ />
+ </DialogContent>
+ <DialogContent className={classes.scrollArea}>
+ <InfiniteScroll
+ pageStart={0}
+ loadMore={onFetchMore}
+ hasMore={hasMore}
+ useWindow={false}
+ loader={
+ <div className={classes.loadMoreLoaderContainer}>
+ <CircularProgress size={16} />
+ </div>
+ }
+ threshold={10}
+ >
+ <Table key="table">
+ <TableBody>
+ {renderCollection(
+ attributes,
+ attribute => {
+ if (!attribute) {
+ return null;
+ }
+ const isChecked = !!selected.find(
+ selectedAttribute => selectedAttribute === attribute.id
+ );
- return (
- <TableRow key={maybe(() => attribute.id)}>
- <TableCell
- padding="checkbox"
- className={classes.checkboxCell}
- >
- <Checkbox
- checked={isChecked}
- onChange={() => onToggle(attribute.id)}
- />
- </TableCell>
- <TableCell className={classes.wideCell}>
- {attribute.name}
- </TableCell>
- </TableRow>
- );
- },
- () =>
- !loading && (
- <TableRow>
- <TableCell colSpan={2}>
- {i18n.t("No results found")}
- </TableCell>
- </TableRow>
- )
- )}
- </TableBody>
- </Table>
- </DialogContent>
- {errors.length > 0 && (
- <DialogContent>
- {errors.map(error => (
- <DialogContentText color="error">{error}</DialogContentText>
- ))}
- </DialogContent>
- )}
- <DialogActions>
- <Button onClick={onClose}>
- {i18n.t("Cancel", { context: "button" })}
- </Button>
- <ConfirmButton
- transitionState={confirmButtonState}
- color="primary"
- variant="contained"
- type="submit"
- >
- {i18n.t("Assign attributes", { context: "button" })}
- </ConfirmButton>
- </DialogActions>
- </>
- )}
- </Form>
+ return (
+ <TableRow key={maybe(() => attribute.id)}>
+ <TableCell
+ padding="checkbox"
+ className={classes.checkboxCell}
+ >
+ <Checkbox
+ checked={isChecked}
+ onChange={() => onToggle(attribute.id)}
+ />
+ </TableCell>
+ <TableCell className={classes.wideCell}>
+ {attribute.name}
+ <Typography variant="caption">
+ {attribute.slug}
+ </Typography>
+ </TableCell>
+ </TableRow>
+ );
+ },
+ () =>
+ !loading && (
+ <TableRow>
+ <TableCell colSpan={2}>
+ {i18n.t("No results found")}
+ </TableCell>
+ </TableRow>
+ )
+ )}
+ </TableBody>
+ </Table>
+ </InfiniteScroll>
+ </DialogContent>
+ {errors.length > 0 && (
+ <DialogContent>
+ {errors.map(error => (
+ <DialogContentText color="error">{error}</DialogContentText>
+ ))}
+ </DialogContent>
+ )}
+ <DialogActions>
+ <Button onClick={onClose}>
+ {i18n.t("Cancel", { context: "button" })}
+ </Button>
+ <ConfirmButton
+ transitionState={confirmButtonState}
+ color="primary"
+ variant="contained"
+ type="submit"
+ onClick={onSubmit}
+ >
+ {i18n.t("Assign attributes", { context: "button" })}
+ </ConfirmButton>
+ </DialogActions>
</Dialog>
- )
-);
+ );
+};
AssignAttributeDialog.displayName = "AssignAttributeDialog";
export default AssignAttributeDialog;
diff --git a/saleor/static/dashboard-next/containers/SearchAttributes/index.tsx b/saleor/static/dashboard-next/containers/SearchAttributes/index.tsx
index 5725da0773..22be619cc0 100644
--- a/saleor/static/dashboard-next/containers/SearchAttributes/index.tsx
+++ b/saleor/static/dashboard-next/containers/SearchAttributes/index.tsx
@@ -1,5 +1,6 @@
import gql from "graphql-tag";
+import { pageInfoFragment } from "@saleor/queries";
import BaseSearch from "../BaseSearch";
import {
SearchAttributes,
@@ -7,14 +8,19 @@ import {
} from "./types/SearchAttributes";
export const searchAttributes = gql`
+ ${pageInfoFragment}
query SearchAttributes($after: String, $first: Int!, $query: String!) {
attributes(after: $after, first: $first, query: $query) {
edges {
node {
id
name
+ slug
}
}
+ pageInfo {
+ ...PageInfoFragment
+ }
}
}
`;
diff --git a/saleor/static/dashboard-next/containers/SearchAttributes/types/SearchAttributes.ts b/saleor/static/dashboard-next/containers/SearchAttributes/types/SearchAttributes.ts
index fc0d9e429a..bb552d2522 100644
--- a/saleor/static/dashboard-next/containers/SearchAttributes/types/SearchAttributes.ts
+++ b/saleor/static/dashboard-next/containers/SearchAttributes/types/SearchAttributes.ts
@@ -10,6 +10,7 @@ export interface SearchAttributes_attributes_edges_node {
__typename: "Attribute";
id: string;
name: string | null;
+ slug: string | null;
}
export interface SearchAttributes_attributes_edges {
@@ -17,9 +18,18 @@ export interface SearchAttributes_attributes_edges {
node: SearchAttributes_attributes_edges_node;
}
+export interface SearchAttributes_attributes_pageInfo {
+ __typename: "PageInfo";
+ endCursor: string | null;
+ hasNextPage: boolean;
+ hasPreviousPage: boolean;
+ startCursor: string | null;
+}
+
export interface SearchAttributes_attributes {
__typename: "AttributeCountableConnection";
edges: SearchAttributes_attributes_edges[];
+ pageInfo: SearchAttributes_attributes_pageInfo;
}
export interface SearchAttributes {
diff --git a/saleor/static/dashboard-next/home/types/Home.ts b/saleor/static/dashboard-next/home/types/Home.ts
index 139866c2db..d88e49e129 100644
--- a/saleor/static/dashboard-next/home/types/Home.ts
+++ b/saleor/static/dashboard-next/home/types/Home.ts
@@ -54,7 +54,7 @@ export interface Home_productTopToday_edges_node_attributes_value {
__typename: "AttributeValue";
id: string;
name: string | null;
- sortOrder: number | null;
+ sortOrder: number;
}
export interface Home_productTopToday_edges_node_attributes {
diff --git a/saleor/static/dashboard-next/hooks/useSearchQuery.ts b/saleor/static/dashboard-next/hooks/useSearchQuery.ts
new file mode 100644
index 0000000000..af33288489
--- /dev/null
+++ b/saleor/static/dashboard-next/hooks/useSearchQuery.ts
@@ -0,0 +1,21 @@
+import React from "react";
+
+import { ChangeEvent } from "@saleor/hooks/useForm";
+
+export type UseSearchQuery = [string, (event: ChangeEvent) => void];
+function useSearchQuery(
+ onFetch: (query: string) => void,
+ initial?: string
+): UseSearchQuery {
+ const [query, setQuery] = React.useState(initial || "");
+ const change = (event: ChangeEvent) => {
+ const value = event.target.value;
+
+ onFetch(value);
+ setQuery(value);
+ };
+
+ return [query, change];
+}
+
+export default useSearchQuery;
diff --git a/saleor/static/dashboard-next/misc.ts b/saleor/static/dashboard-next/misc.ts
index 91a2311608..3c1f469c66 100644
--- a/saleor/static/dashboard-next/misc.ts
+++ b/saleor/static/dashboard-next/misc.ts
@@ -272,14 +272,3 @@ export function generateCode(charNum: number) {
}
return result;
}
-
-export function onQueryChange(
- event: ChangeEvent,
- onFetch: (data: string) => void,
- setQuery: (data: string) => void
-) {
- const value = event.target.value;
-
- onFetch(value);
- setQuery(value);
-}
diff --git a/saleor/static/dashboard-next/navigation/types/MenuDetails.ts b/saleor/static/dashboard-next/navigation/types/MenuDetails.ts
index 8fd2239849..74d606d729 100644
--- a/saleor/static/dashboard-next/navigation/types/MenuDetails.ts
+++ b/saleor/static/dashboard-next/navigation/types/MenuDetails.ts
@@ -140,7 +140,7 @@ export interface MenuDetails_menu_items_children_children_children_children_chil
level: number;
name: string;
page: MenuDetails_menu_items_children_children_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
}
@@ -152,7 +152,7 @@ export interface MenuDetails_menu_items_children_children_children_children_chil
level: number;
name: string;
page: MenuDetails_menu_items_children_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetails_menu_items_children_children_children_children_children_children | null)[] | null;
}
@@ -165,7 +165,7 @@ export interface MenuDetails_menu_items_children_children_children_children {
level: number;
name: string;
page: MenuDetails_menu_items_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetails_menu_items_children_children_children_children_children | null)[] | null;
}
@@ -178,7 +178,7 @@ export interface MenuDetails_menu_items_children_children_children {
level: number;
name: string;
page: MenuDetails_menu_items_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetails_menu_items_children_children_children_children | null)[] | null;
}
@@ -191,7 +191,7 @@ export interface MenuDetails_menu_items_children_children {
level: number;
name: string;
page: MenuDetails_menu_items_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetails_menu_items_children_children_children | null)[] | null;
}
@@ -204,7 +204,7 @@ export interface MenuDetails_menu_items_children {
level: number;
name: string;
page: MenuDetails_menu_items_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetails_menu_items_children_children | null)[] | null;
}
@@ -217,7 +217,7 @@ export interface MenuDetails_menu_items {
level: number;
name: string;
page: MenuDetails_menu_items_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetails_menu_items_children | null)[] | null;
}
diff --git a/saleor/static/dashboard-next/navigation/types/MenuDetailsFragment.ts b/saleor/static/dashboard-next/navigation/types/MenuDetailsFragment.ts
index 1f1d4d5457..2a60401002 100644
--- a/saleor/static/dashboard-next/navigation/types/MenuDetailsFragment.ts
+++ b/saleor/static/dashboard-next/navigation/types/MenuDetailsFragment.ts
@@ -140,7 +140,7 @@ export interface MenuDetailsFragment_items_children_children_children_children_c
level: number;
name: string;
page: MenuDetailsFragment_items_children_children_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
}
@@ -152,7 +152,7 @@ export interface MenuDetailsFragment_items_children_children_children_children_c
level: number;
name: string;
page: MenuDetailsFragment_items_children_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetailsFragment_items_children_children_children_children_children_children | null)[] | null;
}
@@ -165,7 +165,7 @@ export interface MenuDetailsFragment_items_children_children_children_children {
level: number;
name: string;
page: MenuDetailsFragment_items_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetailsFragment_items_children_children_children_children_children | null)[] | null;
}
@@ -178,7 +178,7 @@ export interface MenuDetailsFragment_items_children_children_children {
level: number;
name: string;
page: MenuDetailsFragment_items_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetailsFragment_items_children_children_children_children | null)[] | null;
}
@@ -191,7 +191,7 @@ export interface MenuDetailsFragment_items_children_children {
level: number;
name: string;
page: MenuDetailsFragment_items_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetailsFragment_items_children_children_children | null)[] | null;
}
@@ -204,7 +204,7 @@ export interface MenuDetailsFragment_items_children {
level: number;
name: string;
page: MenuDetailsFragment_items_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetailsFragment_items_children_children | null)[] | null;
}
@@ -217,7 +217,7 @@ export interface MenuDetailsFragment_items {
level: number;
name: string;
page: MenuDetailsFragment_items_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuDetailsFragment_items_children | null)[] | null;
}
diff --git a/saleor/static/dashboard-next/navigation/types/MenuItemCreate.ts b/saleor/static/dashboard-next/navigation/types/MenuItemCreate.ts
index b993b610ce..1ee635b437 100644
--- a/saleor/static/dashboard-next/navigation/types/MenuItemCreate.ts
+++ b/saleor/static/dashboard-next/navigation/types/MenuItemCreate.ts
@@ -148,7 +148,7 @@ export interface MenuItemCreate_menuItemCreate_menuItem_menu_items_children_chil
level: number;
name: string;
page: MenuItemCreate_menuItemCreate_menuItem_menu_items_children_children_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
}
@@ -160,7 +160,7 @@ export interface MenuItemCreate_menuItemCreate_menuItem_menu_items_children_chil
level: number;
name: string;
page: MenuItemCreate_menuItemCreate_menuItem_menu_items_children_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemCreate_menuItemCreate_menuItem_menu_items_children_children_children_children_children_children | null)[] | null;
}
@@ -173,7 +173,7 @@ export interface MenuItemCreate_menuItemCreate_menuItem_menu_items_children_chil
level: number;
name: string;
page: MenuItemCreate_menuItemCreate_menuItem_menu_items_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemCreate_menuItemCreate_menuItem_menu_items_children_children_children_children_children | null)[] | null;
}
@@ -186,7 +186,7 @@ export interface MenuItemCreate_menuItemCreate_menuItem_menu_items_children_chil
level: number;
name: string;
page: MenuItemCreate_menuItemCreate_menuItem_menu_items_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemCreate_menuItemCreate_menuItem_menu_items_children_children_children_children | null)[] | null;
}
@@ -199,7 +199,7 @@ export interface MenuItemCreate_menuItemCreate_menuItem_menu_items_children_chil
level: number;
name: string;
page: MenuItemCreate_menuItemCreate_menuItem_menu_items_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemCreate_menuItemCreate_menuItem_menu_items_children_children_children | null)[] | null;
}
@@ -212,7 +212,7 @@ export interface MenuItemCreate_menuItemCreate_menuItem_menu_items_children {
level: number;
name: string;
page: MenuItemCreate_menuItemCreate_menuItem_menu_items_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemCreate_menuItemCreate_menuItem_menu_items_children_children | null)[] | null;
}
@@ -225,7 +225,7 @@ export interface MenuItemCreate_menuItemCreate_menuItem_menu_items {
level: number;
name: string;
page: MenuItemCreate_menuItemCreate_menuItem_menu_items_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemCreate_menuItemCreate_menuItem_menu_items_children | null)[] | null;
}
diff --git a/saleor/static/dashboard-next/navigation/types/MenuItemFragment.ts b/saleor/static/dashboard-next/navigation/types/MenuItemFragment.ts
index 9d7a261e0d..74664fca6b 100644
--- a/saleor/static/dashboard-next/navigation/types/MenuItemFragment.ts
+++ b/saleor/static/dashboard-next/navigation/types/MenuItemFragment.ts
@@ -32,6 +32,6 @@ export interface MenuItemFragment {
level: number;
name: string;
page: MenuItemFragment_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
}
diff --git a/saleor/static/dashboard-next/navigation/types/MenuItemNestedFragment.ts b/saleor/static/dashboard-next/navigation/types/MenuItemNestedFragment.ts
index 4559855b4c..b45d1e73a1 100644
--- a/saleor/static/dashboard-next/navigation/types/MenuItemNestedFragment.ts
+++ b/saleor/static/dashboard-next/navigation/types/MenuItemNestedFragment.ts
@@ -140,7 +140,7 @@ export interface MenuItemNestedFragment_children_children_children_children_chil
level: number;
name: string;
page: MenuItemNestedFragment_children_children_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
}
@@ -152,7 +152,7 @@ export interface MenuItemNestedFragment_children_children_children_children_chil
level: number;
name: string;
page: MenuItemNestedFragment_children_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemNestedFragment_children_children_children_children_children_children | null)[] | null;
}
@@ -165,7 +165,7 @@ export interface MenuItemNestedFragment_children_children_children_children {
level: number;
name: string;
page: MenuItemNestedFragment_children_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemNestedFragment_children_children_children_children_children | null)[] | null;
}
@@ -178,7 +178,7 @@ export interface MenuItemNestedFragment_children_children_children {
level: number;
name: string;
page: MenuItemNestedFragment_children_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemNestedFragment_children_children_children_children | null)[] | null;
}
@@ -191,7 +191,7 @@ export interface MenuItemNestedFragment_children_children {
level: number;
name: string;
page: MenuItemNestedFragment_children_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemNestedFragment_children_children_children | null)[] | null;
}
@@ -204,7 +204,7 @@ export interface MenuItemNestedFragment_children {
level: number;
name: string;
page: MenuItemNestedFragment_children_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemNestedFragment_children_children | null)[] | null;
}
@@ -217,7 +217,7 @@ export interface MenuItemNestedFragment {
level: number;
name: string;
page: MenuItemNestedFragment_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
children: (MenuItemNestedFragment_children | null)[] | null;
}
diff --git a/saleor/static/dashboard-next/navigation/types/MenuItemUpdate.ts b/saleor/static/dashboard-next/navigation/types/MenuItemUpdate.ts
index d3c46bd07d..e2d7942ad0 100644
--- a/saleor/static/dashboard-next/navigation/types/MenuItemUpdate.ts
+++ b/saleor/static/dashboard-next/navigation/types/MenuItemUpdate.ts
@@ -40,7 +40,7 @@ export interface MenuItemUpdate_menuItemUpdate_menuItem {
level: number;
name: string;
page: MenuItemUpdate_menuItemUpdate_menuItem_page | null;
- sortOrder: number | null;
+ sortOrder: number;
url: string | null;
}
diff --git a/saleor/static/dashboard-next/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx b/saleor/static/dashboard-next/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx
index f18884e234..7b5f4f5575 100644
--- a/saleor/static/dashboard-next/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx
@@ -24,9 +24,10 @@ import ConfirmButton, {
} from "@saleor/components/ConfirmButton";
import Money from "@saleor/components/Money";
import TableCellAvatar from "@saleor/components/TableCellAvatar";
-import { ChangeEvent } from "@saleor/hooks/useForm";
+import useSearchQuery from "@saleor/hooks/useSearchQuery";
import i18n from "@saleor/i18n";
-import { maybe, onQueryChange, renderCollection } from "@saleor/misc";
+import { maybe, renderCollection } from "@saleor/misc";
+import { FetchMoreProps } from "@saleor/types";
import {
SearchOrderVariant_products_edges_node,
SearchOrderVariant_products_edges_node_variants
@@ -38,7 +39,6 @@ const styles = (theme: Theme) =>
paddingLeft: 0
},
content: {
- maxHeight: 600,
overflowY: "scroll"
},
grayText: {
@@ -75,15 +75,11 @@ type SetVariantsAction = (
data: SearchOrderVariant_products_edges_node_variants[]
) => void;
-interface OrderProductAddDialogProps extends WithStyles<typeof styles> {
+interface OrderProductAddDialogProps extends FetchMoreProps {
confirmButtonState: ConfirmButtonTransitionState;
open: boolean;
products: SearchOrderVariant_products_edges_node[];
- loading: boolean;
- hasMore: boolean;
onClose: () => void;
- onFetch: (value: string) => void;
- onFetchMore: () => void;
onSubmit: (data: SearchOrderVariant_products_edges_node_variants[]) => void;
}
@@ -164,8 +160,8 @@ const OrderProductAddDialog = withStyles(styles, {
onFetchMore,
onClose,
onSubmit
- }: OrderProductAddDialogProps) => {
- const [query, setQuery] = React.useState("");
+ }: OrderProductAddDialogProps & WithStyles<typeof styles>) => {
+ const [query, onQueryChange] = useSearchQuery(onFetch);
const [variants, setVariants] = React.useState<
SearchOrderVariant_products_edges_node_variants[]
>([]);
@@ -181,8 +177,6 @@ const OrderProductAddDialog = withStyles(styles, {
)
: [];
- const handleQueryChange = (event: ChangeEvent) =>
- onQueryChange(event, onFetch, setQuery);
const handleSubmit = () => onSubmit(variants);
return (
@@ -198,7 +192,7 @@ const OrderProductAddDialog = withStyles(styles, {
<TextField
name="query"
value={query}
- onChange={handleQueryChange}
+ onChange={onQueryChange}
label={i18n.t("Search Products", {
context: "product search input label"
})}
diff --git a/saleor/static/dashboard-next/productTypes/queries.ts b/saleor/static/dashboard-next/productTypes/queries.ts
index 9b34f532df..63bbbbec0a 100644
--- a/saleor/static/dashboard-next/productTypes/queries.ts
+++ b/saleor/static/dashboard-next/productTypes/queries.ts
@@ -1,7 +1,7 @@
import gql from "graphql-tag";
import { attributeFragment } from "@saleor/attributes/queries";
-import { TypedQuery } from "../queries";
+import { pageInfoFragment, TypedQuery } from "../queries";
import { ProductTypeCreateData } from "./types/ProductTypeCreateData";
import {
ProductTypeDetails,
@@ -44,6 +44,7 @@ export const productTypeDetailsFragment = gql`
`;
export const productTypeListQuery = gql`
+ ${pageInfoFragment}
${productTypeFragment}
query ProductTypeList(
$after: String
@@ -58,10 +59,7 @@ export const productTypeListQuery = gql`
}
}
pageInfo {
- hasNextPage
- hasPreviousPage
- startCursor
- endCursor
+ ...PageInfoFragment
}
}
}
diff --git a/saleor/static/dashboard-next/productTypes/types/ProductTypeList.ts b/saleor/static/dashboard-next/productTypes/types/ProductTypeList.ts
index e7fcf18178..64fa7e917d 100644
--- a/saleor/static/dashboard-next/productTypes/types/ProductTypeList.ts
+++ b/saleor/static/dashboard-next/productTypes/types/ProductTypeList.ts
@@ -28,10 +28,10 @@ export interface ProductTypeList_productTypes_edges {
export interface ProductTypeList_productTypes_pageInfo {
__typename: "PageInfo";
+ endCursor: string | null;
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
- endCursor: string | null;
}
export interface ProductTypeList_productTypes {
diff --git a/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate/index.tsx b/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate/index.tsx
index 16d63ff81c..074c3c53c7 100644
--- a/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate/index.tsx
+++ b/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate/index.tsx
@@ -4,7 +4,6 @@ import React from "react";
import { attributeUrl } from "@saleor/attributes/urls";
import AssignAttributeDialog from "@saleor/components/AssignAttributeDialog";
import { WindowTitle } from "@saleor/components/WindowTitle";
-import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config";
import SearchAttributes from "@saleor/containers/SearchAttributes";
import useBulkActions from "@saleor/hooks/useBulkActions";
import useNavigator from "@saleor/hooks/useNavigator";
@@ -325,53 +324,92 @@ export const ProductTypeUpdate: React.FC<ProductTypeUpdateProps> = ({
/>
{!dataLoading && (
<SearchAttributes
- variables={DEFAULT_INITIAL_SEARCH_DATA}
+ variables={{
+ first: 10,
+ query: ""
+ }}
>
- {({ search, result }) => (
- <>
- {Object.keys(AttributeTypeEnum).map(key => (
- <AssignAttributeDialog
- attributes={maybe(() =>
- result.data.attributes.edges.map(
- edge => edge.node
- )
- )}
- confirmButtonState={assignTransactionState}
- errors={maybe(
- () =>
- assignAttribute.opts.data.attributeAssign.errors.map(
- err => err.message
- ),
- []
- )}
- loading={result.loading}
- onClose={closeModal}
- onSubmit={handleAssignAttribute}
- onFetch={search}
- open={
- params.action === "assign-attribute" &&
- params.type === AttributeTypeEnum[key]
+ {({ search, result }) => {
+ const fetchMore = () =>
+ result.loadMore(
+ (prev, next) => {
+ if (
+ prev.attributes.pageInfo.endCursor ===
+ next.attributes.pageInfo.endCursor
+ ) {
+ return prev;
}
- selected={maybe(() => params.ids, [])}
- onToggle={attributeId => {
- const ids = maybe(() => params.ids, []);
- navigate(
- productTypeUrl(id, {
- ...params,
- ids: ids.includes(attributeId)
- ? params.ids.filter(
- selectedId =>
- selectedId !== attributeId
- )
- : [...ids, attributeId]
- })
- );
- }}
- key={key}
- />
- ))}
- </>
- )}
+ return {
+ ...prev,
+ attributes: {
+ ...prev.attributes,
+ edges: [
+ ...prev.attributes.edges,
+ ...next.attributes.edges
+ ],
+ pageInfo: next.attributes.pageInfo
+ }
+ };
+ },
+ {
+ after:
+ result.data.attributes.pageInfo.endCursor
+ }
+ );
+
+ return (
+ <>
+ {Object.keys(AttributeTypeEnum).map(key => (
+ <AssignAttributeDialog
+ attributes={maybe(() =>
+ result.data.attributes.edges.map(
+ edge => edge.node
+ )
+ )}
+ confirmButtonState={assignTransactionState}
+ errors={maybe(
+ () =>
+ assignAttribute.opts.data.attributeAssign.errors.map(
+ err => err.message
+ ),
+ []
+ )}
+ loading={result.loading}
+ onClose={closeModal}
+ onSubmit={handleAssignAttribute}
+ onFetch={search}
+ onFetchMore={fetchMore}
+ hasMore={maybe(
+ () =>
+ result.data.attributes.pageInfo
+ .hasNextPage,
+ false
+ )}
+ open={
+ params.action === "assign-attribute" &&
+ params.type === AttributeTypeEnum[key]
+ }
+ selected={maybe(() => params.ids, [])}
+ onToggle={attributeId => {
+ const ids = maybe(() => params.ids, []);
+ navigate(
+ productTypeUrl(id, {
+ ...params,
+ ids: ids.includes(attributeId)
+ ? params.ids.filter(
+ selectedId =>
+ selectedId !== attributeId
+ )
+ : [...ids, attributeId]
+ })
+ );
+ }}
+ key={key}
+ />
+ ))}
+ </>
+ );
+ }}
</SearchAttributes>
)}
<ProductTypeDeleteDialog
diff --git a/saleor/static/dashboard-next/products/types/Product.ts b/saleor/static/dashboard-next/products/types/Product.ts
index 6f501fbda1..8b3b5e347c 100644
--- a/saleor/static/dashboard-next/products/types/Product.ts
+++ b/saleor/static/dashboard-next/products/types/Product.ts
@@ -116,7 +116,7 @@ export interface Product_images {
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/ProductCreate.ts b/saleor/static/dashboard-next/products/types/ProductCreate.ts
index c0f419babf..6724a7595d 100644
--- a/saleor/static/dashboard-next/products/types/ProductCreate.ts
+++ b/saleor/static/dashboard-next/products/types/ProductCreate.ts
@@ -122,7 +122,7 @@ export interface ProductCreate_productCreate_product_images {
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/ProductCreateData.ts b/saleor/static/dashboard-next/products/types/ProductCreateData.ts
index c99bebcc63..31e557f2e1 100644
--- a/saleor/static/dashboard-next/products/types/ProductCreateData.ts
+++ b/saleor/static/dashboard-next/products/types/ProductCreateData.ts
@@ -11,7 +11,7 @@ import { AttributeInputTypeEnum } from "./../../types/globalTypes";
export interface ProductCreateData_productTypes_edges_node_productAttributes_values {
__typename: "AttributeValue";
id: string;
- sortOrder: number | null;
+ sortOrder: number;
name: string | null;
slug: string | null;
}
diff --git a/saleor/static/dashboard-next/products/types/ProductDetails.ts b/saleor/static/dashboard-next/products/types/ProductDetails.ts
index 47b83fcf92..7258a8f40f 100644
--- a/saleor/static/dashboard-next/products/types/ProductDetails.ts
+++ b/saleor/static/dashboard-next/products/types/ProductDetails.ts
@@ -116,7 +116,7 @@ export interface ProductDetails_product_images {
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/ProductImageCreate.ts b/saleor/static/dashboard-next/products/types/ProductImageCreate.ts
index 1a3bd5c1f8..fb89184110 100644
--- a/saleor/static/dashboard-next/products/types/ProductImageCreate.ts
+++ b/saleor/static/dashboard-next/products/types/ProductImageCreate.ts
@@ -122,7 +122,7 @@ export interface ProductImageCreate_productImageCreate_product_images {
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/ProductImageFragment.ts b/saleor/static/dashboard-next/products/types/ProductImageFragment.ts
index de4e5b5ca8..9eb7a37fb1 100644
--- a/saleor/static/dashboard-next/products/types/ProductImageFragment.ts
+++ b/saleor/static/dashboard-next/products/types/ProductImageFragment.ts
@@ -10,6 +10,6 @@ export interface ProductImageFragment {
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/ProductImageReorder.ts b/saleor/static/dashboard-next/products/types/ProductImageReorder.ts
index 4e59603896..47b5631a66 100644
--- a/saleor/static/dashboard-next/products/types/ProductImageReorder.ts
+++ b/saleor/static/dashboard-next/products/types/ProductImageReorder.ts
@@ -16,7 +16,7 @@ export interface ProductImageReorder_productImageReorder_product_images {
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/ProductImageUpdate.ts b/saleor/static/dashboard-next/products/types/ProductImageUpdate.ts
index 3068fb6ea8..21108bb79f 100644
--- a/saleor/static/dashboard-next/products/types/ProductImageUpdate.ts
+++ b/saleor/static/dashboard-next/products/types/ProductImageUpdate.ts
@@ -122,7 +122,7 @@ export interface ProductImageUpdate_productImageUpdate_product_images {
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/ProductUpdate.ts b/saleor/static/dashboard-next/products/types/ProductUpdate.ts
index 8aa76dc9d6..0c1011fe38 100644
--- a/saleor/static/dashboard-next/products/types/ProductUpdate.ts
+++ b/saleor/static/dashboard-next/products/types/ProductUpdate.ts
@@ -122,7 +122,7 @@ export interface ProductUpdate_productUpdate_product_images {
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/ProductVariant.ts b/saleor/static/dashboard-next/products/types/ProductVariant.ts
index ce379e15a8..d9ad5622a7 100644
--- a/saleor/static/dashboard-next/products/types/ProductVariant.ts
+++ b/saleor/static/dashboard-next/products/types/ProductVariant.ts
@@ -56,7 +56,7 @@ export interface ProductVariant_product_images {
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/ProductVariantCreateData.ts b/saleor/static/dashboard-next/products/types/ProductVariantCreateData.ts
index 956873a6a1..f882cf5e59 100644
--- a/saleor/static/dashboard-next/products/types/ProductVariantCreateData.ts
+++ b/saleor/static/dashboard-next/products/types/ProductVariantCreateData.ts
@@ -9,14 +9,14 @@
export interface ProductVariantCreateData_product_images {
__typename: "ProductImage";
id: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
export interface ProductVariantCreateData_product_productType_variantAttributes_values {
__typename: "AttributeValue";
id: string;
- sortOrder: number | null;
+ sortOrder: number;
name: string | null;
slug: string | null;
}
diff --git a/saleor/static/dashboard-next/products/types/ProductVariantDetails.ts b/saleor/static/dashboard-next/products/types/ProductVariantDetails.ts
index 793fee6605..99cb40f580 100644
--- a/saleor/static/dashboard-next/products/types/ProductVariantDetails.ts
+++ b/saleor/static/dashboard-next/products/types/ProductVariantDetails.ts
@@ -56,7 +56,7 @@ export interface ProductVariantDetails_productVariant_product_images {
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/SimpleProductUpdate.ts b/saleor/static/dashboard-next/products/types/SimpleProductUpdate.ts
index e52a9ebd3b..0151933866 100644
--- a/saleor/static/dashboard-next/products/types/SimpleProductUpdate.ts
+++ b/saleor/static/dashboard-next/products/types/SimpleProductUpdate.ts
@@ -122,7 +122,7 @@ export interface SimpleProductUpdate_productUpdate_product_images {
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
@@ -237,7 +237,7 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_product
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/VariantCreate.ts b/saleor/static/dashboard-next/products/types/VariantCreate.ts
index c763a11aa6..63e2a327e1 100644
--- a/saleor/static/dashboard-next/products/types/VariantCreate.ts
+++ b/saleor/static/dashboard-next/products/types/VariantCreate.ts
@@ -64,7 +64,7 @@ export interface VariantCreate_productVariantCreate_productVariant_product_image
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/VariantImageAssign.ts b/saleor/static/dashboard-next/products/types/VariantImageAssign.ts
index 560d08e0b9..27a6090b32 100644
--- a/saleor/static/dashboard-next/products/types/VariantImageAssign.ts
+++ b/saleor/static/dashboard-next/products/types/VariantImageAssign.ts
@@ -62,7 +62,7 @@ export interface VariantImageAssign_variantImageAssign_productVariant_product_im
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/VariantImageUnassign.ts b/saleor/static/dashboard-next/products/types/VariantImageUnassign.ts
index 3a63b52e8b..8c41a68583 100644
--- a/saleor/static/dashboard-next/products/types/VariantImageUnassign.ts
+++ b/saleor/static/dashboard-next/products/types/VariantImageUnassign.ts
@@ -62,7 +62,7 @@ export interface VariantImageUnassign_variantImageUnassign_productVariant_produc
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/products/types/VariantUpdate.ts b/saleor/static/dashboard-next/products/types/VariantUpdate.ts
index 0f723a4352..3ad83d91ba 100644
--- a/saleor/static/dashboard-next/products/types/VariantUpdate.ts
+++ b/saleor/static/dashboard-next/products/types/VariantUpdate.ts
@@ -64,7 +64,7 @@ export interface VariantUpdate_productVariantUpdate_productVariant_product_image
__typename: "ProductImage";
id: string;
alt: string;
- sortOrder: number | null;
+ sortOrder: number;
url: string;
}
diff --git a/saleor/static/dashboard-next/types.ts b/saleor/static/dashboard-next/types.ts
index ee179e5ebb..accab494b4 100644
--- a/saleor/static/dashboard-next/types.ts
+++ b/saleor/static/dashboard-next/types.ts
@@ -115,3 +115,10 @@ export interface ReorderEvent {
newIndex: number;
}
export type ReorderAction = (event: ReorderEvent) => void;
+
+export interface FetchMoreProps<TData = string> {
+ loading: boolean;
+ hasMore: boolean;
+ onFetch: (value: TData) => void;
+ onFetchMore: () => void;
+}
diff --git a/saleor/static/dashboard-next/utils/handlers/queryChangeHandler.ts b/saleor/static/dashboard-next/utils/handlers/queryChangeHandler.ts
new file mode 100644
index 0000000000..8297c44cb4
--- /dev/null
+++ b/saleor/static/dashboard-next/utils/handlers/queryChangeHandler.ts
@@ -0,0 +1,12 @@
+import { ChangeEvent } from "@saleor/hooks/useForm";
+
+export function onQueryChange(
+ event: ChangeEvent,
+ onFetch: (data: string) => void,
+ setQuery: (data: string) => void
+) {
+ const value = event.target.value;
+
+ onFetch(value);
+ setQuery(value);
+}