2019-06-19 14:40:52 +00:00
|
|
|
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";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-08-21 12:31:55 +00:00
|
|
|
import { useIntl } from "react-intl";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
import CardTitle from "@saleor/components/CardTitle";
|
|
|
|
import FormSpacer from "@saleor/components/FormSpacer";
|
|
|
|
import RichTextEditor from "@saleor/components/RichTextEditor";
|
2019-08-21 12:31:55 +00:00
|
|
|
import { commonMessages } from "@saleor/intl";
|
|
|
|
import { maybe } from "@saleor/misc";
|
|
|
|
import { FormErrors } from "@saleor/types";
|
2019-06-19 14:40:52 +00:00
|
|
|
import { CollectionDetails_collection } from "../../types/CollectionDetails";
|
|
|
|
|
|
|
|
const styles = createStyles({
|
|
|
|
name: {
|
|
|
|
width: "80%"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export interface CollectionDetailsProps extends WithStyles<typeof styles> {
|
|
|
|
collection?: CollectionDetails_collection;
|
|
|
|
data: {
|
|
|
|
description: RawDraftContentState;
|
|
|
|
name: string;
|
|
|
|
};
|
|
|
|
disabled: boolean;
|
|
|
|
errors: FormErrors<"descriptionJson" | "name">;
|
|
|
|
onChange: (event: React.ChangeEvent<any>) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CollectionDetails = withStyles(styles, { name: "CollectionDetails" })(
|
|
|
|
({
|
|
|
|
classes,
|
|
|
|
collection,
|
|
|
|
disabled,
|
|
|
|
data,
|
|
|
|
onChange,
|
|
|
|
errors
|
2019-08-21 12:31:55 +00:00
|
|
|
}: CollectionDetailsProps) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Card>
|
|
|
|
<CardTitle
|
|
|
|
title={intl.formatMessage(commonMessages.generalInformations)}
|
2019-06-19 14:40:52 +00:00
|
|
|
/>
|
2019-08-21 12:31:55 +00:00
|
|
|
<CardContent>
|
|
|
|
<TextField
|
|
|
|
classes={{ root: classes.name }}
|
|
|
|
label={intl.formatMessage({
|
|
|
|
defaultMessage: "Name",
|
|
|
|
description: "collection name",
|
2019-08-22 16:19:16 +00:00
|
|
|
|
2019-08-21 12:31:55 +00:00
|
|
|
})}
|
|
|
|
name="name"
|
|
|
|
disabled={disabled}
|
|
|
|
value={data.name}
|
|
|
|
onChange={onChange}
|
|
|
|
error={!!errors.name}
|
|
|
|
helperText={errors.name}
|
|
|
|
/>
|
|
|
|
<FormSpacer />
|
|
|
|
<RichTextEditor
|
|
|
|
error={!!errors.descriptionJson}
|
|
|
|
helperText={errors.descriptionJson}
|
|
|
|
initial={maybe(() => JSON.parse(collection.descriptionJson))}
|
|
|
|
label={intl.formatMessage(commonMessages.description)}
|
|
|
|
name="description"
|
|
|
|
disabled={disabled}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
}
|
2019-06-19 14:40:52 +00:00
|
|
|
);
|
|
|
|
CollectionDetails.displayName = "CollectionDetails";
|
|
|
|
export default CollectionDetails;
|