saleor-dashboard/src/orders/components/OrderHistory/OrderHistory.tsx

416 lines
14 KiB
TypeScript
Raw Normal View History

2019-10-30 14:34:24 +00:00
import { makeStyles } from "@material-ui/core/styles";
2019-06-19 14:40:52 +00:00
import Typography from "@material-ui/core/Typography";
import Form from "@saleor/components/Form";
import Hr from "@saleor/components/Hr";
Refunds (#870) * 1721 - add refunds miscellaneous view (#860) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Fix refund details on order details page (#879) * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Add missing refund amount to order history * Merge repeated order lines in fulfillment lines * Update order history events types and test snapshots * Update changelog with refunds changes
2020-12-01 13:13:05 +00:00
import Money from "@saleor/components/Money";
2019-06-19 14:40:52 +00:00
import Skeleton from "@saleor/components/Skeleton";
import {
Timeline,
TimelineAddNote,
TimelineEvent,
TimelineNote
} from "@saleor/components/Timeline";
import React from "react";
import { FormattedMessage, IntlShape, useIntl } from "react-intl";
2019-06-19 14:40:52 +00:00
import {
OrderEventsEmailsEnum,
OrderEventsEnum
} from "../../../types/globalTypes";
import { OrderDetails_order_events } from "../../types/OrderDetails";
export interface FormData {
message: string;
}
const getEventMessage = (event: OrderDetails_order_events, intl: IntlShape) => {
2019-06-19 14:40:52 +00:00
switch (event.type) {
case OrderEventsEnum.CANCELED:
return intl.formatMessage({
defaultMessage: "Order was cancelled",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.DRAFT_ADDED_PRODUCTS:
return intl.formatMessage({
defaultMessage: "Products were added to draft order",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.DRAFT_CREATED:
return intl.formatMessage({
defaultMessage: "Draft order was created",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.DRAFT_REMOVED_PRODUCTS:
return intl.formatMessage({
2019-09-05 10:44:10 +00:00
defaultMessage: "Products were deleted from draft order",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.EMAIL_SENT:
switch (event.emailType) {
case OrderEventsEmailsEnum.DIGITAL_LINKS:
return intl.formatMessage({
defaultMessage: "Links to the order's digital goods were sent",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEmailsEnum.FULFILLMENT_CONFIRMATION:
return intl.formatMessage({
defaultMessage: "Fulfillment confirmation was sent to customer",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEmailsEnum.ORDER_CONFIRMATION:
return intl.formatMessage({
defaultMessage: "Order confirmation was sent to customer",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEmailsEnum.PAYMENT_CONFIRMATION:
return intl.formatMessage({
defaultMessage: "Payment confirmation was sent to customer",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEmailsEnum.SHIPPING_CONFIRMATION:
return intl.formatMessage({
defaultMessage: "Shipping details was sent to customer",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEmailsEnum.TRACKING_UPDATED:
return intl.formatMessage({
defaultMessage: "Shipping tracking number was sent to customer",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
2020-08-26 10:33:03 +00:00
case OrderEventsEmailsEnum.ORDER_CANCEL:
return intl.formatMessage({
defaultMessage: "Order cancel information was sent to customer",
description: "order history message"
});
case OrderEventsEmailsEnum.ORDER_REFUND:
return intl.formatMessage({
defaultMessage: "Order refund information was sent to customer",
description: "order history message"
});
2019-06-19 14:40:52 +00:00
}
case OrderEventsEnum.FULFILLMENT_CANCELED:
return intl.formatMessage({
defaultMessage: "Fulfillment was cancelled",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.INVOICE_REQUESTED:
return intl.formatMessage(
{
defaultMessage: "Invoice was requested by {requestedBy}",
description: "order history message"
},
{
requestedBy: event.user ? event.user.email : null
}
);
case OrderEventsEnum.INVOICE_GENERATED:
return intl.formatMessage(
{
defaultMessage:
"Invoice no. {invoiceNumber} was generated by {generatedBy}",
description: "order history message"
},
{
2020-07-21 17:08:27 +00:00
generatedBy: event.user ? event.user.email : null,
invoiceNumber: event.invoiceNumber
}
2020-07-17 08:10:01 +00:00
);
case OrderEventsEnum.INVOICE_UPDATED:
return intl.formatMessage(
{
defaultMessage: "Invoice no. {invoiceNumber} was updated",
description: "order history message"
},
{
invoiceNumber: event.invoiceNumber
}
);
case OrderEventsEnum.INVOICE_SENT:
return intl.formatMessage(
{
defaultMessage: "Invoice was sent to customer by {sentBy}",
description: "order history message"
},
{
sentBy: event.user ? event.user.email : null
}
);
2019-06-19 14:40:52 +00:00
case OrderEventsEnum.FULFILLMENT_FULFILLED_ITEMS:
return intl.formatMessage(
{
defaultMessage: "Fulfilled {quantity} items",
description: "order history message"
},
{
quantity: event.quantity
}
);
Refunds (#870) * 1721 - add refunds miscellaneous view (#860) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Fix refund details on order details page (#879) * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Add missing refund amount to order history * Merge repeated order lines in fulfillment lines * Update order history events types and test snapshots * Update changelog with refunds changes
2020-12-01 13:13:05 +00:00
case OrderEventsEnum.FULFILLMENT_REFUNDED:
return intl.formatMessage(
{
defaultMessage: "Order was refunded by {refundedBy}",
description: "order history message"
},
{
refundedBy: event.user ? event.user.email : null
}
);
2019-06-19 14:40:52 +00:00
case OrderEventsEnum.FULFILLMENT_RESTOCKED_ITEMS:
return intl.formatMessage(
{
defaultMessage: "Restocked {quantity} items",
description: "order history message"
},
{
quantity: event.quantity
}
);
2019-06-19 14:40:52 +00:00
case OrderEventsEnum.NOTE_ADDED:
return intl.formatMessage({
defaultMessage: "Note was added to the order",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.ORDER_FULLY_PAID:
return intl.formatMessage({
defaultMessage: "Order was fully paid",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.ORDER_MARKED_AS_PAID:
return intl.formatMessage({
defaultMessage: "Order was marked as paid",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.OTHER:
return event.message;
case OrderEventsEnum.OVERSOLD_ITEMS:
return intl.formatMessage(
{
defaultMessage: "Oversold {quantity} items",
description: "order history message"
},
{
quantity: event.quantity
}
);
2019-06-19 14:40:52 +00:00
case OrderEventsEnum.PAYMENT_CAPTURED:
return intl.formatMessage({
defaultMessage: "Payment was captured",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.PAYMENT_FAILED:
return intl.formatMessage({
defaultMessage: "Payment failed",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.PAYMENT_REFUNDED:
return intl.formatMessage({
defaultMessage: "Payment was refunded",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.PAYMENT_VOIDED:
return intl.formatMessage({
defaultMessage: "Payment was voided",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.PLACED:
return intl.formatMessage({
defaultMessage: "Order was placed",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.PLACED_FROM_DRAFT:
return intl.formatMessage({
defaultMessage: "Order was created from draft",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.TRACKING_UPDATED:
return intl.formatMessage({
defaultMessage: "Updated fulfillment group's tracking number",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.UPDATED_ADDRESS:
return intl.formatMessage({
defaultMessage: "Order address was updated",
description: "order history message"
2020-09-02 09:57:48 +00:00
});
case OrderEventsEnum.PAYMENT_AUTHORIZED:
return intl.formatMessage({
defaultMessage: "Payment was authorized",
description: "order history message"
2019-06-19 14:40:52 +00:00
});
case OrderEventsEnum.CONFIRMED:
return intl.formatMessage({
defaultMessage: "Order was confirmed",
description: "order history message"
});
2020-08-26 10:33:03 +00:00
case OrderEventsEnum.EXTERNAL_SERVICE_NOTIFICATION:
return event.message;
2019-06-19 14:40:52 +00:00
}
};
2019-12-03 15:28:40 +00:00
const useStyles = makeStyles(
theme => ({
Refunds (#870) * 1721 - add refunds miscellaneous view (#860) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Fix refund details on order details page (#879) * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Add missing refund amount to order history * Merge repeated order lines in fulfillment lines * Update order history events types and test snapshots * Update changelog with refunds changes
2020-12-01 13:13:05 +00:00
eventSubtitle: {
marginTop: theme.spacing(1)
},
2019-12-03 15:28:40 +00:00
header: {
fontWeight: 500,
marginBottom: theme.spacing(1)
},
Refunds (#870) * 1721 - add refunds miscellaneous view (#860) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Fix refund details on order details page (#879) * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Add missing refund amount to order history * Merge repeated order lines in fulfillment lines * Update order history events types and test snapshots * Update changelog with refunds changes
2020-12-01 13:13:05 +00:00
linesTableCell: {
paddingRight: theme.spacing(3)
},
2019-12-03 15:28:40 +00:00
root: { marginTop: theme.spacing(4) },
user: {
marginBottom: theme.spacing(1)
}
}),
{ name: "OrderHistory" }
);
2019-06-19 14:40:52 +00:00
2019-10-30 14:34:24 +00:00
interface OrderHistoryProps {
2019-06-19 14:40:52 +00:00
history: OrderDetails_order_events[];
Refunds (#870) * 1721 - add refunds miscellaneous view (#860) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Fix refund details on order details page (#879) * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Add missing refund amount to order history * Merge repeated order lines in fulfillment lines * Update order history events types and test snapshots * Update changelog with refunds changes
2020-12-01 13:13:05 +00:00
orderCurrency: string;
2019-06-19 14:40:52 +00:00
onNoteAdd: (data: FormData) => void;
}
2019-10-30 14:34:24 +00:00
const OrderHistory: React.FC<OrderHistoryProps> = props => {
Refunds (#870) * 1721 - add refunds miscellaneous view (#860) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Fix refund details on order details page (#879) * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Add missing refund amount to order history * Merge repeated order lines in fulfillment lines * Update order history events types and test snapshots * Update changelog with refunds changes
2020-12-01 13:13:05 +00:00
const { history, orderCurrency, onNoteAdd } = props;
2019-10-30 14:34:24 +00:00
const classes = useStyles(props);
2019-10-30 14:34:24 +00:00
const intl = useIntl();
return (
<div className={classes.root}>
<Typography className={classes.header} color="textSecondary">
<FormattedMessage defaultMessage="Order History" />
</Typography>
<Hr />
{history ? (
<Timeline>
<Form initial={{ message: "" }} onSubmit={onNoteAdd} resetOnSubmit>
{({ change, data, reset, submit }) => (
<TimelineAddNote
message={data.message}
reset={reset}
onChange={change}
onSubmit={submit}
/>
)}
</Form>
{history
.slice()
.reverse()
.map(event => {
if (event.type === OrderEventsEnum.NOTE_ADDED) {
2019-06-19 14:40:52 +00:00
return (
2019-10-30 14:34:24 +00:00
<TimelineNote
2019-06-19 14:40:52 +00:00
date={event.date}
2019-10-30 14:34:24 +00:00
user={event.user}
message={event.message}
2019-06-19 14:40:52 +00:00
key={event.id}
/>
);
2019-10-30 14:34:24 +00:00
}
if (event.type === OrderEventsEnum.ORDER_MARKED_AS_PAID) {
return (
<TimelineEvent
date={event.date}
title={getEventMessage(event, intl)}
secondaryTitle={intl.formatMessage(
{
defaultMessage:
"Transaction Reference {transactionReference}",
description: "transaction reference"
},
{ transactionReference: event.transactionReference }
)}
key={event.id}
/>
);
}
Refunds (#870) * 1721 - add refunds miscellaneous view (#860) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Fix refund details on order details page (#879) * Update order details view for refunds (#874) * 1719 - add refund entry to order history (#875) * Add refund order history entry * Update refund event with the right query * 1722 - add refunds product view (#873) * Create new page for Miscellaneous Refunds * Replace refund order dialog with dedicated page * Add data test ids * Create refund products table * Implement refund products view * Update refund mutation with product lines input * Fix products quantities on refund page * Fix order refund submission * Fix products refund submission input variables * Filter out fulfillments on refund page * Update refund page in storybook * Fix test snapshots after wrong refunds rebase * Set max refund as captured amount * Refund queries adjustments * Display refund values with nullish coalescing operator * Update test snapshots with refunds * Refactor order refund values calculation * Create and use refund order line fragment * Use old simple refund mutation for miscellaneous refund * Submit for refund only lines with non-zero quantity set * Fix showing refund error * Add missing refund amount to order history * Merge repeated order lines in fulfillment lines * Update order history events types and test snapshots * Update changelog with refunds changes
2020-12-01 13:13:05 +00:00
if (event.type === OrderEventsEnum.FULFILLMENT_REFUNDED) {
return (
<TimelineEvent
date={event.date}
title={getEventMessage(event, intl)}
key={event.id}
>
{event.lines && (
<>
<Typography
variant="caption"
color="textSecondary"
className={classes.eventSubtitle}
>
<FormattedMessage defaultMessage="Products refunded" />
</Typography>
<table>
<tbody>
{event.lines.map(line => (
<tr key={line.orderLine.id}>
<td className={classes.linesTableCell}>
{line.orderLine.productName}
</td>
<td className={classes.linesTableCell}>
<Typography
variant="caption"
color="textSecondary"
>
{line.orderLine.variantName}
</Typography>
</td>
<td className={classes.linesTableCell}>
<Typography
variant="caption"
color="textSecondary"
>
{`qty: ${line.quantity}`}
</Typography>
</td>
</tr>
))}
</tbody>
</table>
<Typography
variant="caption"
color="textSecondary"
className={classes.eventSubtitle}
>
<FormattedMessage defaultMessage="Refunded amount" />
</Typography>
{(event.amount || event.amount === 0) && (
<Money
money={{
amount: event.amount,
currency: orderCurrency
}}
/>
)}
{event.shippingCostsIncluded && (
<Typography>
<FormattedMessage defaultMessage="Shipment was refunded" />
</Typography>
)}
</>
)}
</TimelineEvent>
);
}
2019-10-30 14:34:24 +00:00
return (
<TimelineEvent
date={event.date}
title={getEventMessage(event, intl)}
key={event.id}
/>
);
})}
</Timeline>
) : (
<Skeleton />
)}
</div>
);
};
2019-06-19 14:40:52 +00:00
OrderHistory.displayName = "OrderHistory";
export default OrderHistory;