Skip to content

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

Refactor code a bit

dominik-zeglene27c58fce00e
diff --git a/saleor/static/dashboard-next/storybook/stories/translations/TranslationsEntitiesListPage.tsx b/saleor/static/dashboard-next/storybook/stories/translations/TranslationsEntitiesListPage.tsx
index a5963cdcd6..2bdb320f41 100644
--- a/saleor/static/dashboard-next/storybook/stories/translations/TranslationsEntitiesListPage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/translations/TranslationsEntitiesListPage.tsx
@@ -2,6 +2,7 @@ import { storiesOf } from "@storybook/react";
import * as React from "react";
import { pageListProps } from "../../../fixtures";
+import TranslationsEntitiesList from "../../../translations/components/TranslationsEntitiesList";
import TranslationsEntitiesListPage, {
TranslationsEntitiesListPageProps
} from "../../../translations/components/TranslationsEntitiesListPage";
@@ -10,56 +11,50 @@ import Decorator from "../../Decorator";
const props: TranslationsEntitiesListPageProps = {
...pageListProps.default,
- entities: [
- {
- completion: {
- current: 3,
- max: 8
- },
- id: "1",
- name: "Some product 1"
- },
- {
- completion: {
- current: 2,
- max: 5
- },
- id: "2",
- name: "Some product 2"
- },
- {
- completion: {
- current: 7,
- max: 11
- },
- id: "3",
- name: "Some product 3"
- }
- ],
+ children: null,
filters: {
current: "products",
onCategoriesTabClick: () => undefined,
- onProductsTabClick: () => undefined
+ onCollectionsTabClick: () => undefined,
+ onPagesTabClick: () => undefined,
+ onProductTypesTabClick: () => undefined,
+ onProductsTabClick: () => undefined,
+ onSalesTabClick: () => undefined,
+ onVouchersTabClick: () => undefined
},
language: {
__typename: "LanguageDisplay",
code: LanguageCodeEnum.EN,
language: "English"
},
- onBack: () => undefined,
- onRowClick: () => undefined
+ onBack: () => undefined
};
storiesOf("Views / Translations / Entity list", module)
.addDecorator(Decorator)
- .add("default", () => <TranslationsEntitiesListPage {...props} />)
- .add("loading", () => (
- <TranslationsEntitiesListPage
- {...props}
- entities={undefined}
- disabled={true}
- />
- ))
- .add("no data", () => (
- <TranslationsEntitiesListPage {...props} entities={[]} />
+ .add("default", () => (
+ <TranslationsEntitiesListPage {...props}>
+ <TranslationsEntitiesList
+ disabled={false}
+ entities={[
+ {
+ completion: { current: 1, max: 3 },
+ id: "1",
+ name: "White Hoodie"
+ },
+ {
+ completion: { current: 2, max: 3 },
+ id: "1",
+ name: "Brown Supreme Hoodie"
+ }
+ ]}
+ onRowClick={() => undefined}
+ onNextPage={() => undefined}
+ onPreviousPage={() => undefined}
+ pageInfo={{
+ hasNextPage: true,
+ hasPreviousPage: false
+ }}
+ />
+ </TranslationsEntitiesListPage>
));
diff --git a/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFields.tsx b/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFields.tsx
index 4fbbaf3cb3..d506fc2ff9 100644
--- a/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFields.tsx
+++ b/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFields.tsx
@@ -155,7 +155,7 @@ const TranslationFields = withStyles(styles, { name: "TranslationFields" })(
{i18n.t("Edit")}
</Button>
</div>
- <Typography className={classes.content}>
+ <div className={classes.content}>
{field && field.value !== undefined ? (
field.type === "short" ? (
<TranslationFieldsShort
@@ -185,7 +185,7 @@ const TranslationFields = withStyles(styles, { name: "TranslationFields" })(
) : (
<Skeleton />
)}
- </Typography>
+ </div>
<Typography className={classes.content}>
{field && field.translation !== undefined ? (
field.type === "short" ? (
diff --git a/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsLong.tsx b/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsLong.tsx
index 49f90b8996..645d151758 100644
--- a/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsLong.tsx
+++ b/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsLong.tsx
@@ -51,7 +51,7 @@ const TranslationFieldsLong: React.FC<TranslationFieldsLongProps> = ({
{i18n.t("No translation yet")}
</Typography>
) : (
- initial
+ <Typography>{initial}</Typography>
);
TranslationFieldsLong.displayName = "TranslationFieldsLong";
export default TranslationFieldsLong;
diff --git a/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsRich.tsx b/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsRich.tsx
index fe4a9859a2..24a262a358 100644
--- a/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsRich.tsx
+++ b/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsRich.tsx
@@ -53,7 +53,9 @@ const TranslationFieldsRich: React.FC<TranslationFieldsRichProps> = ({
{i18n.t("No translation yet")}
</Typography>
) : (
- <DraftRenderer content={JSON.parse(initial)} />
+ <Typography>
+ <DraftRenderer content={JSON.parse(initial)} />
+ </Typography>
);
TranslationFieldsRich.displayName = "TranslationFieldsRich";
export default TranslationFieldsRich;
diff --git a/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsShort.tsx b/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsShort.tsx
index d0376d3ec2..527fe45651 100644
--- a/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsShort.tsx
+++ b/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFieldsShort.tsx
@@ -50,7 +50,7 @@ const TranslationFieldsShort: React.FC<TranslationFieldsShortProps> = ({
{i18n.t("No translation yet")}
</Typography>
) : (
- initial
+ <Typography>{initial}</Typography>
);
TranslationFieldsShort.displayName = "TranslationFieldsShort";
export default TranslationFieldsShort;
diff --git a/saleor/static/dashboard-next/translations/components/TranslationsEntitiesList/TranslationsEntitiesList.tsx b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesList/TranslationsEntitiesList.tsx
index 7aa25fa3de..b83e35f92c 100644
--- a/saleor/static/dashboard-next/translations/components/TranslationsEntitiesList/TranslationsEntitiesList.tsx
+++ b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesList/TranslationsEntitiesList.tsx
@@ -1,10 +1,5 @@
import { Omit } from "@material-ui/core";
-import {
- createStyles,
- Theme,
- withStyles,
- WithStyles
-} from "@material-ui/core/styles";
+import { createStyles, withStyles, WithStyles } 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";
@@ -35,18 +30,17 @@ export interface TranslationsEntitiesListProps
onRowClick: (code: string) => void;
}
-const styles = (theme: Theme) =>
- createStyles({
- tableRow: {
- cursor: "pointer"
- },
- textRight: {
- textAlign: "right"
- },
- wideColumn: {
- width: "80%"
- }
- });
+const styles = createStyles({
+ tableRow: {
+ cursor: "pointer"
+ },
+ textRight: {
+ textAlign: "right"
+ },
+ wideColumn: {
+ width: "80%"
+ }
+});
const TranslationsEntitiesList = withStyles(styles, {
name: "TranslationsEntitiesList"
})(