2021-05-14 08:15:15 +00:00
|
|
|
import { Card, CardContent, TextField } from "@material-ui/core";
|
2019-09-26 15:33:44 +00:00
|
|
|
import CardTitle from "@saleor/components/CardTitle";
|
2020-11-23 13:04:24 +00:00
|
|
|
import { AppErrorFragment } from "@saleor/fragments/types/AppErrorFragment";
|
2020-05-14 09:30:32 +00:00
|
|
|
import { FormChange } from "@saleor/hooks/useForm";
|
2020-03-11 09:55:14 +00:00
|
|
|
import { getFormErrors } from "@saleor/utils/errors";
|
2020-07-22 10:54:15 +00:00
|
|
|
import getAppErrorMessage from "@saleor/utils/errors/app";
|
2020-05-14 09:30:32 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useIntl } from "react-intl";
|
2019-09-26 15:33:44 +00:00
|
|
|
|
2020-07-22 10:54:15 +00:00
|
|
|
export interface CustomAppInfoProps {
|
2019-09-26 15:33:44 +00:00
|
|
|
data: {
|
|
|
|
name: string;
|
|
|
|
};
|
|
|
|
disabled: boolean;
|
2020-07-22 10:54:15 +00:00
|
|
|
errors: AppErrorFragment[];
|
2019-09-26 15:33:44 +00:00
|
|
|
onChange: FormChange;
|
|
|
|
}
|
|
|
|
|
2020-07-22 10:54:15 +00:00
|
|
|
const CustomAppInformation: React.FC<CustomAppInfoProps> = ({
|
2020-03-11 09:55:14 +00:00
|
|
|
data,
|
|
|
|
disabled,
|
|
|
|
errors,
|
|
|
|
onChange
|
|
|
|
}) => {
|
2019-09-26 15:33:44 +00:00
|
|
|
const intl = useIntl();
|
|
|
|
|
2020-03-11 09:55:14 +00:00
|
|
|
const formErrors = getFormErrors(["name"], errors);
|
|
|
|
|
2019-09-26 15:33:44 +00:00
|
|
|
return (
|
|
|
|
<Card>
|
|
|
|
<CardTitle
|
|
|
|
title={intl.formatMessage({
|
2020-07-22 10:54:15 +00:00
|
|
|
defaultMessage: "App Information",
|
2019-09-26 15:33:44 +00:00
|
|
|
description: "header"
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
<CardContent>
|
|
|
|
<TextField
|
|
|
|
disabled={disabled}
|
2020-03-11 09:55:14 +00:00
|
|
|
error={!!formErrors.name}
|
2019-09-26 15:33:44 +00:00
|
|
|
label={intl.formatMessage({
|
2020-07-22 10:54:15 +00:00
|
|
|
defaultMessage: "App Name",
|
|
|
|
description: "custom app name"
|
2019-09-26 15:33:44 +00:00
|
|
|
})}
|
2020-07-22 10:54:15 +00:00
|
|
|
helperText={getAppErrorMessage(formErrors.name, intl)}
|
2019-09-26 15:33:44 +00:00
|
|
|
fullWidth
|
|
|
|
name="name"
|
|
|
|
value={data.name}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-07-22 10:54:15 +00:00
|
|
|
CustomAppInformation.displayName = "CustomAppInformation";
|
|
|
|
export default CustomAppInformation;
|