
* 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
92 lines
2.8 KiB
TypeScript
92 lines
2.8 KiB
TypeScript
import { sectionNames } from "@saleor/intl";
|
|
import { asSortParams } from "@saleor/utils/sort";
|
|
import { parse as parseQs } from "qs";
|
|
import React from "react";
|
|
import { useIntl } from "react-intl";
|
|
import { Route, RouteComponentProps, Switch } from "react-router-dom";
|
|
|
|
import { WindowTitle } from "../components/WindowTitle";
|
|
import {
|
|
orderDraftListPath,
|
|
OrderDraftListUrlQueryParams,
|
|
OrderDraftListUrlSortField,
|
|
orderFulfillPath,
|
|
orderListPath,
|
|
OrderListUrlQueryParams,
|
|
OrderListUrlSortField,
|
|
orderPath,
|
|
orderRefundPath,
|
|
orderSettingsPath,
|
|
OrderUrlQueryParams
|
|
} from "./urls";
|
|
import OrderDetailsComponent from "./views/OrderDetails";
|
|
import OrderDraftListComponent from "./views/OrderDraftList";
|
|
import OrderFulfillComponent from "./views/OrderFulfill";
|
|
import OrderListComponent from "./views/OrderList";
|
|
import OrderRefundComponent from "./views/OrderRefund";
|
|
import OrderSettings from "./views/OrderSettings";
|
|
|
|
const OrderList: React.FC<RouteComponentProps<any>> = ({ location }) => {
|
|
const qs = parseQs(location.search.substr(1));
|
|
const params: OrderListUrlQueryParams = asSortParams(
|
|
qs,
|
|
OrderListUrlSortField,
|
|
OrderListUrlSortField.number,
|
|
false
|
|
);
|
|
return <OrderListComponent params={params} />;
|
|
};
|
|
const OrderDraftList: React.FC<RouteComponentProps<any>> = ({ location }) => {
|
|
const qs = parseQs(location.search.substr(1));
|
|
const params: OrderDraftListUrlQueryParams = asSortParams(
|
|
qs,
|
|
OrderDraftListUrlSortField,
|
|
OrderDraftListUrlSortField.number,
|
|
false
|
|
);
|
|
|
|
return <OrderDraftListComponent params={params} />;
|
|
};
|
|
|
|
const OrderDetails: React.FC<RouteComponentProps<any>> = ({
|
|
location,
|
|
match
|
|
}) => {
|
|
const qs = parseQs(location.search.substr(1));
|
|
const params: OrderUrlQueryParams = qs;
|
|
|
|
return (
|
|
<OrderDetailsComponent
|
|
id={decodeURIComponent(match.params.id)}
|
|
params={params}
|
|
/>
|
|
);
|
|
};
|
|
|
|
const OrderFulfill: React.FC<RouteComponentProps<any>> = ({ match }) => (
|
|
<OrderFulfillComponent orderId={decodeURIComponent(match.params.id)} />
|
|
);
|
|
|
|
const OrderRefund: React.FC<RouteComponentProps<any>> = ({ match }) => (
|
|
<OrderRefundComponent orderId={decodeURIComponent(match.params.id)} />
|
|
);
|
|
|
|
const Component = () => {
|
|
const intl = useIntl();
|
|
|
|
return (
|
|
<>
|
|
<WindowTitle title={intl.formatMessage(sectionNames.orders)} />
|
|
<Switch>
|
|
<Route exact path={orderSettingsPath} component={OrderSettings} />
|
|
<Route exact path={orderDraftListPath} component={OrderDraftList} />
|
|
<Route exact path={orderListPath} component={OrderList} />
|
|
<Route path={orderFulfillPath(":id")} component={OrderFulfill} />
|
|
<Route path={orderRefundPath(":id")} component={OrderRefund} />
|
|
<Route path={orderPath(":id")} component={OrderDetails} />
|
|
</Switch>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Component;
|