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 Typography from "@material-ui/core/Typography";
|
|
|
|
import AddressEdit from "@saleor/components/AddressEdit";
|
|
|
|
import CardTitle from "@saleor/components/CardTitle";
|
|
|
|
import { FormSpacer } from "@saleor/components/FormSpacer";
|
2019-08-09 11:14:35 +00:00
|
|
|
import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField";
|
2020-03-11 09:55:14 +00:00
|
|
|
import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment";
|
2020-05-14 09:30:32 +00:00
|
|
|
import React from "react";
|
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
|
|
|
2019-06-19 14:40:52 +00:00
|
|
|
import { AddressTypeInput } from "../../types";
|
|
|
|
|
2019-12-03 15:28:40 +00:00
|
|
|
const useStyles = makeStyles(
|
|
|
|
{
|
|
|
|
overflow: {
|
|
|
|
overflow: "visible"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ name: "CustomerCreateAddress" }
|
|
|
|
);
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
export interface CustomerCreateAddressProps {
|
2019-08-09 11:14:35 +00:00
|
|
|
countries: SingleAutocompleteChoiceType[];
|
|
|
|
countryDisplayName: string;
|
2019-06-19 14:40:52 +00:00
|
|
|
data: AddressTypeInput;
|
|
|
|
disabled: boolean;
|
2020-03-11 09:55:14 +00:00
|
|
|
errors: AccountErrorFragment[];
|
2019-06-19 14:40:52 +00:00
|
|
|
onChange(event: React.ChangeEvent<any>);
|
2019-08-09 11:14:35 +00:00
|
|
|
onCountryChange(event: React.ChangeEvent<any>);
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const CustomerCreateAddress: React.FC<CustomerCreateAddressProps> = props => {
|
|
|
|
const {
|
2019-06-19 14:40:52 +00:00
|
|
|
countries,
|
2019-08-09 11:14:35 +00:00
|
|
|
countryDisplayName,
|
2019-06-19 14:40:52 +00:00
|
|
|
data,
|
|
|
|
disabled,
|
|
|
|
errors,
|
2019-08-09 11:14:35 +00:00
|
|
|
onChange,
|
|
|
|
onCountryChange
|
2019-10-30 14:34:24 +00:00
|
|
|
} = props;
|
|
|
|
const classes = useStyles(props);
|
2019-08-23 12:23:59 +00:00
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Card className={classes.overflow}>
|
|
|
|
<CardTitle
|
|
|
|
title={intl.formatMessage({
|
|
|
|
defaultMessage: "Primary Address",
|
|
|
|
description: "page header"
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
<CardContent className={classes.overflow}>
|
|
|
|
<Typography>
|
|
|
|
<FormattedMessage defaultMessage="The primary address of this customer." />
|
|
|
|
</Typography>
|
|
|
|
<FormSpacer />
|
|
|
|
<AddressEdit
|
|
|
|
countries={countries}
|
|
|
|
data={data}
|
|
|
|
disabled={disabled}
|
|
|
|
countryDisplayValue={countryDisplayName}
|
|
|
|
errors={errors}
|
|
|
|
onChange={onChange}
|
|
|
|
onCountryChange={onCountryChange}
|
2019-06-19 14:40:52 +00:00
|
|
|
/>
|
2019-10-30 14:34:24 +00:00
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
CustomerCreateAddress.displayName = "CustomerCreateAddress";
|
|
|
|
export default CustomerCreateAddress;
|