From 66bfd1a32d5bd7e8a0a12c4720ef0429f8a72980 Mon Sep 17 00:00:00 2001 From: Jonatan Witoszek Date: Thu, 12 May 2022 15:39:27 +0200 Subject: [PATCH] Fix subcategory creation (#2041) * Fix subcategory create button didn't use Button from dashboard * Update snapshots --- .../CategoryUpdatePage/CategoryUpdatePage.tsx | 15 +- src/categories/views/CategoryDetails.tsx | 3 +- .../__snapshots__/Stories.test.ts.snap | 286 +++++++----------- .../stories/categories/CategoryUpdatePage.tsx | 2 +- 4 files changed, 126 insertions(+), 180 deletions(-) diff --git a/src/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx b/src/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx index e712116c7..456a52594 100644 --- a/src/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx +++ b/src/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx @@ -1,6 +1,11 @@ import { Card } from "@material-ui/core"; -import { categoryListUrl, categoryUrl } from "@saleor/categories/urls"; +import { + categoryAddUrl, + categoryListUrl, + categoryUrl +} from "@saleor/categories/urls"; import { Backlink } from "@saleor/components/Backlink"; +import { Button } from "@saleor/components/Button"; import { CardSpacer } from "@saleor/components/CardSpacer"; import CardTitle from "@saleor/components/CardTitle"; import Container from "@saleor/components/Container"; @@ -13,7 +18,7 @@ import { CategoryDetailsQuery, ProductErrorFragment } from "@saleor/graphql"; import { SubmitPromise } from "@saleor/hooks/useForm"; import useNavigator from "@saleor/hooks/useNavigator"; import { sectionNames } from "@saleor/intl"; -import { Button, ConfirmButtonTransitionState } from "@saleor/macaw-ui"; +import { ConfirmButtonTransitionState } from "@saleor/macaw-ui"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; @@ -32,6 +37,7 @@ export enum CategoryPageTab { export interface CategoryUpdatePageProps extends TabListActions<"productListToolbar" | "subcategoryListToolbar"> { + categoryId: string; changeTab: (index: CategoryPageTab) => void; currentTab: CategoryPageTab; errors: ProductErrorFragment[]; @@ -45,7 +51,6 @@ export interface CategoryUpdatePageProps }; saveButtonBarState: ConfirmButtonTransitionState; addProductHref: string; - addCategoryHref: string; onImageDelete: () => void; onSubmit: (data: CategoryUpdateData) => SubmitPromise; onImageUpload(file: File); @@ -58,6 +63,7 @@ const CategoriesTab = Tab(CategoryPageTab.categories); const ProductsTab = Tab(CategoryPageTab.products); export const CategoryUpdatePage: React.FC = ({ + categoryId, changeTab, currentTab, category, @@ -67,7 +73,6 @@ export const CategoryUpdatePage: React.FC = ({ products, saveButtonBarState, subcategories, - addCategoryHref, onDelete, onNextPage, onPreviousPage, @@ -171,7 +176,7 @@ export const CategoryUpdatePage: React.FC = ({ toolbar={ +
- +
- +
- +
- +
-
-
- -
-
- - - New Variant + Add variant + + @@ -184430,36 +184421,22 @@ exports[`Storyshots Views / Products / Create product variant default 1`] = ` class="MuiTableRow-root-id MuiTableRow-hover-id" > -
-
- -
-
- - - New Variant + Add variant + + @@ -185495,36 +185472,22 @@ exports[`Storyshots Views / Products / Create product variant no warehouses 1`] class="MuiTableRow-root-id MuiTableRow-hover-id" > -
-
- -
-
- - - New Variant + Add variant + + @@ -186438,36 +186401,22 @@ exports[`Storyshots Views / Products / Create product variant when loading data class="MuiTableRow-root-id MuiTableRow-hover-id" > -
-
- -
-
- - - New Variant + Add variant + + @@ -187373,36 +187322,22 @@ exports[`Storyshots Views / Products / Create product variant with errors 1`] = class="MuiTableRow-root-id MuiTableRow-hover-id" > -
-
- -
-
- - - New Variant + Add variant + + @@ -224208,17 +224143,19 @@ exports[`Storyshots Views / Products / Product variant details attribute errors class="MuiTableCell-root-id MuiTableCell-body-id" colspan="3" > - + @@ -226127,17 +226064,19 @@ exports[`Storyshots Views / Products / Product variant details no warehouses 1`] class="MuiTableCell-root-id MuiTableCell-body-id" colspan="3" > - + @@ -228036,17 +227975,19 @@ exports[`Storyshots Views / Products / Product variant details when loaded data class="MuiTableCell-root-id MuiTableCell-body-id" colspan="3" > - + @@ -229807,17 +229748,19 @@ exports[`Storyshots Views / Products / Product variant details when loading data class="MuiTableCell-root-id MuiTableCell-body-id" colspan="3" > - + @@ -229894,12 +229837,11 @@ exports[`Storyshots Views / Products / Product variant details when loading data
- - ‌ - + Select a specific variant media from product media +
diff --git a/src/storybook/stories/categories/CategoryUpdatePage.tsx b/src/storybook/stories/categories/CategoryUpdatePage.tsx index 86ffead2d..509918af9 100644 --- a/src/storybook/stories/categories/CategoryUpdatePage.tsx +++ b/src/storybook/stories/categories/CategoryUpdatePage.tsx @@ -16,11 +16,11 @@ const category = categoryFixture(placeholderImage); const updateProps: Omit = { category, + categoryId: "123", changeTab: undefined, currentTab: CategoryPageTab.categories, disabled: false, errors: [], - addCategoryHref: "", addProductHref: "", onDelete: () => undefined, onImageDelete: () => undefined,