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 { makeStyles } from "@material-ui/core/styles"; 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 React from "react"; import { FormattedMessage, useIntl } from "react-intl"; import { maybe, transformPaymentStatus } from "../../../misc"; import { OrderAction, OrderStatus } from "../../../types/globalTypes"; import { OrderDetails_order } from "../../types/OrderDetails"; const useStyles = makeStyles( theme => ({ root: { ...theme.typography.body1, lineHeight: 1.9, width: "100%" }, textRight: { textAlign: "right" }, totalRow: { fontWeight: 600 } }), { name: "OrderPayment" } ); interface OrderPaymentProps { order: OrderDetails_order; onCapture: () => void; onMarkAsPaid: () => void; onRefund: () => void; onVoid: () => void; } const OrderPayment: React.FC = props => { const { order, onCapture, onMarkAsPaid, onRefund, onVoid } = props; const classes = useStyles(props); const intl = useIntl(); 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), intl ); return ( order.paymentStatus) === undefined ? ( ) : ( ) } /> {order?.discount?.amount > 0 && ( )}
{maybe(() => order.lines) === undefined ? ( ) : ( line.quantity) .reduce((curr, prev) => prev + curr, 0) }} /> )} {maybe(() => order.subtotal.gross) === undefined ? ( ) : ( )}
{maybe(() => order.total.tax) === undefined ? ( ) : order.total.tax.amount > 0 ? ( intl.formatMessage({ defaultMessage: "VAT included", description: "vat included in order price" }) ) : ( intl.formatMessage({ defaultMessage: "does not apply", description: "vat not included in order price", id: "orderPaymentVATDoesNotApply" }) )} {maybe(() => order.total.tax) === undefined ? ( ) : ( )}
{maybe(() => order.shippingMethodName) === undefined && maybe(() => order.shippingPrice) === undefined ? ( ) : order.shippingMethodName === null ? ( intl.formatMessage({ defaultMessage: "does not apply", description: "order does not require shipping", id: "orderPaymentShippingDoesNotApply" }) ) : ( order.shippingMethodName )} {maybe(() => order.shippingPrice.gross) === undefined ? ( ) : ( )}
-
{maybe(() => order.total.gross) === undefined ? ( ) : ( )}

{maybe(() => order.totalAuthorized.amount) === undefined ? ( ) : ( )}
{maybe(() => order.totalCaptured.amount) === undefined ? ( ) : ( )}
{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;