Fix types and small isssues
This commit is contained in:
parent
4cc48250b2
commit
aaede4b586
4 changed files with 36 additions and 71 deletions
|
@ -23,14 +23,13 @@ interface CategoryDetailsFormProps {
|
||||||
onChange: (event: React.ChangeEvent<any>) => void;
|
onChange: (event: React.ChangeEvent<any>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CategoryDetailsForm = ({
|
export const CategoryDetailsForm: React.FC<CategoryDetailsFormProps> = ({
|
||||||
category,
|
category,
|
||||||
classes,
|
|
||||||
disabled,
|
disabled,
|
||||||
data,
|
data,
|
||||||
onChange,
|
onChange,
|
||||||
errors
|
errors
|
||||||
}: CategoryDetailsFormProps) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -39,34 +38,32 @@ export const CategoryDetailsForm = ({
|
||||||
title={intl.formatMessage(commonMessages.generalInformations)}
|
title={intl.formatMessage(commonMessages.generalInformations)}
|
||||||
/>
|
/>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<>
|
<div>
|
||||||
<div>
|
<TextField
|
||||||
<TextField
|
|
||||||
label={intl.formatMessage({
|
|
||||||
defaultMessage: "Category Name"
|
|
||||||
})}
|
|
||||||
name="name"
|
|
||||||
disabled={disabled}
|
|
||||||
value={data && data.name}
|
|
||||||
onChange={onChange}
|
|
||||||
error={!!errors.name}
|
|
||||||
helperText={errors.name}
|
|
||||||
fullWidth
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<FormSpacer />
|
|
||||||
<RichTextEditor
|
|
||||||
disabled={disabled}
|
|
||||||
error={!!errors.descriptionJson}
|
|
||||||
helperText={errors.descriptionJson}
|
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
defaultMessage: "Category Description"
|
defaultMessage: "Category Name"
|
||||||
})}
|
})}
|
||||||
initial={maybe(() => JSON.parse(category.descriptionJson))}
|
name="name"
|
||||||
name="description"
|
disabled={disabled}
|
||||||
|
value={data && data.name}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
error={!!errors.name}
|
||||||
|
helperText={errors.name}
|
||||||
|
fullWidth
|
||||||
/>
|
/>
|
||||||
</>
|
</div>
|
||||||
|
<FormSpacer />
|
||||||
|
<RichTextEditor
|
||||||
|
disabled={disabled}
|
||||||
|
error={!!errors.descriptionJson}
|
||||||
|
helperText={errors.descriptionJson}
|
||||||
|
label={intl.formatMessage({
|
||||||
|
defaultMessage: "Category Description"
|
||||||
|
})}
|
||||||
|
initial={maybe(() => JSON.parse(category.descriptionJson))}
|
||||||
|
name="description"
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|
|
@ -24,14 +24,13 @@ export interface CollectionDetailsProps {
|
||||||
onChange: (event: React.ChangeEvent<any>) => void;
|
onChange: (event: React.ChangeEvent<any>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CollectionDetails = ({
|
const CollectionDetails: React.FC<CollectionDetailsProps> = ({
|
||||||
classes,
|
|
||||||
collection,
|
collection,
|
||||||
disabled,
|
disabled,
|
||||||
data,
|
data,
|
||||||
onChange,
|
onChange,
|
||||||
errors
|
errors
|
||||||
}: CollectionDetailsProps) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -25,12 +25,6 @@ const styles = (theme: Theme) =>
|
||||||
},
|
},
|
||||||
marginTop: theme.spacing.unit * 3
|
marginTop: theme.spacing.unit * 3
|
||||||
},
|
},
|
||||||
expandedSwitchContainer: {
|
|
||||||
"& > div": {
|
|
||||||
padding: 0
|
|
||||||
},
|
|
||||||
marginBottom: 0
|
|
||||||
},
|
|
||||||
setPublicationDate: {
|
setPublicationDate: {
|
||||||
color: theme.palette.primary.main,
|
color: theme.palette.primary.main,
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
|
@ -126,21 +120,13 @@ export const VisibilityCard = withStyles(styles, {
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div
|
<RadioGroupField
|
||||||
className={
|
choices={visiblilityPickerChoices}
|
||||||
isPublished
|
disabled={disabled}
|
||||||
? classes.expandedSwitchContainer
|
name={"isPublished" as keyof FormData}
|
||||||
: classes.switchContainer
|
value={isPublishedRadio}
|
||||||
}
|
onChange={onChange}
|
||||||
>
|
/>
|
||||||
<RadioGroupField
|
|
||||||
choices={visiblilityPickerChoices}
|
|
||||||
disabled={disabled}
|
|
||||||
name={"isPublished" as keyof FormData}
|
|
||||||
value={isPublishedRadio}
|
|
||||||
onChange={onChange}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{isPublishedRadio === "false" && (
|
{isPublishedRadio === "false" && (
|
||||||
<>
|
<>
|
||||||
{!isPublicationDate && (
|
{!isPublicationDate && (
|
||||||
|
@ -149,8 +135,7 @@ export const VisibilityCard = withStyles(styles, {
|
||||||
onClick={() => setPublicationDate(!isPublicationDate)}
|
onClick={() => setPublicationDate(!isPublicationDate)}
|
||||||
>
|
>
|
||||||
{intl.formatMessage({
|
{intl.formatMessage({
|
||||||
defaultMessage: "Set publication date",
|
defaultMessage: "Set publication date"
|
||||||
description: "set publication date"
|
|
||||||
})}
|
})}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
import Card from "@material-ui/core/Card";
|
import Card from "@material-ui/core/Card";
|
||||||
import CardContent from "@material-ui/core/CardContent";
|
import CardContent from "@material-ui/core/CardContent";
|
||||||
import {
|
|
||||||
createStyles,
|
|
||||||
Theme,
|
|
||||||
withStyles,
|
|
||||||
WithStyles
|
|
||||||
} from "@material-ui/core/styles";
|
|
||||||
import TextField from "@material-ui/core/TextField";
|
import TextField from "@material-ui/core/TextField";
|
||||||
import { RawDraftContentState } from "draft-js";
|
import { RawDraftContentState } from "draft-js";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
@ -16,15 +10,6 @@ import FormSpacer from "@saleor/components/FormSpacer";
|
||||||
import RichTextEditor from "@saleor/components/RichTextEditor";
|
import RichTextEditor from "@saleor/components/RichTextEditor";
|
||||||
import { commonMessages } from "@saleor/intl";
|
import { commonMessages } from "@saleor/intl";
|
||||||
|
|
||||||
const styles = (theme: Theme) =>
|
|
||||||
createStyles({
|
|
||||||
root: {
|
|
||||||
display: "grid",
|
|
||||||
gridColumnGap: theme.spacing.unit * 2 + "px",
|
|
||||||
gridTemplateColumns: `1fr`
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
interface ProductDetailsFormProps {
|
interface ProductDetailsFormProps {
|
||||||
data: {
|
data: {
|
||||||
description: RawDraftContentState;
|
description: RawDraftContentState;
|
||||||
|
@ -39,14 +24,13 @@ interface ProductDetailsFormProps {
|
||||||
onChange(event: any);
|
onChange(event: any);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProductDetailsForm = ({
|
export const ProductDetailsForm: React.FC<ProductDetailsFormProps> = ({
|
||||||
classes,
|
|
||||||
data,
|
data,
|
||||||
disabled,
|
disabled,
|
||||||
errors,
|
errors,
|
||||||
initialDescription,
|
initialDescription,
|
||||||
onChange
|
onChange
|
||||||
}: ProductDetailsFormProps) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue