2019-06-19 14:40:52 +00:00
|
|
|
import Card from "@material-ui/core/Card";
|
|
|
|
import CardContent from "@material-ui/core/CardContent";
|
2019-10-30 14:34:24 +00:00
|
|
|
import { makeStyles } from "@material-ui/core/styles";
|
2019-06-19 14:40:52 +00:00
|
|
|
import TextField from "@material-ui/core/TextField";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-08-27 09:35:54 +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-26 17:48:13 +00:00
|
|
|
import { commonMessages } from "@saleor/intl";
|
2019-06-19 14:40:52 +00:00
|
|
|
import { maybe } from "../../../misc";
|
|
|
|
import { FormErrors } from "../../../types";
|
|
|
|
import { PageDetails_page } from "../../types/PageDetails";
|
|
|
|
import { FormData } from "../PageDetailsPage";
|
|
|
|
|
|
|
|
export interface PageInfoProps {
|
|
|
|
data: FormData;
|
|
|
|
disabled: boolean;
|
|
|
|
errors: FormErrors<"contentJson" | "title">;
|
|
|
|
page: PageDetails_page;
|
|
|
|
onChange: (event: React.ChangeEvent<any>) => void;
|
|
|
|
}
|
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const useStyles = makeStyles({
|
2019-06-19 14:40:52 +00:00
|
|
|
root: {
|
|
|
|
overflow: "visible"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const PageInfo: React.FC<PageInfoProps> = props => {
|
|
|
|
const { data, disabled, errors, page, onChange } = props;
|
|
|
|
const classes = useStyles(props);
|
2019-08-26 17:48:13 +00:00
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Card className={classes.root}>
|
|
|
|
<CardTitle
|
|
|
|
title={intl.formatMessage(commonMessages.generalInformations)}
|
|
|
|
/>
|
|
|
|
<CardContent>
|
|
|
|
<TextField
|
|
|
|
disabled={disabled}
|
|
|
|
error={!!errors.title}
|
|
|
|
fullWidth
|
|
|
|
helperText={errors.title}
|
|
|
|
label={intl.formatMessage({
|
|
|
|
defaultMessage: "Title",
|
|
|
|
description: "page title"
|
|
|
|
})}
|
|
|
|
name={"title" as keyof FormData}
|
|
|
|
value={data.title}
|
|
|
|
onChange={onChange}
|
2019-06-19 14:40:52 +00:00
|
|
|
/>
|
2019-10-30 14:34:24 +00:00
|
|
|
<FormSpacer />
|
|
|
|
<RichTextEditor
|
|
|
|
disabled={disabled}
|
|
|
|
error={!!errors.contentJson}
|
|
|
|
helperText={errors.contentJson}
|
|
|
|
initial={maybe(() => JSON.parse(page.contentJson))}
|
|
|
|
label={intl.formatMessage({
|
|
|
|
defaultMessage: "Content",
|
|
|
|
description: "page content"
|
|
|
|
})}
|
|
|
|
name={"content" as keyof FormData}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
PageInfo.displayName = "PageInfo";
|
|
|
|
export default PageInfo;
|