2019-10-30 14:34:24 +00:00
|
|
|
import { makeStyles } from "@material-ui/core/styles";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-08-26 17:44:42 +00:00
|
|
|
import { FormattedMessage } from "react-intl";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
import Link from "@saleor/components/Link";
|
|
|
|
import Money from "@saleor/components/Money";
|
|
|
|
import Skeleton from "@saleor/components/Skeleton";
|
|
|
|
import { maybe } from "../../../misc";
|
|
|
|
import { OrderDetails_order } from "../../types/OrderDetails";
|
|
|
|
|
2019-12-03 15:28:40 +00:00
|
|
|
const useStyles = makeStyles(
|
|
|
|
theme => ({
|
|
|
|
root: {
|
|
|
|
...theme.typography.body1,
|
|
|
|
lineHeight: 1.9,
|
|
|
|
width: "100%"
|
|
|
|
},
|
|
|
|
textRight: {
|
|
|
|
textAlign: "right"
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
{ name: "OrderDraftDetailsSummary" }
|
|
|
|
);
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
interface OrderDraftDetailsSummaryProps {
|
2019-06-19 14:40:52 +00:00
|
|
|
order: OrderDetails_order;
|
|
|
|
onShippingMethodEdit: () => void;
|
|
|
|
}
|
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const OrderDraftDetailsSummary: React.FC<
|
|
|
|
OrderDraftDetailsSummaryProps
|
|
|
|
> = props => {
|
|
|
|
const { order, onShippingMethodEdit } = props;
|
|
|
|
|
|
|
|
const classes = useStyles(props);
|
|
|
|
|
|
|
|
return (
|
2019-06-19 14:40:52 +00:00
|
|
|
<table className={classes.root}>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
{maybe(() => order.subtotal) ? (
|
|
|
|
<>
|
2019-08-26 17:44:42 +00:00
|
|
|
<td>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Subtotal"
|
|
|
|
description="subtotal price or an order"
|
|
|
|
/>
|
|
|
|
</td>
|
2019-06-19 14:40:52 +00:00
|
|
|
<td className={classes.textRight}>
|
|
|
|
<Money money={order.subtotal.gross} />
|
|
|
|
</td>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<td colSpan={2}>
|
|
|
|
<Skeleton />
|
|
|
|
</td>
|
|
|
|
)}
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
{order &&
|
|
|
|
order.shippingMethod !== undefined &&
|
|
|
|
order.shippingMethodName !== undefined ? (
|
|
|
|
order.shippingMethod === null ? (
|
|
|
|
order.availableShippingMethods &&
|
|
|
|
order.availableShippingMethods.length > 0 ? (
|
|
|
|
<td>
|
|
|
|
<Link onClick={onShippingMethodEdit}>
|
2019-08-26 17:44:42 +00:00
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Add shipping carrier"
|
|
|
|
description="button"
|
|
|
|
/>
|
2019-06-19 14:40:52 +00:00
|
|
|
</Link>
|
|
|
|
</td>
|
|
|
|
) : (
|
2019-08-26 17:44:42 +00:00
|
|
|
<td>
|
|
|
|
<FormattedMessage defaultMessage="No applicable shipping carriers" />
|
|
|
|
</td>
|
2019-06-19 14:40:52 +00:00
|
|
|
)
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<td>
|
|
|
|
<Link onClick={onShippingMethodEdit}>
|
|
|
|
{order.shippingMethodName}
|
|
|
|
</Link>
|
|
|
|
</td>
|
|
|
|
<td className={classes.textRight}>
|
|
|
|
{maybe(() => order.shippingPrice) ? (
|
|
|
|
<Money money={order.shippingPrice.gross} />
|
|
|
|
) : (
|
|
|
|
"---"
|
|
|
|
)}
|
|
|
|
</td>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
) : (
|
|
|
|
<td colSpan={2}>
|
|
|
|
<Skeleton />
|
|
|
|
</td>
|
|
|
|
)}
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
{maybe(() => order.total.tax) !== undefined ? (
|
|
|
|
<>
|
2019-08-26 17:44:42 +00:00
|
|
|
<td>
|
|
|
|
<FormattedMessage defaultMessage="Taxes (VAT included)" />
|
|
|
|
</td>
|
2019-06-19 14:40:52 +00:00
|
|
|
<td className={classes.textRight}>
|
|
|
|
<Money money={order.total.tax} />
|
|
|
|
</td>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<td colSpan={2}>
|
|
|
|
<Skeleton />
|
|
|
|
</td>
|
|
|
|
)}
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
{maybe(() => order.total.gross) !== undefined ? (
|
|
|
|
<>
|
2019-08-26 17:44:42 +00:00
|
|
|
<td>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Total"
|
|
|
|
description="total price of an order"
|
|
|
|
/>
|
|
|
|
</td>
|
2019-06-19 14:40:52 +00:00
|
|
|
<td className={classes.textRight}>
|
|
|
|
<Money money={order.total.gross} />
|
|
|
|
</td>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<td colSpan={2}>
|
|
|
|
<Skeleton />
|
|
|
|
</td>
|
|
|
|
)}
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2019-10-30 14:34:24 +00:00
|
|
|
);
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
OrderDraftDetailsSummary.displayName = "OrderDraftDetailsSummary";
|
|
|
|
export default OrderDraftDetailsSummary;
|