Skip to content

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

wip

Lukasz Szewczykfd2dfbb166da
diff --git a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx
index dc08dd8983..5468234328 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx
@@ -1,4 +1,4 @@
-import { withStyles } from "@material-ui/core/styles";
+import { withStyles, WithStyles } from "@material-ui/core/styles";
import * as React from "react";
import Card from "@material-ui/core/Card";
@@ -12,7 +12,7 @@ import i18n from "../../../i18n";
interface CategoryBackgroundProps {
onImageUpload?(event: React.ChangeEvent<any>);
- disabled: boolean;
+ disabled?: boolean;
}
const decorate = withStyles(theme => ({
@@ -30,39 +30,51 @@ const decorate = withStyles(theme => ({
}
}));
-export const CategoryBackground = decorate<CategoryBackgroundProps>(
- ({ classes, onImageUpload, disabled }) => {
- return (
- <Card>
- <CardTitle
- title={i18n.t("Background image (optional)")}
- toolbar={
- <>
- <Button
- variant="flat"
- color="secondary"
- disabled={disabled}
- onClick={() => this.upload.click()}
- >
- {i18n.t("Upload image")}
- </Button>
- <input
- className={classes.fileField}
- id="fileUpload"
- onChange={onImageUpload}
- type="file"
- ref={ref => (this.upload = ref)}
- />
- </>
- }
- />
- <CardContent>
- <div className={classes.noPhotosIconContainer}>
- <AddPhotoIcon className={classes.noPhotosIcon} />
- </div>
- </CardContent>
- </Card>
- );
+export const CategoryBackground = decorate(
+ class CategoryBackgroundClass extends React.Component<
+ CategoryBackgroundProps &
+ WithStyles<"noPhotosIcon" | "noPhotosIconContainer" | "fileField">,
+ {}
+ > {
+ imgInputAnchor = React.createRef<HTMLInputElement>();
+
+ clickImgInput = () => this.imgInputAnchor.current.click();
+
+ render() {
+ const { classes, onImageUpload, disabled } = this.props;
+ return (
+ <Card>
+ <CardTitle
+ title={i18n.t("Background image (optional)")}
+ toolbar={
+ <>
+ <Button
+ variant="flat"
+ color="secondary"
+ disabled={disabled}
+ onClick={this.clickImgInput}
+ >
+ {i18n.t("Upload image")}
+ </Button>
+ <input
+ className={classes.fileField}
+ id="fileUpload"
+ onChange={onImageUpload}
+ type="file"
+ ref={this.imgInputAnchor}
+ />
+ </>
+ }
+ />
+ <CardContent>
+ <div className={classes.noPhotosIconContainer}>
+ <AddPhotoIcon className={classes.noPhotosIcon} />
+ </div>
+ </CardContent>
+ </Card>
+ );
+ }
}
);
+
export default CategoryBackground;
diff --git a/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
index 4bcb1fea80..14561c8b0d 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
@@ -34,11 +34,11 @@ interface CategoryCreatePageProps {
disabled: boolean;
- onSubmit?(data: FormData);
+ onSubmit(data: FormData);
onImageUpload?(event: React.ChangeEvent<any>);
- onBack?();
- onDelete?();
+ onBack();
+ onDelete();
saveButtonBarState?: SaveButtonBarState;
}
const decorate = withStyles(theme => ({
diff --git a/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx b/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx
index c7bd152819..bf5ec27da4 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx
@@ -11,6 +11,7 @@ import DeleteIcon from "@material-ui/icons/Delete";
import IconButton from "@material-ui/core/IconButton";
import AddIcon from "@material-ui/icons/Add";
// import CardActions from "@material-ui/core/CardActions";
+import Hr from "../../../components/Hr";
import CardTitle from "../../../components/CardTitle";
import Toggle from "../../../components/Toggle";
@@ -26,7 +27,8 @@ const decorate = withStyles(theme => ({
root: {
display: "grid",
gridColumnGap: theme.spacing.unit * 2 + "px",
- gridTemplateColumns: "5fr 8fr 0.5fr"
+ gridTemplateColumns: "5fr 8fr 30px",
+ marginBottom: "1rem"
},
helperText: {
marginBottom: theme.spacing.unit * 4
@@ -37,13 +39,6 @@ const decorate = withStyles(theme => ({
},
addSubCat: {
padding: "0px"
- },
- hr: {
- backgroundColor: "#eaeaea",
- border: "none",
- height: 1,
- marginBottom: theme.spacing.unit,
- marginTop: theme.spacing.unit * 3
}
}));
@@ -87,8 +82,7 @@ export const CategoryCreateSubcategories = decorate<
</IconButton>
</div>
- <hr className={classes.hr} />
-
+ <Hr />
<Button
variant="flat"
color="secondary"
diff --git a/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx b/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx
index 66e8a3a1e0..a1b38683d7 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx
@@ -37,7 +37,7 @@ export const CategoryDetailsForm = decorate<CategoryDetailsFormProps>(
<Card>
<CardTitle title={i18n.t("General information")} />
<CardContent>
- {loading === true ? (
+ {loading ? (
<Skeleton />
) : (
<>
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsx
index f7847f7457..5107766a1d 100644
--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsx
@@ -12,6 +12,8 @@ storiesOf("Views / Categories / Create category", module)
disabled={false}
errors={[]}
onBack={() => undefined}
+ onSubmit={() => undefined}
+ onDelete={() => undefined}
/>
))
.add("When loading", () => (
@@ -20,5 +22,7 @@ storiesOf("Views / Categories / Create category", module)
disabled={true}
errors={[]}
onBack={() => undefined}
+ onSubmit={() => undefined}
+ onDelete={() => undefined}
/>
));
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx
index c61b46d5f5..0b5959bbed 100644
--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx
@@ -47,12 +47,13 @@ storiesOf("Views / Categories / Update category", module)
))
.add("When loading", () => (
<CategoryUpdatePage
- subcategories={category.children}
+ subcategories={undefined}
disabled={false}
category={category}
errors={[]}
- // products={category.products}
+ products={undefined}
loading={true}
onProductClick={() => undefined}
+ onCategoryClick={() => undefined}
/>
));