2019-09-26 15:33:44 +00:00
|
|
|
import Card from "@material-ui/core/Card";
|
|
|
|
import CardContent from "@material-ui/core/CardContent";
|
|
|
|
import TextField from "@material-ui/core/TextField";
|
|
|
|
import CardTitle from "@saleor/components/CardTitle";
|
2020-07-07 10:14:12 +00:00
|
|
|
import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment";
|
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";
|
|
|
|
import getAccountErrorMessage from "@saleor/utils/errors/account";
|
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
|
|
|
|
|
|
|
export interface ServiceInfoProps {
|
|
|
|
data: {
|
|
|
|
name: string;
|
|
|
|
};
|
|
|
|
disabled: boolean;
|
2020-03-11 09:55:14 +00:00
|
|
|
errors: AccountErrorFragment[];
|
2019-09-26 15:33:44 +00:00
|
|
|
onChange: FormChange;
|
|
|
|
}
|
|
|
|
|
2020-03-11 09:55:14 +00:00
|
|
|
const ServiceInfo: React.FC<ServiceInfoProps> = ({
|
|
|
|
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({
|
|
|
|
defaultMessage: "Service Account Information",
|
|
|
|
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({
|
|
|
|
defaultMessage: "Account Name",
|
|
|
|
description: "service account"
|
|
|
|
})}
|
2020-03-11 09:55:14 +00:00
|
|
|
helperText={getAccountErrorMessage(formErrors.name, intl)}
|
2019-09-26 15:33:44 +00:00
|
|
|
fullWidth
|
|
|
|
name="name"
|
|
|
|
value={data.name}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
ServiceInfo.displayName = "ServiceInfo";
|
|
|
|
export default ServiceInfo;
|