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, Theme, withStyles, WithStyles } from "@material-ui/core/styles"; import * as React from "react"; import CardTitle from "@saleor/components/CardTitle"; import { Hr } from "@saleor/components/Hr"; import Money, { subtractMoney } from "@saleor/components/Money"; import Skeleton from "@saleor/components/Skeleton"; import StatusLabel from "@saleor/components/StatusLabel"; import i18n from "../../../i18n"; import { maybe, transformPaymentStatus } from "../../../misc"; import { OrderAction, OrderStatus } from "../../../types/globalTypes"; import { OrderDetails_order } from "../../types/OrderDetails"; const styles = (theme: Theme) => createStyles({ root: { ...theme.typography.body2, lineHeight: 1.9, width: "100%" }, textRight: { textAlign: "right" }, totalRow: { fontWeight: 600 } }); interface OrderPaymentProps extends WithStyles { order: OrderDetails_order; onCapture: () => void; onMarkAsPaid: () => void; onRefund: () => void; onVoid: () => void; } const OrderPayment = withStyles(styles, { name: "OrderPayment" })( ({ classes, order, onCapture, onMarkAsPaid, onRefund, onVoid }: OrderPaymentProps) => { const canCapture = maybe(() => order.actions, []).includes( OrderAction.CAPTURE ); const canVoid = maybe(() => order.actions, []).includes(OrderAction.VOID); const canRefund = maybe(() => order.actions, []).includes( OrderAction.REFUND ); const canMarkAsPaid = maybe(() => order.actions, []).includes( OrderAction.MARK_AS_PAID ); const payment = transformPaymentStatus(maybe(() => order.paymentStatus)); return ( order.paymentStatus) === undefined ? ( ) : ( ) } />
{i18n.t("Subtotal")} {maybe(() => order.lines) === undefined ? ( ) : ( i18n.t("{{ quantity }} items", { quantity: order.lines .map(line => line.quantity) .reduce((curr, prev) => prev + curr, 0) }) )} {maybe(() => order.subtotal.gross) === undefined ? ( ) : ( )}
{i18n.t("Taxes")} {maybe(() => order.total.tax) === undefined ? ( ) : order.total.tax.amount > 0 ? ( i18n.t("VAT included") ) : ( i18n.t("does not apply") )} {maybe(() => order.total.tax) === undefined ? ( ) : ( )}
{i18n.t("Shipping")} {maybe(() => order.shippingMethodName) === undefined && maybe(() => order.shippingPrice) === undefined ? ( ) : order.shippingMethodName === null ? ( i18n.t("does not apply") ) : ( order.shippingMethodName )} {maybe(() => order.shippingPrice.gross) === undefined ? ( ) : ( )}
{i18n.t("Total")} {maybe(() => order.total.gross) === undefined ? ( ) : ( )}

{i18n.t("Preauthorized amount")} {maybe(() => order.totalAuthorized.amount) === undefined ? ( ) : ( )}
{i18n.t("Captured amount")} {maybe(() => order.totalCaptured.amount) === undefined ? ( ) : ( )}
{i18n.t("Outstanding Balance")} {maybe( () => order.total.gross.amount && order.totalCaptured.amount ) === undefined ? ( ) : ( )}
{maybe(() => order.status) !== OrderStatus.CANCELED && (canCapture || canRefund || canVoid || canMarkAsPaid) && ( <>
{canCapture && ( )} {canRefund && ( )} {canVoid && ( )} {canMarkAsPaid && ( )} )}
); } ); OrderPayment.displayName = "OrderPayment"; export default OrderPayment;