Payment status card improvements (#2222)
* Change table layout to flexbox * Move taxes before total * Move discounts above subtotal * Add type to util function * Remove maybes * Improve discounts * Change taxes message * Make font smaller * Query total balance in order details * Use totalBalance from api * Show refunded when more than 0 * Make taxes grey * Delete unused import * Update fixtures * Update snapshots * Extract messages * Move styles to seperate file * Fix refunded amount * Add settled message for zero balances * Change payment status to payment balance * Update snapshots * Fix messages post rebase
This commit is contained in:
parent
24d77b984a
commit
c1185198f5
12 changed files with 1778 additions and 2370 deletions
|
@ -2481,7 +2481,7 @@
|
||||||
{
|
{
|
||||||
"kind": "ENUM",
|
"kind": "ENUM",
|
||||||
"name": "AllocationStrategyEnum",
|
"name": "AllocationStrategyEnum",
|
||||||
"description": "Determine the allocation strategy for the channel.\n\n PRIORITIZE_SORTING_ORDER - the allocation is prioritized by the warehouses' sort\n order within the channel\n\n PRIORITIZE_HIGH_STOCK - the allocation is prioritized by the highest available\n quantity in stocks\n ",
|
"description": "Determine the allocation strategy for the channel.\n\n PRIORITIZE_SORTING_ORDER - allocate stocks according to the warehouses' order\n within the channel\n\n PRIORITIZE_HIGH_STOCK - allocate stock in a warehouse with the most stock\n ",
|
||||||
"fields": null,
|
"fields": null,
|
||||||
"inputFields": null,
|
"inputFields": null,
|
||||||
"interfaces": null,
|
"interfaces": null,
|
||||||
|
@ -51802,7 +51802,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "moves",
|
"name": "moves",
|
||||||
"description": "The list of reordering operations for given channel warehouses.",
|
"description": "The list of reordering operations for the given channel warehouses.",
|
||||||
"type": {
|
"type": {
|
||||||
"kind": "NON_NULL",
|
"kind": "NON_NULL",
|
||||||
"name": null,
|
"name": null,
|
||||||
|
@ -67124,7 +67124,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "variants",
|
"name": "variants",
|
||||||
"description": "List of varint IDs which causes the error.",
|
"description": "List of variant IDs which causes the error.",
|
||||||
"args": [],
|
"args": [],
|
||||||
"type": {
|
"type": {
|
||||||
"kind": "LIST",
|
"kind": "LIST",
|
||||||
|
@ -93930,7 +93930,7 @@
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"name": "allocationStrategy",
|
"name": "allocationStrategy",
|
||||||
"description": "Allocation strategy options. Strategy defines the preference of warehouses for allocations and reservations.",
|
"description": "Allocation strategy defines the preference of warehouses for allocations and reservations.",
|
||||||
"args": [],
|
"args": [],
|
||||||
"type": {
|
"type": {
|
||||||
"kind": "NON_NULL",
|
"kind": "NON_NULL",
|
||||||
|
@ -102023,7 +102023,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shippingZones",
|
"name": "shippingZones",
|
||||||
"description": "Shipping zones supported by the warehouse.",
|
"description": "Shipping zones supported by the warehouse.\n\nDEPRECATED: this field will be removed in Saleor 4.0. Providing the zone ids will raise a ValidationError.",
|
||||||
"type": {
|
"type": {
|
||||||
"kind": "LIST",
|
"kind": "LIST",
|
||||||
"name": null,
|
"name": null,
|
||||||
|
@ -102315,6 +102315,26 @@
|
||||||
},
|
},
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "shippingZones",
|
||||||
|
"description": "List of shipping zones IDs which causes the error.",
|
||||||
|
"args": [],
|
||||||
|
"type": {
|
||||||
|
"kind": "LIST",
|
||||||
|
"name": null,
|
||||||
|
"ofType": {
|
||||||
|
"kind": "NON_NULL",
|
||||||
|
"name": null,
|
||||||
|
"ofType": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "ID",
|
||||||
|
"ofType": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inputFields": null,
|
"inputFields": null,
|
||||||
|
|
|
@ -1131,6 +1131,10 @@
|
||||||
"context": "product field",
|
"context": "product field",
|
||||||
"string": "Export Product Weight"
|
"string": "Export Product Weight"
|
||||||
},
|
},
|
||||||
|
"7KRGqz": {
|
||||||
|
"context": "Payment card title",
|
||||||
|
"string": "Payment balance"
|
||||||
|
},
|
||||||
"7NFfmz": {
|
"7NFfmz": {
|
||||||
"string": "Products"
|
"string": "Products"
|
||||||
},
|
},
|
||||||
|
@ -3806,10 +3810,6 @@
|
||||||
"context": "unassign attribute from product type, button",
|
"context": "unassign attribute from product type, button",
|
||||||
"string": "Unassign"
|
"string": "Unassign"
|
||||||
},
|
},
|
||||||
"SC/eNC": {
|
|
||||||
"context": "Payment card title",
|
|
||||||
"string": "Payment status"
|
|
||||||
},
|
|
||||||
"SHm7ee": {
|
"SHm7ee": {
|
||||||
"string": "Search by product name, attribute, product type etc..."
|
"string": "Search by product name, attribute, product type etc..."
|
||||||
},
|
},
|
||||||
|
@ -3888,6 +3888,10 @@
|
||||||
"context": "checkbox label, fulfillment approval",
|
"context": "checkbox label, fulfillment approval",
|
||||||
"string": "Send shipment details to customer"
|
"string": "Send shipment details to customer"
|
||||||
},
|
},
|
||||||
|
"Sxzua5": {
|
||||||
|
"context": "order payment",
|
||||||
|
"string": "Settled"
|
||||||
|
},
|
||||||
"T/5OyA": {
|
"T/5OyA": {
|
||||||
"string": "No translation yet"
|
"string": "No translation yet"
|
||||||
},
|
},
|
||||||
|
@ -6570,6 +6574,10 @@
|
||||||
"context": "tab name",
|
"context": "tab name",
|
||||||
"string": "All Vouchers"
|
"string": "All Vouchers"
|
||||||
},
|
},
|
||||||
|
"pPef6L": {
|
||||||
|
"context": "order payment",
|
||||||
|
"string": "Included in subtotal"
|
||||||
|
},
|
||||||
"pRYGUR": {
|
"pRYGUR": {
|
||||||
"context": "section description",
|
"context": "section description",
|
||||||
"string": "This address will be used to generate invoices and calculate shipping rates. Email address you provide here will be used as a contact address for your customers."
|
"string": "This address will be used to generate invoices and calculate shipping rates. Email address you provide here will be used as a contact address for your customers."
|
||||||
|
@ -7236,6 +7244,10 @@
|
||||||
"context": "voucher start date",
|
"context": "voucher start date",
|
||||||
"string": "Started"
|
"string": "Started"
|
||||||
},
|
},
|
||||||
|
"ukYopn": {
|
||||||
|
"context": "order payment",
|
||||||
|
"string": "Included in prices"
|
||||||
|
},
|
||||||
"ukdRUv": {
|
"ukdRUv": {
|
||||||
"context": "delete variant dialog subtitle",
|
"context": "delete variant dialog subtitle",
|
||||||
"string": "{counter,plural,one{Are you sure you want to delete this variant?} other{Are you sure you want to delete {displayQuantity} variants?}}"
|
"string": "{counter,plural,one{Are you sure you want to delete this variant?} other{Are you sure you want to delete {displayQuantity} variants?}}"
|
||||||
|
|
|
@ -414,11 +414,10 @@ type Allocation implements Node {
|
||||||
"""
|
"""
|
||||||
Determine the allocation strategy for the channel.
|
Determine the allocation strategy for the channel.
|
||||||
|
|
||||||
PRIORITIZE_SORTING_ORDER - the allocation is prioritized by the warehouses' sort
|
PRIORITIZE_SORTING_ORDER - allocate stocks according to the warehouses' order
|
||||||
order within the channel
|
within the channel
|
||||||
|
|
||||||
PRIORITIZE_HIGH_STOCK - the allocation is prioritized by the highest available
|
PRIORITIZE_HIGH_STOCK - allocate stock in a warehouse with the most stock
|
||||||
quantity in stocks
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
enum AllocationStrategyEnum {
|
enum AllocationStrategyEnum {
|
||||||
|
@ -11557,7 +11556,7 @@ type Mutation {
|
||||||
"""ID of a channel."""
|
"""ID of a channel."""
|
||||||
channelId: ID!
|
channelId: ID!
|
||||||
|
|
||||||
"""The list of reordering operations for given channel warehouses."""
|
"""The list of reordering operations for the given channel warehouses."""
|
||||||
moves: [ReorderInput!]!
|
moves: [ReorderInput!]!
|
||||||
): ChannelReorderWarehouses
|
): ChannelReorderWarehouses
|
||||||
|
|
||||||
|
@ -14909,7 +14908,7 @@ type PaymentError {
|
||||||
"""The error code."""
|
"""The error code."""
|
||||||
code: PaymentErrorCode!
|
code: PaymentErrorCode!
|
||||||
|
|
||||||
"""List of varint IDs which causes the error."""
|
"""List of variant IDs which causes the error."""
|
||||||
variants: [ID!]
|
variants: [ID!]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21151,7 +21150,7 @@ Note: this API is currently in Feature Preview and can be subject to changes at
|
||||||
"""
|
"""
|
||||||
type StockSettings {
|
type StockSettings {
|
||||||
"""
|
"""
|
||||||
Allocation strategy options. Strategy defines the preference of warehouses for allocations and reservations.
|
Allocation strategy defines the preference of warehouses for allocations and reservations.
|
||||||
"""
|
"""
|
||||||
allocationStrategy: AllocationStrategyEnum!
|
allocationStrategy: AllocationStrategyEnum!
|
||||||
}
|
}
|
||||||
|
@ -22856,7 +22855,11 @@ input WarehouseCreateInput {
|
||||||
"""Address of the warehouse."""
|
"""Address of the warehouse."""
|
||||||
address: AddressInput!
|
address: AddressInput!
|
||||||
|
|
||||||
"""Shipping zones supported by the warehouse."""
|
"""
|
||||||
|
Shipping zones supported by the warehouse.
|
||||||
|
|
||||||
|
DEPRECATED: this field will be removed in Saleor 4.0. Providing the zone ids will raise a ValidationError.
|
||||||
|
"""
|
||||||
shippingZones: [ID!]
|
shippingZones: [ID!]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22930,6 +22933,9 @@ type WarehouseError {
|
||||||
|
|
||||||
"""The error code."""
|
"""The error code."""
|
||||||
code: WarehouseErrorCode!
|
code: WarehouseErrorCode!
|
||||||
|
|
||||||
|
"""List of shipping zones IDs which causes the error."""
|
||||||
|
shippingZones: [ID!]
|
||||||
}
|
}
|
||||||
|
|
||||||
"""An enumeration."""
|
"""An enumeration."""
|
||||||
|
|
|
@ -287,6 +287,9 @@ export const fragmentOrderDetails = gql`
|
||||||
totalCaptured {
|
totalCaptured {
|
||||||
...Money
|
...Money
|
||||||
}
|
}
|
||||||
|
totalBalance {
|
||||||
|
...Money
|
||||||
|
}
|
||||||
undiscountedTotal {
|
undiscountedTotal {
|
||||||
net {
|
net {
|
||||||
...Money
|
...Money
|
||||||
|
|
|
@ -1424,6 +1424,9 @@ export const OrderDetailsFragmentDoc = gql`
|
||||||
totalCaptured {
|
totalCaptured {
|
||||||
...Money
|
...Money
|
||||||
}
|
}
|
||||||
|
totalBalance {
|
||||||
|
...Money
|
||||||
|
}
|
||||||
undiscountedTotal {
|
undiscountedTotal {
|
||||||
net {
|
net {
|
||||||
...Money
|
...Money
|
||||||
|
|
|
@ -5090,11 +5090,12 @@ export type WarehouseDeletedFieldPolicy = {
|
||||||
recipient?: FieldPolicy<any> | FieldReadFunction<any>,
|
recipient?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||||
warehouse?: FieldPolicy<any> | FieldReadFunction<any>
|
warehouse?: FieldPolicy<any> | FieldReadFunction<any>
|
||||||
};
|
};
|
||||||
export type WarehouseErrorKeySpecifier = ('field' | 'message' | 'code' | WarehouseErrorKeySpecifier)[];
|
export type WarehouseErrorKeySpecifier = ('field' | 'message' | 'code' | 'shippingZones' | WarehouseErrorKeySpecifier)[];
|
||||||
export type WarehouseErrorFieldPolicy = {
|
export type WarehouseErrorFieldPolicy = {
|
||||||
field?: FieldPolicy<any> | FieldReadFunction<any>,
|
field?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||||
message?: FieldPolicy<any> | FieldReadFunction<any>,
|
message?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||||
code?: FieldPolicy<any> | FieldReadFunction<any>
|
code?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||||
|
shippingZones?: FieldPolicy<any> | FieldReadFunction<any>
|
||||||
};
|
};
|
||||||
export type WarehouseShippingZoneAssignKeySpecifier = ('warehouseErrors' | 'errors' | 'warehouse' | WarehouseShippingZoneAssignKeySpecifier)[];
|
export type WarehouseShippingZoneAssignKeySpecifier = ('warehouseErrors' | 'errors' | 'warehouse' | WarehouseShippingZoneAssignKeySpecifier)[];
|
||||||
export type WarehouseShippingZoneAssignFieldPolicy = {
|
export type WarehouseShippingZoneAssignFieldPolicy = {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -11,41 +11,15 @@ import {
|
||||||
OrderDiscountType,
|
OrderDiscountType,
|
||||||
OrderStatus,
|
OrderStatus,
|
||||||
} from "@saleor/graphql";
|
} from "@saleor/graphql";
|
||||||
import { makeStyles, Pill } from "@saleor/macaw-ui";
|
import { Pill } from "@saleor/macaw-ui";
|
||||||
|
import clsx from "clsx";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
|
||||||
import { maybe, transformPaymentStatus } from "../../../misc";
|
import { transformPaymentStatus } from "../../../misc";
|
||||||
import { orderPaymentMessages, paymentButtonMessages } from "./messages";
|
import { orderPaymentMessages, paymentButtonMessages } from "./messages";
|
||||||
import {
|
import { useStyles } from "./styles";
|
||||||
extractOrderGiftCardUsedAmount,
|
import { extractOrderGiftCardUsedAmount, extractRefundedAmount } from "./utils";
|
||||||
extractOutstandingBalance,
|
|
||||||
extractRefundedAmount,
|
|
||||||
} from "./utils";
|
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
|
||||||
theme => ({
|
|
||||||
header: {
|
|
||||||
display: "flex",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
},
|
|
||||||
root: {
|
|
||||||
...theme.typography.body1,
|
|
||||||
lineHeight: 1.9,
|
|
||||||
width: "100%",
|
|
||||||
},
|
|
||||||
textRight: {
|
|
||||||
textAlign: "right",
|
|
||||||
},
|
|
||||||
totalRow: {
|
|
||||||
fontWeight: 600,
|
|
||||||
},
|
|
||||||
titleContainer: {
|
|
||||||
display: "flex",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
{ name: "OrderPayment" },
|
|
||||||
);
|
|
||||||
|
|
||||||
interface OrderPaymentProps {
|
interface OrderPaymentProps {
|
||||||
order: OrderDetailsFragment;
|
order: OrderDetailsFragment;
|
||||||
|
@ -61,20 +35,17 @@ const OrderPayment: React.FC<OrderPaymentProps> = props => {
|
||||||
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const canCapture = maybe(() => order.actions, []).includes(
|
const canCapture = (order?.actions ?? []).includes(OrderAction.CAPTURE);
|
||||||
OrderAction.CAPTURE,
|
const canVoid = (order?.actions ?? []).includes(OrderAction.VOID);
|
||||||
);
|
const canRefund = (order?.actions ?? []).includes(OrderAction.REFUND);
|
||||||
const canVoid = maybe(() => order.actions, []).includes(OrderAction.VOID);
|
const canMarkAsPaid = (order?.actions ?? []).includes(
|
||||||
const canRefund = maybe(() => order.actions, []).includes(OrderAction.REFUND);
|
|
||||||
const canMarkAsPaid = maybe(() => order.actions, []).includes(
|
|
||||||
OrderAction.MARK_AS_PAID,
|
OrderAction.MARK_AS_PAID,
|
||||||
);
|
);
|
||||||
const payment = transformPaymentStatus(order?.paymentStatus, intl);
|
const payment = transformPaymentStatus(order?.paymentStatus, intl);
|
||||||
const refundedAmount = extractRefundedAmount(order);
|
const refundedAmount = extractRefundedAmount(order);
|
||||||
const outstandingBalance = extractOutstandingBalance(order);
|
|
||||||
const usedGiftCardAmount = extractOrderGiftCardUsedAmount(order);
|
const usedGiftCardAmount = extractOrderGiftCardUsedAmount(order);
|
||||||
|
|
||||||
const getDeliveryMethodName = order => {
|
const getDeliveryMethodName = (order: OrderDetailsFragment) => {
|
||||||
if (
|
if (
|
||||||
order?.shippingMethodName === undefined &&
|
order?.shippingMethodName === undefined &&
|
||||||
order?.shippingPrice === undefined &&
|
order?.shippingPrice === undefined &&
|
||||||
|
@ -102,13 +73,15 @@ const OrderPayment: React.FC<OrderPaymentProps> = props => {
|
||||||
!order?.paymentStatus ? (
|
!order?.paymentStatus ? (
|
||||||
<Skeleton />
|
<Skeleton />
|
||||||
) : (
|
) : (
|
||||||
<div className={classes.header}>
|
|
||||||
<div className={classes.titleContainer}>
|
<div className={classes.titleContainer}>
|
||||||
<FormattedMessage {...orderPaymentMessages.paymentTitle} />
|
<FormattedMessage {...orderPaymentMessages.paymentTitle} />
|
||||||
<HorizontalSpacer spacing={2} />
|
<HorizontalSpacer spacing={2} />
|
||||||
<Pill label={payment.localized} color={payment.status} />
|
<Pill
|
||||||
</div>
|
className={classes.rightmostLeftAlignedElement}
|
||||||
{maybe(() => order.status) !== OrderStatus.CANCELED &&
|
label={payment.localized}
|
||||||
|
color={payment.status}
|
||||||
|
/>
|
||||||
|
{order?.status !== OrderStatus.CANCELED &&
|
||||||
(canCapture || canRefund || canVoid || canMarkAsPaid) && (
|
(canCapture || canRefund || canVoid || canMarkAsPaid) && (
|
||||||
<div>
|
<div>
|
||||||
{canCapture && (
|
{canCapture && (
|
||||||
|
@ -144,172 +117,142 @@ const OrderPayment: React.FC<OrderPaymentProps> = props => {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<table className={classes.root}>
|
<div className={classes.root}>
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<FormattedMessage {...orderPaymentMessages.subtotal} />
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{maybe(() => order.lines) === undefined ? (
|
|
||||||
<Skeleton />
|
|
||||||
) : (
|
|
||||||
<FormattedMessage
|
|
||||||
{...orderPaymentMessages.itemCount}
|
|
||||||
values={{
|
|
||||||
quantity: order.lines
|
|
||||||
.map(line => line.quantity)
|
|
||||||
.reduce((curr, prev) => prev + curr, 0),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td className={classes.textRight}>
|
|
||||||
{maybe(() => order.subtotal.gross) === undefined ? (
|
|
||||||
<Skeleton />
|
|
||||||
) : (
|
|
||||||
<Money money={order.subtotal.gross} />
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<FormattedMessage {...orderPaymentMessages.taxes} />
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{maybe(() => order.total.tax) === undefined ? (
|
|
||||||
<Skeleton />
|
|
||||||
) : order.total.tax.amount > 0 ? (
|
|
||||||
intl.formatMessage(orderPaymentMessages.vatIncluded)
|
|
||||||
) : (
|
|
||||||
intl.formatMessage(orderPaymentMessages.vatNotIncluded)
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td className={classes.textRight}>
|
|
||||||
{maybe(() => order.total.tax) === undefined ? (
|
|
||||||
<Skeleton />
|
|
||||||
) : (
|
|
||||||
<Money money={order.total.tax} />
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<FormattedMessage {...orderPaymentMessages.shipping} />
|
|
||||||
</td>
|
|
||||||
<td>{getDeliveryMethodName(order)}</td>
|
|
||||||
<td className={classes.textRight}>
|
|
||||||
{maybe(() => order.shippingPrice.gross) === undefined ? (
|
|
||||||
<Skeleton />
|
|
||||||
) : (
|
|
||||||
<Money money={order.shippingPrice.gross} />
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{order?.discounts?.map(discount => (
|
{order?.discounts?.map(discount => (
|
||||||
<tr>
|
<div>
|
||||||
<td>
|
|
||||||
<FormattedMessage {...orderPaymentMessages.discount} />
|
<FormattedMessage {...orderPaymentMessages.discount} />
|
||||||
</td>
|
<HorizontalSpacer spacing={4} />
|
||||||
<td>
|
<span className={classes.supportText}>
|
||||||
{discount.type === OrderDiscountType.MANUAL ? (
|
{discount.type === OrderDiscountType.MANUAL ? (
|
||||||
<FormattedMessage {...orderPaymentMessages.staffAdded} />
|
<FormattedMessage {...orderPaymentMessages.staffAdded} />
|
||||||
) : (
|
) : (
|
||||||
<FormattedMessage {...orderPaymentMessages.voucher} />
|
<FormattedMessage {...orderPaymentMessages.voucher} />
|
||||||
)}
|
)}
|
||||||
</td>
|
</span>
|
||||||
<td className={classes.textRight}>
|
<span
|
||||||
-<Money money={discount.amount} />
|
className={clsx(
|
||||||
</td>
|
classes.leftmostRightAlignedElement,
|
||||||
</tr>
|
classes.smallFont,
|
||||||
))}
|
classes.supportText,
|
||||||
<tr className={classes.totalRow}>
|
|
||||||
<td>
|
|
||||||
<FormattedMessage {...orderPaymentMessages.total} />
|
|
||||||
</td>
|
|
||||||
<td />
|
|
||||||
<td className={classes.textRight}>
|
|
||||||
{maybe(() => order.total.gross) === undefined ? (
|
|
||||||
<Skeleton />
|
|
||||||
) : (
|
|
||||||
<Money money={order.total.gross} />
|
|
||||||
)}
|
)}
|
||||||
</td>
|
>
|
||||||
</tr>
|
<FormattedMessage
|
||||||
</tbody>
|
{...orderPaymentMessages.includedInSubtotal}
|
||||||
</table>
|
/>
|
||||||
|
</span>
|
||||||
|
<HorizontalSpacer spacing={2} />
|
||||||
|
<div className={classes.supportText}>
|
||||||
|
-<Money money={discount.amount} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<div>
|
||||||
|
<FormattedMessage {...orderPaymentMessages.subtotal} />
|
||||||
|
<div className={classes.leftmostRightAlignedElement}>
|
||||||
|
{<Money money={order?.subtotal.gross} /> ?? <Skeleton />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<FormattedMessage {...orderPaymentMessages.shipping} />
|
||||||
|
<HorizontalSpacer spacing={4} />
|
||||||
|
<div className={classes.supportText}>
|
||||||
|
{getDeliveryMethodName(order)}
|
||||||
|
</div>
|
||||||
|
<div className={classes.leftmostRightAlignedElement}>
|
||||||
|
{<Money money={order?.shippingPrice.gross} /> ?? <Skeleton />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<FormattedMessage {...orderPaymentMessages.taxes} />
|
||||||
|
{order?.total.tax.amount > 0 && (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className={clsx(
|
||||||
|
classes.supportText,
|
||||||
|
classes.smallFont,
|
||||||
|
classes.leftmostRightAlignedElement,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<FormattedMessage
|
||||||
|
{...orderPaymentMessages.includedInPrices}
|
||||||
|
/>{" "}
|
||||||
|
</div>
|
||||||
|
<HorizontalSpacer spacing={2} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<div
|
||||||
|
className={clsx(
|
||||||
|
{
|
||||||
|
[classes.leftmostRightAlignedElement]:
|
||||||
|
order?.total.tax.amount === 0,
|
||||||
|
},
|
||||||
|
classes.supportText,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{<Money money={order?.total.tax} /> ?? <Skeleton />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={classes.totalRow}>
|
||||||
|
<FormattedMessage {...orderPaymentMessages.total} />
|
||||||
|
<div className={classes.leftmostRightAlignedElement}>
|
||||||
|
{<Money money={order?.total.gross} /> ?? <Skeleton />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<Hr />
|
<Hr />
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<table className={classes.root}>
|
<div className={classes.root}>
|
||||||
<tbody>
|
|
||||||
{!!usedGiftCardAmount && (
|
{!!usedGiftCardAmount && (
|
||||||
<tr>
|
<div>
|
||||||
<td>
|
<FormattedMessage {...orderPaymentMessages.paidWithGiftCard} />
|
||||||
<FormattedMessage
|
<div className={classes.leftmostRightAlignedElement}>
|
||||||
{...orderPaymentMessages.paidWithGiftCard}
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td className={classes.textRight}>
|
|
||||||
<Money
|
<Money
|
||||||
money={{
|
money={{
|
||||||
amount: usedGiftCardAmount,
|
amount: usedGiftCardAmount,
|
||||||
currency: order?.total?.gross?.currency,
|
currency: order?.total?.gross?.currency,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</td>
|
</div>
|
||||||
</tr>
|
</div>
|
||||||
)}
|
)}
|
||||||
<tr>
|
<div>
|
||||||
<td>
|
|
||||||
<FormattedMessage {...orderPaymentMessages.preauthorized} />
|
<FormattedMessage {...orderPaymentMessages.preauthorized} />
|
||||||
</td>
|
<div className={classes.leftmostRightAlignedElement}>
|
||||||
<td className={classes.textRight}>
|
{<Money money={order?.totalAuthorized} /> ?? <Skeleton />}
|
||||||
{maybe(() => order.totalAuthorized.amount) === undefined ? (
|
</div>
|
||||||
<Skeleton />
|
</div>
|
||||||
) : (
|
<div>
|
||||||
<Money money={order.totalAuthorized} />
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<FormattedMessage {...orderPaymentMessages.captured} />
|
<FormattedMessage {...orderPaymentMessages.captured} />
|
||||||
</td>
|
<div className={classes.leftmostRightAlignedElement}>
|
||||||
<td className={classes.textRight}>
|
{<Money money={order?.totalCaptured} /> ?? <Skeleton />}
|
||||||
{maybe(() => order.totalCaptured.amount) === undefined ? (
|
</div>
|
||||||
<Skeleton />
|
</div>
|
||||||
) : (
|
{!!refundedAmount?.amount && (
|
||||||
<Money money={order.totalCaptured} />
|
<div>
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<FormattedMessage {...orderPaymentMessages.refunded} />
|
<FormattedMessage {...orderPaymentMessages.refunded} />
|
||||||
</td>
|
<div className={classes.leftmostRightAlignedElement}>
|
||||||
<td className={classes.textRight}>
|
{<Money money={refundedAmount} />}
|
||||||
{refundedAmount?.amount === undefined ? (
|
</div>
|
||||||
<Skeleton />
|
</div>
|
||||||
) : (
|
|
||||||
<Money money={refundedAmount} />
|
|
||||||
)}
|
)}
|
||||||
</td>
|
<div
|
||||||
</tr>
|
className={clsx(
|
||||||
<tr className={classes.totalRow}>
|
{ [classes.success]: order?.totalBalance.amount === 0 },
|
||||||
<td>
|
classes.totalRow,
|
||||||
|
)}
|
||||||
|
>
|
||||||
<FormattedMessage {...orderPaymentMessages.outstanding} />
|
<FormattedMessage {...orderPaymentMessages.outstanding} />
|
||||||
</td>
|
<div className={classes.leftmostRightAlignedElement}>
|
||||||
<td className={classes.textRight}>
|
{order?.totalBalance.amount === 0 ? (
|
||||||
{outstandingBalance?.amount === undefined ? (
|
<FormattedMessage {...orderPaymentMessages.settled} />
|
||||||
<Skeleton />
|
|
||||||
) : (
|
) : (
|
||||||
<Money money={outstandingBalance} />
|
<Money money={order?.totalBalance} /> ?? <Skeleton />
|
||||||
)}
|
)}
|
||||||
</td>
|
{}
|
||||||
</tr>
|
</div>
|
||||||
</tbody>
|
</div>
|
||||||
</table>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,8 +12,8 @@ export const orderPaymentMessages = defineMessages({
|
||||||
description: "OrderPayment does not require shipping",
|
description: "OrderPayment does not require shipping",
|
||||||
},
|
},
|
||||||
paymentTitle: {
|
paymentTitle: {
|
||||||
id: "SC/eNC",
|
id: "7KRGqz",
|
||||||
defaultMessage: "Payment status",
|
defaultMessage: "Payment balance",
|
||||||
description: "Payment card title",
|
description: "Payment card title",
|
||||||
},
|
},
|
||||||
subtotal: {
|
subtotal: {
|
||||||
|
@ -95,6 +95,21 @@ export const orderPaymentMessages = defineMessages({
|
||||||
defaultMessage: "Paid with Gift Card",
|
defaultMessage: "Paid with Gift Card",
|
||||||
description: "order payment",
|
description: "order payment",
|
||||||
},
|
},
|
||||||
|
includedInSubtotal: {
|
||||||
|
id: "pPef6L",
|
||||||
|
defaultMessage: "Included in subtotal",
|
||||||
|
description: "order payment",
|
||||||
|
},
|
||||||
|
includedInPrices: {
|
||||||
|
id: "ukYopn",
|
||||||
|
defaultMessage: "Included in prices",
|
||||||
|
description: "order payment",
|
||||||
|
},
|
||||||
|
settled: {
|
||||||
|
id: "Sxzua5",
|
||||||
|
defaultMessage: "Settled",
|
||||||
|
description: "order payment",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const paymentButtonMessages = defineMessages({
|
export const paymentButtonMessages = defineMessages({
|
||||||
|
|
41
src/orders/components/OrderPayment/styles.ts
Normal file
41
src/orders/components/OrderPayment/styles.ts
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import { makeStyles } from "@saleor/macaw-ui";
|
||||||
|
|
||||||
|
export const useStyles = makeStyles(
|
||||||
|
theme => ({
|
||||||
|
header: {
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
},
|
||||||
|
root: {
|
||||||
|
...theme.typography.body1,
|
||||||
|
lineHeight: 1.9,
|
||||||
|
width: "100%",
|
||||||
|
"& > div": {
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "flex-end",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
leftmostRightAlignedElement: {
|
||||||
|
marginLeft: "auto",
|
||||||
|
},
|
||||||
|
rightmostLeftAlignedElement: {
|
||||||
|
marginRight: "auto",
|
||||||
|
},
|
||||||
|
totalRow: {
|
||||||
|
fontWeight: 600,
|
||||||
|
},
|
||||||
|
titleContainer: {
|
||||||
|
display: "flex",
|
||||||
|
},
|
||||||
|
supportText: {
|
||||||
|
color: theme.palette.saleor.main[3],
|
||||||
|
},
|
||||||
|
smallFont: {
|
||||||
|
fontSize: theme.typography.body2.fontSize,
|
||||||
|
},
|
||||||
|
success: {
|
||||||
|
color: theme.palette.success.dark,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
{ name: "OrderPayment" },
|
||||||
|
);
|
|
@ -1586,6 +1586,11 @@ export const order = (placeholder: string): OrderDetailsFragment => ({
|
||||||
amount: 0,
|
amount: 0,
|
||||||
currency: "USD",
|
currency: "USD",
|
||||||
},
|
},
|
||||||
|
totalBalance: {
|
||||||
|
__typename: "Money",
|
||||||
|
amount: 0,
|
||||||
|
currency: "USD",
|
||||||
|
},
|
||||||
undiscountedTotal: {
|
undiscountedTotal: {
|
||||||
__typename: "TaxedMoney",
|
__typename: "TaxedMoney",
|
||||||
gross: {
|
gross: {
|
||||||
|
@ -1891,6 +1896,11 @@ export const draftOrder = (placeholder: string): OrderDetailsFragment => ({
|
||||||
},
|
},
|
||||||
totalAuthorized: null,
|
totalAuthorized: null,
|
||||||
totalCaptured: null,
|
totalCaptured: null,
|
||||||
|
totalBalance: {
|
||||||
|
__typename: "Money" as "Money",
|
||||||
|
amount: 168.3,
|
||||||
|
currency: "USD",
|
||||||
|
},
|
||||||
undiscountedTotal: {
|
undiscountedTotal: {
|
||||||
__typename: "TaxedMoney",
|
__typename: "TaxedMoney",
|
||||||
gross: {
|
gross: {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue