Add returned products to refund page
This commit is contained in:
parent
b894487c63
commit
6608ac8122
3 changed files with 21 additions and 7 deletions
|
@ -17,6 +17,7 @@ import TableCellAvatar from "@saleor/components/TableCellAvatar";
|
||||||
import { FormsetChange } from "@saleor/hooks/useFormset";
|
import { FormsetChange } from "@saleor/hooks/useFormset";
|
||||||
import { renderCollection } from "@saleor/misc";
|
import { renderCollection } from "@saleor/misc";
|
||||||
import { OrderRefundData_order_fulfillments } from "@saleor/orders/types/OrderRefundData";
|
import { OrderRefundData_order_fulfillments } from "@saleor/orders/types/OrderRefundData";
|
||||||
|
import { FulfillmentStatus } from "@saleor/types/globalTypes";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
|
||||||
|
@ -91,10 +92,15 @@ const OrderRefundFulfilledProducts: React.FC<OrderRefundFulfilledProductsProps>
|
||||||
<CardTitle
|
<CardTitle
|
||||||
title={
|
title={
|
||||||
<>
|
<>
|
||||||
{intl.formatMessage({
|
{fulfillment.status === FulfillmentStatus.RETURNED
|
||||||
defaultMessage: "Fulfillment",
|
? intl.formatMessage({
|
||||||
description: "section header"
|
defaultMessage: "Fulfillment returned",
|
||||||
})}
|
description: "section header returned"
|
||||||
|
})
|
||||||
|
: intl.formatMessage({
|
||||||
|
defaultMessage: "Fulfillment",
|
||||||
|
description: "section header"
|
||||||
|
})}
|
||||||
{fulfillment && (
|
{fulfillment && (
|
||||||
<Typography className={classes.orderNumber} variant="body1">
|
<Typography className={classes.orderNumber} variant="body1">
|
||||||
{`#${orderNumber}-${fulfillment?.fulfillmentOrder}`}
|
{`#${orderNumber}-${fulfillment?.fulfillmentOrder}`}
|
||||||
|
|
|
@ -24,6 +24,11 @@ import OrderRefundForm, {
|
||||||
OrderRefundType
|
OrderRefundType
|
||||||
} from "./form";
|
} from "./form";
|
||||||
|
|
||||||
|
export const refundFulfilledStatuses = [
|
||||||
|
FulfillmentStatus.FULFILLED,
|
||||||
|
FulfillmentStatus.RETURNED
|
||||||
|
];
|
||||||
|
|
||||||
export interface OrderRefundPageProps {
|
export interface OrderRefundPageProps {
|
||||||
order: OrderRefundData_order;
|
order: OrderRefundData_order;
|
||||||
defaultType?: OrderRefundType;
|
defaultType?: OrderRefundType;
|
||||||
|
@ -48,9 +53,10 @@ const OrderRefundPage: React.FC<OrderRefundPageProps> = props => {
|
||||||
const unfulfilledLines = order?.lines.filter(
|
const unfulfilledLines = order?.lines.filter(
|
||||||
line => line.quantity !== line.quantityFulfilled
|
line => line.quantity !== line.quantityFulfilled
|
||||||
);
|
);
|
||||||
|
|
||||||
const fulfilledFulfillemnts =
|
const fulfilledFulfillemnts =
|
||||||
order?.fulfillments.filter(
|
order?.fulfillments.filter(({ status }) =>
|
||||||
fulfillment => fulfillment.status === FulfillmentStatus.FULFILLED
|
refundFulfilledStatuses.includes(status)
|
||||||
) || [];
|
) || [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -8,6 +8,8 @@ import { FulfillmentStatus } from "@saleor/types/globalTypes";
|
||||||
import handleFormSubmit from "@saleor/utils/handlers/handleFormSubmit";
|
import handleFormSubmit from "@saleor/utils/handlers/handleFormSubmit";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
|
import { refundFulfilledStatuses } from "./OrderRefundPage";
|
||||||
|
|
||||||
export enum OrderRefundType {
|
export enum OrderRefundType {
|
||||||
MISCELLANEOUS = "miscellaneous",
|
MISCELLANEOUS = "miscellaneous",
|
||||||
PRODUCTS = "products"
|
PRODUCTS = "products"
|
||||||
|
@ -87,7 +89,7 @@ function useOrderRefundForm(
|
||||||
);
|
);
|
||||||
const refundedFulfilledProductQuantities = useFormset<null, string>(
|
const refundedFulfilledProductQuantities = useFormset<null, string>(
|
||||||
order?.fulfillments
|
order?.fulfillments
|
||||||
.filter(fulfillment => fulfillment.status === FulfillmentStatus.FULFILLED)
|
.filter(({ status }) => refundFulfilledStatuses.includes(status))
|
||||||
.reduce(
|
.reduce(
|
||||||
(linesQty, fulfillemnt) =>
|
(linesQty, fulfillemnt) =>
|
||||||
linesQty.concat(
|
linesQty.concat(
|
||||||
|
|
Loading…
Reference in a new issue