From 4cc48250b2edc3fe30a4cdea0921e3215b146294 Mon Sep 17 00:00:00 2001 From: Krzysztof Bialoglowicz Date: Wed, 11 Sep 2019 16:24:24 +0200 Subject: [PATCH] Fix small issues --- .../AttributeDetails/AttributeDetails.tsx | 2 +- .../AttributeValues/AttributeValues.tsx | 2 +- .../CategoryDetailsForm.tsx | 100 ++++++++---------- .../CollectionDetails/CollectionDetails.tsx | 94 ++++++++-------- .../CollectionDetailsPage.tsx | 2 +- .../RadioGroupField/RadioGroupField.tsx | 40 +++---- .../VisibilityCard/VisibilityCard.tsx | 12 +-- src/icons/Attributes.tsx | 4 +- src/pages/views/PageCreate.tsx | 6 +- .../ProductTypeListPage.tsx | 2 +- .../ProductDetailsForm/ProductDetailsForm.tsx | 91 ++++++++-------- .../TranslationsLanguageListPage.tsx | 2 - 12 files changed, 161 insertions(+), 196 deletions(-) diff --git a/src/attributes/components/AttributeDetails/AttributeDetails.tsx b/src/attributes/components/AttributeDetails/AttributeDetails.tsx index eff953517..9d873b5e3 100644 --- a/src/attributes/components/AttributeDetails/AttributeDetails.tsx +++ b/src/attributes/components/AttributeDetails/AttributeDetails.tsx @@ -104,7 +104,7 @@ const AttributeDetails: React.FC = ({ /> = ({ } diff --git a/src/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx b/src/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx index b887bd3cf..a9a1764a1 100644 --- a/src/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx +++ b/src/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx @@ -1,6 +1,5 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; -import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles"; import TextField from "@material-ui/core/TextField"; import { RawDraftContentState } from "draft-js"; import React from "react"; @@ -13,13 +12,7 @@ import { commonMessages } from "@saleor/intl"; import { maybe } from "../../../misc"; import { CategoryDetails_category } from "../../types/CategoryDetails"; -const styles = createStyles({ - root: { - width: "100%" - } -}); - -interface CategoryDetailsFormProps extends WithStyles { +interface CategoryDetailsFormProps { category?: CategoryDetails_category; data: { name: string; @@ -30,57 +23,52 @@ interface CategoryDetailsFormProps extends WithStyles { onChange: (event: React.ChangeEvent) => void; } -export const CategoryDetailsForm = withStyles(styles, { - name: "CategoryDetailsForm" -})( - ({ - category, - classes, - disabled, - data, - onChange, - errors - }: CategoryDetailsFormProps) => { - const intl = useIntl(); +export const CategoryDetailsForm = ({ + category, + classes, + disabled, + data, + onChange, + errors +}: CategoryDetailsFormProps) => { + const intl = useIntl(); - return ( - - - - <> -
- -
- - + + + <> +
+ JSON.parse(category.descriptionJson))} - name="description" + name="name" + disabled={disabled} + value={data && data.name} onChange={onChange} + error={!!errors.name} + helperText={errors.name} + fullWidth /> - - - - ); - } -); -CategoryDetailsForm.displayName = "CategoryDetailsForm"; +
+ + JSON.parse(category.descriptionJson))} + name="description" + onChange={onChange} + /> + +
+
+ ); +}; export default CategoryDetailsForm; diff --git a/src/collections/components/CollectionDetails/CollectionDetails.tsx b/src/collections/components/CollectionDetails/CollectionDetails.tsx index a86d16cbd..0d11561a2 100644 --- a/src/collections/components/CollectionDetails/CollectionDetails.tsx +++ b/src/collections/components/CollectionDetails/CollectionDetails.tsx @@ -1,6 +1,5 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; -import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles"; import TextField from "@material-ui/core/TextField"; import { RawDraftContentState } from "draft-js"; import React from "react"; @@ -14,13 +13,7 @@ import { maybe } from "@saleor/misc"; import { FormErrors } from "@saleor/types"; import { CollectionDetails_collection } from "../../types/CollectionDetails"; -const styles = createStyles({ - name: { - width: "100%" - } -}); - -export interface CollectionDetailsProps extends WithStyles { +export interface CollectionDetailsProps { collection?: CollectionDetails_collection; data: { description: RawDraftContentState; @@ -31,50 +24,47 @@ export interface CollectionDetailsProps extends WithStyles { onChange: (event: React.ChangeEvent) => void; } -const CollectionDetails = withStyles(styles, { name: "CollectionDetails" })( - ({ - classes, - collection, - disabled, - data, - onChange, - errors - }: CollectionDetailsProps) => { - const intl = useIntl(); +const CollectionDetails = ({ + classes, + collection, + disabled, + data, + onChange, + errors +}: CollectionDetailsProps) => { + const intl = useIntl(); - return ( - - + + + - - - - JSON.parse(collection.descriptionJson))} - label={intl.formatMessage(commonMessages.description)} - name="description" - disabled={disabled} - onChange={onChange} - /> - - - ); - } -); -CollectionDetails.displayName = "CollectionDetails"; + + JSON.parse(collection.descriptionJson))} + label={intl.formatMessage(commonMessages.description)} + name="description" + disabled={disabled} + onChange={onChange} + /> + + + ); +}; export default CollectionDetails; diff --git a/src/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx b/src/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx index 079d5c261..bd56fe160 100644 --- a/src/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx +++ b/src/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx @@ -127,7 +127,7 @@ const CollectionDetailsPage: React.StatelessComponent< onChange={change} > span": { - "& > span": { - display: "block", - fontSize: "12px" - }, padding: "6px" } + }, + secondLabel: { + display: "block", + fontSize: "12px" } }); @@ -77,22 +77,22 @@ export const RadioGroupField = withStyles(styles, { onChange={onChange} > {choices.length > 0 ? ( - choices.map(choice => { - return ( - } - label={ - <> - {choice.label} - {choice.secondLabel} - - } - key={choice.value} - /> - ); - }) + choices.map(choice => ( + } + label={ + <> + {choice.label} + + {choice.secondLabel} + + + } + key={choice.value} + /> + )) ) : ( diff --git a/src/components/VisibilityCard/VisibilityCard.tsx b/src/components/VisibilityCard/VisibilityCard.tsx index 594330299..58c324587 100644 --- a/src/components/VisibilityCard/VisibilityCard.tsx +++ b/src/components/VisibilityCard/VisibilityCard.tsx @@ -37,12 +37,6 @@ const styles = (theme: Theme) => fontSize: "14px", paddingTop: "15px", textDecoration: "underline" - }, - switchContainer: { - "& > div": { - padding: 0 - }, - marginBottom: -theme.spacing.unit } }); @@ -154,8 +148,10 @@ export const VisibilityCard = withStyles(styles, { className={classes.setPublicationDate} onClick={() => setPublicationDate(!isPublicationDate)} > - {" "} - Set publication date + {intl.formatMessage({ + defaultMessage: "Set publication date", + description: "set publication date" + })} )} {isPublicationDate && ( diff --git a/src/icons/Attributes.tsx b/src/icons/Attributes.tsx index d658e1980..ff3b99560 100644 --- a/src/icons/Attributes.tsx +++ b/src/icons/Attributes.tsx @@ -4,8 +4,8 @@ import React from "react"; export const Attributes = createSvgIcon( <> diff --git a/src/pages/views/PageCreate.tsx b/src/pages/views/PageCreate.tsx index 44cd84e63..a30c6051d 100644 --- a/src/pages/views/PageCreate.tsx +++ b/src/pages/views/PageCreate.tsx @@ -54,7 +54,7 @@ export const PageCreate: React.StatelessComponent = () => { page={null} onBack={() => navigate(pageListUrl())} onRemove={() => undefined} - onSubmit={formData => { + onSubmit={formData => pageCreate({ variables: { input: { @@ -77,8 +77,8 @@ export const PageCreate: React.StatelessComponent = () => { title: formData.title } } - }); - }} + }) + } /> ); diff --git a/src/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx b/src/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx index 36eb1bd3a..a88c995f6 100644 --- a/src/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx +++ b/src/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx @@ -36,7 +36,7 @@ const ProductTypeListPage: React.StatelessComponent< {" "} + /> diff --git a/src/products/components/ProductDetailsForm/ProductDetailsForm.tsx b/src/products/components/ProductDetailsForm/ProductDetailsForm.tsx index 54e6e2018..55960504b 100644 --- a/src/products/components/ProductDetailsForm/ProductDetailsForm.tsx +++ b/src/products/components/ProductDetailsForm/ProductDetailsForm.tsx @@ -25,7 +25,7 @@ const styles = (theme: Theme) => } }); -interface ProductDetailsFormProps extends WithStyles { +interface ProductDetailsFormProps { data: { description: RawDraftContentState; name: string; @@ -39,54 +39,47 @@ interface ProductDetailsFormProps extends WithStyles { onChange(event: any); } -export const ProductDetailsForm = withStyles(styles, { - name: "ProductDetailsForm" -})( - ({ - classes, - data, - disabled, - errors, - initialDescription, - onChange - }: ProductDetailsFormProps) => { - const intl = useIntl(); +export const ProductDetailsForm = ({ + classes, + data, + disabled, + errors, + initialDescription, + onChange +}: ProductDetailsFormProps) => { + const intl = useIntl(); - return ( - - + + + - -
- -
- - -
-
- ); - } -); -ProductDetailsForm.displayName = "ProductDetailsForm"; + + + + + ); +}; export default ProductDetailsForm; diff --git a/src/translations/components/TranslationsLanguageListPage/TranslationsLanguageListPage.tsx b/src/translations/components/TranslationsLanguageListPage/TranslationsLanguageListPage.tsx index e08fc875e..678cf5ca7 100644 --- a/src/translations/components/TranslationsLanguageListPage/TranslationsLanguageListPage.tsx +++ b/src/translations/components/TranslationsLanguageListPage/TranslationsLanguageListPage.tsx @@ -1,5 +1,3 @@ -// import Button from "@material-ui/core/Button"; -// import React from "react"; import { useIntl } from "react-intl";