import Button from "@material-ui/core/Button"; import Card from "@material-ui/core/Card"; import CardActions from "@material-ui/core/CardActions"; import CardContent from "@material-ui/core/CardContent"; import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles"; import Typography from "@material-ui/core/Typography"; import * as React from "react"; import AddressFormatter from "@saleor/components/AddressFormatter"; import CardMenu from "@saleor/components/CardMenu"; import CardTitle from "@saleor/components/CardTitle"; import Skeleton from "@saleor/components/Skeleton"; import i18n from "../../../i18n"; import { AddressTypeEnum } from "../../../types/globalTypes"; import { CustomerAddresses_user_addresses } from "../../types/CustomerAddresses"; export interface CustomerAddressProps { address: CustomerAddresses_user_addresses; disabled: boolean; isDefaultBillingAddress: boolean; isDefaultShippingAddress: boolean; addressNumber: number; onEdit: () => void; onRemove: () => void; onSetAsDefault: (type: AddressTypeEnum) => void; } const styles = createStyles({ actions: { flexDirection: "row" }, actionsContainer: { display: "flex", flexDirection: "column", height: "100%", justifyContent: "flex-end" }, card: { display: "flex", flexDirection: "column" } }); const CustomerAddress = withStyles(styles, { name: "CustomerAddress" })( ({ address, addressNumber, classes, disabled, isDefaultBillingAddress, isDefaultShippingAddress, onEdit, onRemove, onSetAsDefault }: CustomerAddressProps & WithStyles) => ( {i18n.t("Address {{ addressNumber }}", { addressNumber })} {isDefaultBillingAddress && isDefaultShippingAddress ? i18n.t("Default Address") : isDefaultShippingAddress ? i18n.t("Default Shipping Address") : isDefaultBillingAddress ? i18n.t("Default Billing Address") : null} ) : ( ) } height="const" toolbar={ onSetAsDefault(AddressTypeEnum.SHIPPING) }, { label: i18n.t("Set as default billing address", { context: "button" }), onSelect: () => onSetAsDefault(AddressTypeEnum.BILLING) } ]} /> } />
) ); CustomerAddress.displayName = "CustomerAddress"; export default CustomerAddress;