import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import makeStyles from "@material-ui/core/styles/makeStyles"; import TextField from "@material-ui/core/TextField"; import CardSpacer from "@saleor/components/CardSpacer"; import CardTitle from "@saleor/components/CardTitle"; import { ShippingErrorFragment } from "@saleor/fragments/types/ShippingErrorFragment"; import { commonMessages } from "@saleor/intl"; import { getFormErrors } from "@saleor/utils/errors"; import getShippingErrorMessage from "@saleor/utils/errors/shipping"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; export interface ShippingZoneInfoProps { data: Record<"name" | "description", string>; disabled: boolean; errors: ShippingErrorFragment[]; onChange: (event: React.ChangeEvent) => void; } const useStyles = makeStyles( { label: { flex: 1 }, labelContainer: { "& span": { paddingRight: 30 }, display: "flex" } }, { name: "ShippingZoneCreatePage" } ); const MAX_DESCRIPTION_LENGTH = 300; const ShippingZoneInfo: React.FC = ({ data, disabled, errors, onChange }) => { const intl = useIntl(); const classes = useStyles({}); const formErrors = getFormErrors(["name"], errors); return ( MAX_DESCRIPTION_LENGTH} name={"description"} label={
{data.description?.length > 0 && ( )}
} InputProps={{ inputProps: { maxLength: MAX_DESCRIPTION_LENGTH } }} value={data.description} onChange={onChange} disabled={disabled} fullWidth multiline placeholder={intl.formatMessage({ defaultMessage: "Description of a shipping zone.", description: "field placeholder" })} rows={10} />
); }; ShippingZoneInfo.displayName = "ShippingZoneInfo"; export default ShippingZoneInfo;