Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve types
dominik-zeglen5d7dd09fb424
diff --git a/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx b/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsxindex 25f1b54c2b..485b970902 100644--- a/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx+++ b/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx@@ -10,10 +10,10 @@ import ProductList from "../../../components/ProductList";import { Filter } from "../../../components/TableFilter";import i18n from "../../../i18n";import { PageListProps } from "../../../types";-import ProductListFilter from "../ProductListFilter";+import ProductListFilter, { ProductListFilterTabs } from "../ProductListFilter";interface ProductListCardProps extends PageListProps {- currentTab: number;+ currentTab: ProductListFilterTabs;filtersList: Filter[];products: CategoryDetails_category_products_edges_node[];onAllProducts: () => void;diff --git a/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsx b/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsxindex 79d54ae826..09c34b9df3 100644--- a/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsx+++ b/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsx@@ -8,8 +8,14 @@ import {} from "../../../components/TableFilter";import i18n from "../../../i18n";+export type ProductListFilterTabs =+ | "all"+ | "available"+ | "outOfStock"+ | "custom";+interface ProductListFilterProps {- currentTab: number;+ currentTab: ProductListFilterTabs;filtersList: Filter[];onAllProducts: () => void;onAvailable: () => void;@@ -26,11 +32,15 @@ const ProductListFilter: React.StatelessComponent<ProductListFilterProps> = ({onCustomFilter}) => (<>- <FilterTabs currentTab={currentTab}>+ <FilterTabs+ currentTab={["all", "available", "outOfStock", "custom"].indexOf(+ currentTab+ )}+ ><FilterTab label={i18n.t("All Products")} onClick={onAllProducts} />- <FilterTab label={i18n.t("Availiable")} onClick={onAvailable} />+ <FilterTab label={i18n.t("Available")} onClick={onAvailable} /><FilterTab label={i18n.t("Out Of Stock")} onClick={onOfStock} />- {currentTab === 0 && filtersList && filtersList.length > 0 && (+ {currentTab === "custom" && filtersList && filtersList.length > 0 && (<FilterTabonClick={onCustomFilter}value={0}@@ -38,7 +48,7 @@ const ProductListFilter: React.StatelessComponent<ProductListFilterProps> = ({/>)}</FilterTabs>- {currentTab === 0 && filtersList && filtersList.length > 0 && (+ {currentTab === "custom" && filtersList && filtersList.length > 0 && (<FilterChip filtersList={filtersList} />)}</>diff --git a/saleor/static/dashboard-next/products/views/ProductList.tsx b/saleor/static/dashboard-next/products/views/ProductList.tsxindex 5d552214c7..9494e8bbff 100644--- a/saleor/static/dashboard-next/products/views/ProductList.tsx+++ b/saleor/static/dashboard-next/products/views/ProductList.tsx@@ -35,6 +35,8 @@ export const ProductList: React.StatelessComponent<ProductListProps> = ({if (error) {return <ErrorMessageCard message="Something went wrong" />;}++ const currentTab = "all";return (<PaginatorpageInfo={maybe(() => data.products.pageInfo)}@@ -43,7 +45,7 @@ export const ProductList: React.StatelessComponent<ProductListProps> = ({>{({ loadNextPage, loadPreviousPage, pageInfo }) => (<ProductListCard- currentTab={0}+ currentTab={currentTab}filtersList={[]}onAdd={() => navigate(productAddUrl)}disabled={loading}