2019-06-19 14:40:52 +00:00
|
|
|
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 { AddressType } from "../../customers/types";
|
|
|
|
import Skeleton from "../Skeleton";
|
|
|
|
|
|
|
|
interface AddressFormatterProps {
|
|
|
|
address?: AddressType;
|
|
|
|
}
|
|
|
|
|
2019-11-07 11:34:54 +00:00
|
|
|
const AddressFormatter: React.FC<AddressFormatterProps> = ({ address }) => {
|
2019-06-19 14:40:52 +00:00
|
|
|
if (!address) {
|
|
|
|
return <Skeleton />;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<address
|
|
|
|
style={{
|
|
|
|
fontStyle: "inherit"
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Typography component="span">
|
|
|
|
{address.firstName} {address.lastName}
|
|
|
|
</Typography>
|
|
|
|
{address.companyName && (
|
|
|
|
<Typography component="span">{address.companyName}</Typography>
|
|
|
|
)}
|
|
|
|
<Typography component="span">
|
|
|
|
{address.streetAddress1}
|
|
|
|
<br />
|
|
|
|
{address.streetAddress2}
|
|
|
|
</Typography>
|
|
|
|
<Typography component="span">
|
|
|
|
{" "}
|
|
|
|
{address.postalCode} {address.city}
|
|
|
|
{address.cityArea ? ", " + address.cityArea : ""}
|
|
|
|
</Typography>
|
|
|
|
<Typography component="span">
|
|
|
|
{address.countryArea
|
|
|
|
? address.countryArea + ", " + address.country.country
|
|
|
|
: address.country.country}
|
|
|
|
</Typography>
|
|
|
|
</address>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
AddressFormatter.displayName = "AddressFormatter";
|
|
|
|
export default AddressFormatter;
|