Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix types menagment and add background component for Category Create Page
Lukasz Szewczykfa793983f634
diff --git a/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsxindex a8622a5c7b..abea1acff2 100644--- a/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx@@ -9,7 +9,7 @@ import { UserError } from "../../../";import i18n from "../../../i18n";import CategoryDetailsForm from "../../components/CategoryDetailsForm";import SeoForm from "../../../components/SeoForm";-// import CategoryBackground from "../CategoryBackground";+import CategoryBackground from "../CategoryBackground";import CategoryCreateSubcategories from "../CategoryCreateSubcategories";import Toggle from "../../../components/Toggle";import CategoryDeleteDialog from "../../components/CategoryDeleteDialog";@@ -19,27 +19,23 @@ import SaveButtonBar, {} from "../../../components/SaveButtonBar/SaveButtonBar";interface FormData {- //CategoryDetailsFormdescription: string;name: string;-- // SeoFormseoTitle: string;seoDescription: string;}-interface CategoryCreatePageProps {+export interface CategoryCreatePageProps {errors: UserError[];header: string;-+ placeholderImage: string;disabled: boolean;-onSubmit(data: FormData);onImageUpload?(event: React.ChangeEvent<any>);-onBack();onDelete();saveButtonBarState?: SaveButtonBarState;+ onImageDelete: (id: string) => () => void;}const decorate = withStyles(theme => ({root: {@@ -57,9 +53,11 @@ export const CategoryCreatePage = decorate<CategoryCreatePageProps>(onSubmit,onBack,errors: userErrors,- // onImageUpload,onDelete,- saveButtonBarState+ saveButtonBarState,+ onImageUpload,+ onImageDelete,+ placeholderImage}) => {const initialData: FormData = {name: "",@@ -82,10 +80,12 @@ export const CategoryCreatePage = decorate<CategoryCreatePageProps>(onChange={change}errors={errors}/>- {/* <CategoryBackground+ <CategoryBackgroundonImageUpload={onImageUpload}+ onImageDelete={onImageDelete}+ placeholderImage={placeholderImage}disabled={disabled}- /> */}+ /><CategoryCreateSubcategories disabled={disabled} /><SeoFormhelperText={i18n.t(diff --git a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsxindex acb9245b64..b951911f4a 100644--- a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx@@ -1,18 +1,18 @@import { withStyles } from "@material-ui/core/styles";import * as React from "react";import AddIcon from "@material-ui/icons/Add";+import Button from "@material-ui/core/Button";+import DialogContentText from "@material-ui/core/DialogContentText";+import CategoryBackground from "../CategoryBackground";import Container from "../../../components/Container";import PageHeader from "../../../components/PageHeader";--import CategoryBackground from "../CategoryBackground";import CategoryList from "../../components/CategoryList";-import CategoryDetailsForm from "../../components/CategoryDetailsForm";import SeoForm from "../../../components/SeoForm";import Form from "../../../components/Form";import CategoryProductsCard from "../CategoryProductsCard";-import DialogContentText from "@material-ui/core/DialogContentText";+import ActionDialog from "../../../components/ActionDialog";import { MoneyType } from "../../../products";import Toggle from "../../../components/Toggle";@@ -21,7 +21,7 @@ import SaveButtonBar, {} from "../../../components/SaveButtonBar/SaveButtonBar";import Tabs, { SingleTab } from "../../../components/Tab";import { UserError } from "../../../";-import Button from "@material-ui/core/Button";+import i18n from "../../../i18n";interface FormData {@@ -33,14 +33,14 @@ interface FormData {export interface CategoryUpdatePageProps {errors: UserError[];disabled: boolean;- placeholderImage?: string;+ placeholderImage: string;category: {SeoDescription: string;SeoTitle: string;name: string;description: string;};- backgroundImage?: {+ backgroundImage: {id?: string;url?: string;};@@ -72,17 +72,17 @@ export interface CategoryUpdatePageProps {};loading: boolean;saveButtonBarState?: SaveButtonBarState;- onSubmit?(data: FormData);+ onSubmit(data: FormData);onImageUpload?(event: React.ChangeEvent<any>);- onNextPage?();- onPreviousPage?();- onProductClick?(id: string): () => void;- onAddProduct?();- onBack?();- onDelete?();- onImageDelete?: (id: string) => () => void;+ onNextPage();+ onPreviousPage();+ onProductClick(id: string): () => void;+ onAddProduct();+ onBack();+ onDelete();+ onImageDelete: (id: string) => () => void;onAddCategory();- onCategoryClick?(id: string): () => void;+ onCategoryClick(id: string): () => void;}const decorate = withStyles(theme => ({diff --git a/saleor/static/dashboard-next/categories/fixtures.ts b/saleor/static/dashboard-next/categories/fixtures.tsindex 1b01e4a4db..099d5a825f 100644--- a/saleor/static/dashboard-next/categories/fixtures.ts+++ b/saleor/static/dashboard-next/categories/fixtures.ts@@ -1,4 +1,5 @@import { products } from "../products/fixtures";+import * as block1 from "../../images/block1.jpg";export const categories = [{@@ -73,7 +74,7 @@ export const category = (placeholderImage: string) => ({name: "Apparel",backgroundImage: {id: "UPJvZHVjfEs4YWdlOjV",- url: placeholderImage+ url: block1},products: products(placeholderImage)});diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsxindex 5107766a1d..15e45e6cea 100644--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsx@@ -1,28 +1,26 @@import { storiesOf } from "@storybook/react";import * as React from "react";+import * as placeholderImage from "../../../../images/placeholder255x255.png";-import CategoryCreatePage from "../../../categories/components/CategoryCreatePage";+import CategoryCreatePage, {+ CategoryCreatePageProps+} from "../../../categories/components/CategoryCreatePage";import Decorator from "../../Decorator";+const createProps: CategoryCreatePageProps = {+ header: "Add category",+ disabled: false,+ errors: [],+ onBack: () => undefined,+ onSubmit: () => undefined,+ onDelete: () => undefined,+ placeholderImage: placeholderImage,+ onImageDelete: () => undefined+};+storiesOf("Views / Categories / Create category", module).addDecorator(Decorator)- .add("default", () => (- <CategoryCreatePage- header="Add category"- disabled={false}- errors={[]}- onBack={() => undefined}- onSubmit={() => undefined}- onDelete={() => undefined}- />- ))+ .add("default", () => <CategoryCreatePage {...createProps} />).add("When loading", () => (- <CategoryCreatePage- header="Add category"- disabled={true}- errors={[]}- onBack={() => undefined}- onSubmit={() => undefined}- onDelete={() => undefined}- />+ <CategoryCreatePage {...createProps} disabled={true} />));diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsxindex 7622327835..a2febb1106 100644--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx@@ -25,6 +25,7 @@ const updateProps: CategoryUpdatePageProps = {hasPreviousPage: true},onNextPage: undefined,+ onSubmit: () => undefined,onPreviousPage: undefined,onImageDelete: () => undefined,onProductClick: () => undefined,