saleor-dashboard/src/customers/components/CustomerCreateAddress/CustomerCreateAddress.tsx

66 lines
2 KiB
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
import { createStyles, WithStyles, withStyles } from "@material-ui/core/styles";
import Typography from "@material-ui/core/Typography";
2019-08-09 10:26:22 +00:00
import React from "react";
2019-06-19 14:40:52 +00:00
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";
2019-06-19 14:40:52 +00:00
import i18n from "../../../i18n";
import { FormErrors } from "../../../types";
import { AddressTypeInput } from "../../types";
const styles = createStyles({
overflow: {
overflow: "visible"
}
});
export interface CustomerCreateAddressProps extends WithStyles<typeof styles> {
2019-08-09 11:14:35 +00:00
countries: SingleAutocompleteChoiceType[];
countryDisplayName: string;
2019-06-19 14:40:52 +00:00
data: AddressTypeInput;
disabled: boolean;
errors: FormErrors<keyof AddressTypeInput>;
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
}
const CustomerCreateAddress = withStyles(styles, {
name: "CustomerCreateAddress"
})(
({
classes,
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-06-19 14:40:52 +00:00
}: CustomerCreateAddressProps) => (
<Card className={classes.overflow}>
<CardTitle title={i18n.t("Primary address")} />
<CardContent className={classes.overflow}>
<Typography>
{i18n.t("The primary address of this customer.")}
</Typography>
<FormSpacer />
<AddressEdit
2019-08-09 11:14:35 +00:00
countries={countries}
2019-06-19 14:40:52 +00:00
data={data}
disabled={disabled}
2019-08-09 11:14:35 +00:00
countryDisplayValue={countryDisplayName}
2019-06-19 14:40:52 +00:00
errors={errors}
onChange={onChange}
2019-08-09 11:14:35 +00:00
onCountryChange={onCountryChange}
2019-06-19 14:40:52 +00:00
/>
</CardContent>
</Card>
)
);
CustomerCreateAddress.displayName = "CustomerCreateAddress";
export default CustomerCreateAddress;