saleor-dashboard/src/orders/views/OrderDetails/OrderUnconfirmedDetails/index.tsx

382 lines
13 KiB
TypeScript
Raw Normal View History

import { useUser } from "@saleor/auth";
import { WindowTitle } from "@saleor/components/WindowTitle";
import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config";
import useNavigator from "@saleor/hooks/useNavigator";
import OrderCannotCancelOrderDialog from "@saleor/orders/components/OrderCannotCancelOrderDialog";
Introduce fulfillment creation API (#1241) * Display warehouse name for each fulfillment (#1259) * Hide no-stocks columns in fulfillment view (#1260) * Hide no-stocks columns in fulfillment view * Update tests * Refactor * Update tests * Add fulfillment settings card (#1242) * Add fulfillment setting card * Make fulfillment approvement naming consistent * Fix mutation bug * Update types * Trigger CI * Handle fulfillment acceptance on order details page (#1255) * Handle fulfillment acceptance on order details page * Make fulfillment approvement naming consistent * Update fulfillment schema and its usage * Render history events regarding waiting fulfillments (#1265) * Add awaiting for approval fulfillment order event * Fix warehouse name * Change fulfillment quantity calculation (#1267) * Change fulfillment quantity calculation * Fix warehouse name * Update messages * Trigger CI * Refactor * Fix refactor * Fix fulfillment for no variant * Allow creating fulfillments waiting for acceptance (#1248) * Fix fulfillment page style and typescript classname types perfomance issue * Allow creating fulfillments waiting for acceptance * Make fulfillment approvement naming consistent * Update schema * Add tooltip to fulfillment savebar * Update unpaid fulfillment creation restriction * Update fulfillment cration restriction * Update test snapshots * Add possibility to cancel "waiting" fulfillments (#1288) * Allow to cancel waiting fulfillments * Add delete button to fulfillment card * Update test snapshots * Handle waiting fulfillments on refund page (#1290) * Handle waiting fulfillments on refund page * Trigger CI * Trigger CI * Calculate quantity to refund on quantityToFulfill * Update changelog * Update snapshots Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-08-20 14:36:05 +00:00
import OrderFulfillmentApproveDialog from "@saleor/orders/components/OrderFulfillmentApproveDialog";
import OrderInvoiceEmailSendDialog from "@saleor/orders/components/OrderInvoiceEmailSendDialog";
Introduce fulfillment creation API (#1241) * Display warehouse name for each fulfillment (#1259) * Hide no-stocks columns in fulfillment view (#1260) * Hide no-stocks columns in fulfillment view * Update tests * Refactor * Update tests * Add fulfillment settings card (#1242) * Add fulfillment setting card * Make fulfillment approvement naming consistent * Fix mutation bug * Update types * Trigger CI * Handle fulfillment acceptance on order details page (#1255) * Handle fulfillment acceptance on order details page * Make fulfillment approvement naming consistent * Update fulfillment schema and its usage * Render history events regarding waiting fulfillments (#1265) * Add awaiting for approval fulfillment order event * Fix warehouse name * Change fulfillment quantity calculation (#1267) * Change fulfillment quantity calculation * Fix warehouse name * Update messages * Trigger CI * Refactor * Fix refactor * Fix fulfillment for no variant * Allow creating fulfillments waiting for acceptance (#1248) * Fix fulfillment page style and typescript classname types perfomance issue * Allow creating fulfillments waiting for acceptance * Make fulfillment approvement naming consistent * Update schema * Add tooltip to fulfillment savebar * Update unpaid fulfillment creation restriction * Update fulfillment cration restriction * Update test snapshots * Add possibility to cancel "waiting" fulfillments (#1288) * Allow to cancel waiting fulfillments * Add delete button to fulfillment card * Update test snapshots * Handle waiting fulfillments on refund page (#1290) * Handle waiting fulfillments on refund page * Trigger CI * Trigger CI * Calculate quantity to refund on quantityToFulfill * Update changelog * Update snapshots Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-08-20 14:36:05 +00:00
import {
OrderFulfillmentApprove,
OrderFulfillmentApproveVariables
} from "@saleor/orders/types/OrderFulfillmentApprove";
import { OrderDiscountProvider } from "@saleor/products/components/OrderDiscountProviders/OrderDiscountProvider";
import { OrderLineDiscountProvider } from "@saleor/products/components/OrderDiscountProviders/OrderLineDiscountProvider";
Introduce fulfillment creation API (#1241) * Display warehouse name for each fulfillment (#1259) * Hide no-stocks columns in fulfillment view (#1260) * Hide no-stocks columns in fulfillment view * Update tests * Refactor * Update tests * Add fulfillment settings card (#1242) * Add fulfillment setting card * Make fulfillment approvement naming consistent * Fix mutation bug * Update types * Trigger CI * Handle fulfillment acceptance on order details page (#1255) * Handle fulfillment acceptance on order details page * Make fulfillment approvement naming consistent * Update fulfillment schema and its usage * Render history events regarding waiting fulfillments (#1265) * Add awaiting for approval fulfillment order event * Fix warehouse name * Change fulfillment quantity calculation (#1267) * Change fulfillment quantity calculation * Fix warehouse name * Update messages * Trigger CI * Refactor * Fix refactor * Fix fulfillment for no variant * Allow creating fulfillments waiting for acceptance (#1248) * Fix fulfillment page style and typescript classname types perfomance issue * Allow creating fulfillments waiting for acceptance * Make fulfillment approvement naming consistent * Update schema * Add tooltip to fulfillment savebar * Update unpaid fulfillment creation restriction * Update fulfillment cration restriction * Update test snapshots * Add possibility to cancel "waiting" fulfillments (#1288) * Allow to cancel waiting fulfillments * Add delete button to fulfillment card * Update test snapshots * Handle waiting fulfillments on refund page (#1290) * Handle waiting fulfillments on refund page * Trigger CI * Trigger CI * Calculate quantity to refund on quantityToFulfill * Update changelog * Update snapshots Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-08-20 14:36:05 +00:00
import { PartialMutationProviderOutput } from "@saleor/types";
import { mapEdgesToItems } from "@saleor/utils/maps";
import { useWarehouseList } from "@saleor/warehouses/queries";
import React from "react";
import { useIntl } from "react-intl";
import { customerUrl } from "../../../../customers/urls";
2021-04-02 04:28:28 +00:00
import { getMutationState, getStringOrPlaceholder } from "../../../../misc";
import { productUrl } from "../../../../products/urls";
import { FulfillmentStatus } from "../../../../types/globalTypes";
import OrderCancelDialog from "../../../components/OrderCancelDialog";
import OrderDetailsPage from "../../../components/OrderDetailsPage";
import OrderFulfillmentCancelDialog from "../../../components/OrderFulfillmentCancelDialog";
import OrderFulfillmentTrackingDialog from "../../../components/OrderFulfillmentTrackingDialog";
import OrderMarkAsPaidDialog from "../../../components/OrderMarkAsPaidDialog/OrderMarkAsPaidDialog";
import OrderPaymentDialog from "../../../components/OrderPaymentDialog";
import OrderPaymentVoidDialog from "../../../components/OrderPaymentVoidDialog";
import OrderProductAddDialog from "../../../components/OrderProductAddDialog";
import OrderShippingMethodEditDialog from "../../../components/OrderShippingMethodEditDialog";
import { useOrderVariantSearch } from "../../../queries";
import {
orderFulfillUrl,
orderListUrl,
orderRefundUrl,
orderReturnPath,
orderUrl,
OrderUrlQueryParams
} from "../../../urls";
interface OrderUnconfirmedDetailsProps {
id: string;
params: OrderUrlQueryParams;
data: any;
orderAddNote: any;
orderLineUpdate: any;
orderLineDelete: any;
orderInvoiceRequest: any;
handleSubmit: any;
orderCancel: any;
orderShippingMethodUpdate: any;
orderLinesAdd: any;
orderPaymentMarkAsPaid: any;
orderVoid: any;
orderPaymentCapture: any;
Introduce fulfillment creation API (#1241) * Display warehouse name for each fulfillment (#1259) * Hide no-stocks columns in fulfillment view (#1260) * Hide no-stocks columns in fulfillment view * Update tests * Refactor * Update tests * Add fulfillment settings card (#1242) * Add fulfillment setting card * Make fulfillment approvement naming consistent * Fix mutation bug * Update types * Trigger CI * Handle fulfillment acceptance on order details page (#1255) * Handle fulfillment acceptance on order details page * Make fulfillment approvement naming consistent * Update fulfillment schema and its usage * Render history events regarding waiting fulfillments (#1265) * Add awaiting for approval fulfillment order event * Fix warehouse name * Change fulfillment quantity calculation (#1267) * Change fulfillment quantity calculation * Fix warehouse name * Update messages * Trigger CI * Refactor * Fix refactor * Fix fulfillment for no variant * Allow creating fulfillments waiting for acceptance (#1248) * Fix fulfillment page style and typescript classname types perfomance issue * Allow creating fulfillments waiting for acceptance * Make fulfillment approvement naming consistent * Update schema * Add tooltip to fulfillment savebar * Update unpaid fulfillment creation restriction * Update fulfillment cration restriction * Update test snapshots * Add possibility to cancel "waiting" fulfillments (#1288) * Allow to cancel waiting fulfillments * Add delete button to fulfillment card * Update test snapshots * Handle waiting fulfillments on refund page (#1290) * Handle waiting fulfillments on refund page * Trigger CI * Trigger CI * Calculate quantity to refund on quantityToFulfill * Update changelog * Update snapshots Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-08-20 14:36:05 +00:00
orderFulfillmentApprove: PartialMutationProviderOutput<
OrderFulfillmentApprove,
OrderFulfillmentApproveVariables
>;
orderFulfillmentCancel: any;
orderFulfillmentUpdateTracking: any;
orderInvoiceSend: any;
updateMetadataOpts: any;
updatePrivateMetadataOpts: any;
openModal: any;
closeModal: any;
}
export const OrderUnconfirmedDetails: React.FC<OrderUnconfirmedDetailsProps> = ({
id,
params,
data,
orderAddNote,
orderLineUpdate,
orderLineDelete,
orderInvoiceRequest,
handleSubmit,
orderCancel,
orderShippingMethodUpdate,
orderLinesAdd,
orderPaymentMarkAsPaid,
orderVoid,
orderPaymentCapture,
Introduce fulfillment creation API (#1241) * Display warehouse name for each fulfillment (#1259) * Hide no-stocks columns in fulfillment view (#1260) * Hide no-stocks columns in fulfillment view * Update tests * Refactor * Update tests * Add fulfillment settings card (#1242) * Add fulfillment setting card * Make fulfillment approvement naming consistent * Fix mutation bug * Update types * Trigger CI * Handle fulfillment acceptance on order details page (#1255) * Handle fulfillment acceptance on order details page * Make fulfillment approvement naming consistent * Update fulfillment schema and its usage * Render history events regarding waiting fulfillments (#1265) * Add awaiting for approval fulfillment order event * Fix warehouse name * Change fulfillment quantity calculation (#1267) * Change fulfillment quantity calculation * Fix warehouse name * Update messages * Trigger CI * Refactor * Fix refactor * Fix fulfillment for no variant * Allow creating fulfillments waiting for acceptance (#1248) * Fix fulfillment page style and typescript classname types perfomance issue * Allow creating fulfillments waiting for acceptance * Make fulfillment approvement naming consistent * Update schema * Add tooltip to fulfillment savebar * Update unpaid fulfillment creation restriction * Update fulfillment cration restriction * Update test snapshots * Add possibility to cancel "waiting" fulfillments (#1288) * Allow to cancel waiting fulfillments * Add delete button to fulfillment card * Update test snapshots * Handle waiting fulfillments on refund page (#1290) * Handle waiting fulfillments on refund page * Trigger CI * Trigger CI * Calculate quantity to refund on quantityToFulfill * Update changelog * Update snapshots Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-08-20 14:36:05 +00:00
orderFulfillmentApprove,
orderFulfillmentCancel,
orderFulfillmentUpdateTracking,
orderInvoiceSend,
updateMetadataOpts,
updatePrivateMetadataOpts,
openModal,
closeModal
}) => {
const order = data.order;
Introduce fulfillment creation API (#1241) * Display warehouse name for each fulfillment (#1259) * Hide no-stocks columns in fulfillment view (#1260) * Hide no-stocks columns in fulfillment view * Update tests * Refactor * Update tests * Add fulfillment settings card (#1242) * Add fulfillment setting card * Make fulfillment approvement naming consistent * Fix mutation bug * Update types * Trigger CI * Handle fulfillment acceptance on order details page (#1255) * Handle fulfillment acceptance on order details page * Make fulfillment approvement naming consistent * Update fulfillment schema and its usage * Render history events regarding waiting fulfillments (#1265) * Add awaiting for approval fulfillment order event * Fix warehouse name * Change fulfillment quantity calculation (#1267) * Change fulfillment quantity calculation * Fix warehouse name * Update messages * Trigger CI * Refactor * Fix refactor * Fix fulfillment for no variant * Allow creating fulfillments waiting for acceptance (#1248) * Fix fulfillment page style and typescript classname types perfomance issue * Allow creating fulfillments waiting for acceptance * Make fulfillment approvement naming consistent * Update schema * Add tooltip to fulfillment savebar * Update unpaid fulfillment creation restriction * Update fulfillment cration restriction * Update test snapshots * Add possibility to cancel "waiting" fulfillments (#1288) * Allow to cancel waiting fulfillments * Add delete button to fulfillment card * Update test snapshots * Handle waiting fulfillments on refund page (#1290) * Handle waiting fulfillments on refund page * Trigger CI * Trigger CI * Calculate quantity to refund on quantityToFulfill * Update changelog * Update snapshots Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-08-20 14:36:05 +00:00
const shop = data.shop;
const navigate = useNavigator();
const { user } = useUser();
const {
loadMore,
search: variantSearch,
result: variantSearchOpts
} = useOrderVariantSearch({
variables: { ...DEFAULT_INITIAL_SEARCH_DATA, channel: order.channel.slug }
});
const warehouses = useWarehouseList({
displayLoader: true,
variables: {
first: 30
}
});
const intl = useIntl();
const [transactionReference, setTransactionReference] = React.useState("");
const handleBack = () => navigate(orderListUrl());
return (
<>
<WindowTitle
title={intl.formatMessage(
{
defaultMessage: "Order #{orderNumber}",
description: "window title"
},
{
orderNumber: getStringOrPlaceholder(order.number)
}
)}
/>
<OrderDiscountProvider order={order}>
<OrderLineDiscountProvider order={order}>
<OrderDetailsPage
onOrderReturn={() => navigate(orderReturnPath(id))}
disabled={
updateMetadataOpts.loading || updatePrivateMetadataOpts.loading
}
onNoteAdd={variables =>
orderAddNote.mutate({
input: variables,
order: id
})
}
onBack={handleBack}
order={order}
Introduce fulfillment creation API (#1241) * Display warehouse name for each fulfillment (#1259) * Hide no-stocks columns in fulfillment view (#1260) * Hide no-stocks columns in fulfillment view * Update tests * Refactor * Update tests * Add fulfillment settings card (#1242) * Add fulfillment setting card * Make fulfillment approvement naming consistent * Fix mutation bug * Update types * Trigger CI * Handle fulfillment acceptance on order details page (#1255) * Handle fulfillment acceptance on order details page * Make fulfillment approvement naming consistent * Update fulfillment schema and its usage * Render history events regarding waiting fulfillments (#1265) * Add awaiting for approval fulfillment order event * Fix warehouse name * Change fulfillment quantity calculation (#1267) * Change fulfillment quantity calculation * Fix warehouse name * Update messages * Trigger CI * Refactor * Fix refactor * Fix fulfillment for no variant * Allow creating fulfillments waiting for acceptance (#1248) * Fix fulfillment page style and typescript classname types perfomance issue * Allow creating fulfillments waiting for acceptance * Make fulfillment approvement naming consistent * Update schema * Add tooltip to fulfillment savebar * Update unpaid fulfillment creation restriction * Update fulfillment cration restriction * Update test snapshots * Add possibility to cancel "waiting" fulfillments (#1288) * Allow to cancel waiting fulfillments * Add delete button to fulfillment card * Update test snapshots * Handle waiting fulfillments on refund page (#1290) * Handle waiting fulfillments on refund page * Trigger CI * Trigger CI * Calculate quantity to refund on quantityToFulfill * Update changelog * Update snapshots Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-08-20 14:36:05 +00:00
shop={shop}
onOrderLineAdd={() => openModal("add-order-line")}
onOrderLineChange={(id, data) =>
orderLineUpdate.mutate({
id,
input: data
})
}
onOrderLineRemove={id => orderLineDelete.mutate({ id })}
onShippingMethodEdit={() => openModal("edit-shipping")}
saveButtonBarState={getMutationState(
updateMetadataOpts.called || updatePrivateMetadataOpts.called,
updateMetadataOpts.loading || updatePrivateMetadataOpts.loading,
[
...(updateMetadataOpts.data?.deleteMetadata.errors || []),
...(updateMetadataOpts.data?.updateMetadata.errors || []),
...(updatePrivateMetadataOpts.data?.deletePrivateMetadata
.errors || []),
...(updatePrivateMetadataOpts.data?.updatePrivateMetadata
.errors || [])
]
)}
shippingMethods={data?.order?.shippingMethods || []}
userPermissions={user?.userPermissions || []}
onOrderCancel={() => openModal("cancel")}
onOrderFulfill={() => navigate(orderFulfillUrl(id))}
Introduce fulfillment creation API (#1241) * Display warehouse name for each fulfillment (#1259) * Hide no-stocks columns in fulfillment view (#1260) * Hide no-stocks columns in fulfillment view * Update tests * Refactor * Update tests * Add fulfillment settings card (#1242) * Add fulfillment setting card * Make fulfillment approvement naming consistent * Fix mutation bug * Update types * Trigger CI * Handle fulfillment acceptance on order details page (#1255) * Handle fulfillment acceptance on order details page * Make fulfillment approvement naming consistent * Update fulfillment schema and its usage * Render history events regarding waiting fulfillments (#1265) * Add awaiting for approval fulfillment order event * Fix warehouse name * Change fulfillment quantity calculation (#1267) * Change fulfillment quantity calculation * Fix warehouse name * Update messages * Trigger CI * Refactor * Fix refactor * Fix fulfillment for no variant * Allow creating fulfillments waiting for acceptance (#1248) * Fix fulfillment page style and typescript classname types perfomance issue * Allow creating fulfillments waiting for acceptance * Make fulfillment approvement naming consistent * Update schema * Add tooltip to fulfillment savebar * Update unpaid fulfillment creation restriction * Update fulfillment cration restriction * Update test snapshots * Add possibility to cancel "waiting" fulfillments (#1288) * Allow to cancel waiting fulfillments * Add delete button to fulfillment card * Update test snapshots * Handle waiting fulfillments on refund page (#1290) * Handle waiting fulfillments on refund page * Trigger CI * Trigger CI * Calculate quantity to refund on quantityToFulfill * Update changelog * Update snapshots Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-08-20 14:36:05 +00:00
onFulfillmentApprove={fulfillmentId =>
navigate(
orderUrl(id, {
action: "approve-fulfillment",
id: fulfillmentId
})
)
}
onFulfillmentCancel={fulfillmentId =>
navigate(
orderUrl(id, {
action: "cancel-fulfillment",
id: fulfillmentId
})
)
}
onFulfillmentTrackingNumberUpdate={fulfillmentId =>
navigate(
orderUrl(id, {
action: "edit-fulfillment",
id: fulfillmentId
})
)
}
onPaymentCapture={() => openModal("capture")}
onPaymentVoid={() => openModal("void")}
onPaymentRefund={() => navigate(orderRefundUrl(id))}
onProductClick={id => () => navigate(productUrl(id))}
onBillingAddressEdit={() => openModal("edit-billing-address")}
onShippingAddressEdit={() => openModal("edit-shipping-address")}
onPaymentPaid={() => openModal("mark-paid")}
onProfileView={() => navigate(customerUrl(order.user.id))}
onInvoiceClick={id =>
window.open(
order.invoices.find(invoice => invoice.id === id)?.url,
"_blank"
)
}
onInvoiceGenerate={() =>
orderInvoiceRequest.mutate({
orderId: id
})
}
onInvoiceSend={id => openModal("invoice-send", { id })}
onSubmit={handleSubmit}
/>
</OrderLineDiscountProvider>
</OrderDiscountProvider>
<OrderCannotCancelOrderDialog
onClose={closeModal}
open={
params.action === "cancel" &&
order?.fulfillments.some(
fulfillment => fulfillment.status === FulfillmentStatus.FULFILLED
)
}
/>
<OrderCancelDialog
confirmButtonState={orderCancel.opts.status}
errors={orderCancel.opts.data?.orderCancel.errors || []}
number={order?.number}
open={params.action === "cancel"}
onClose={closeModal}
onSubmit={() =>
orderCancel.mutate({
id
})
}
/>
<OrderShippingMethodEditDialog
confirmButtonState={orderShippingMethodUpdate.opts.status}
errors={
orderShippingMethodUpdate.opts.data?.orderUpdateShipping.errors || []
}
open={params.action === "edit-shipping"}
shippingMethod={order?.shippingMethod?.id}
shippingMethods={order?.shippingMethods}
onClose={closeModal}
onSubmit={variables =>
orderShippingMethodUpdate.mutate({
id,
input: {
shippingMethod: variables.shippingMethod
}
})
}
/>
<OrderProductAddDialog
confirmButtonState={orderLinesAdd.opts.status}
errors={orderLinesAdd.opts.data?.orderLinesCreate.errors || []}
loading={variantSearchOpts.loading}
open={params.action === "add-order-line"}
hasMore={variantSearchOpts.data?.search.pageInfo.hasNextPage}
products={mapEdgesToItems(variantSearchOpts?.data?.search)}
selectedChannelId={order?.channel?.id}
onClose={closeModal}
onFetch={variantSearch}
onFetchMore={loadMore}
onSubmit={variants =>
orderLinesAdd.mutate({
id,
input: variants.map(variant => ({
quantity: 1,
variantId: variant.id
}))
})
}
/>
<OrderMarkAsPaidDialog
confirmButtonState={orderPaymentMarkAsPaid.opts.status}
errors={orderPaymentMarkAsPaid.opts.data?.orderMarkAsPaid.errors || []}
onClose={closeModal}
onConfirm={() =>
orderPaymentMarkAsPaid.mutate({
id,
transactionReference
})
}
open={params.action === "mark-paid"}
transactionReference={transactionReference}
handleTransactionReference={({ target }) =>
setTransactionReference(target.value)
}
/>
<OrderPaymentVoidDialog
confirmButtonState={orderVoid.opts.status}
errors={orderVoid.opts.data?.orderVoid.errors || []}
open={params.action === "void"}
onClose={closeModal}
onConfirm={() => orderVoid.mutate({ id })}
/>
<OrderPaymentDialog
confirmButtonState={orderPaymentCapture.opts.status}
errors={orderPaymentCapture.opts.data?.orderCapture.errors || []}
initial={order?.total.gross.amount}
open={params.action === "capture"}
onClose={closeModal}
onSubmit={variables =>
orderPaymentCapture.mutate({
...variables,
id
})
}
/>
Introduce fulfillment creation API (#1241) * Display warehouse name for each fulfillment (#1259) * Hide no-stocks columns in fulfillment view (#1260) * Hide no-stocks columns in fulfillment view * Update tests * Refactor * Update tests * Add fulfillment settings card (#1242) * Add fulfillment setting card * Make fulfillment approvement naming consistent * Fix mutation bug * Update types * Trigger CI * Handle fulfillment acceptance on order details page (#1255) * Handle fulfillment acceptance on order details page * Make fulfillment approvement naming consistent * Update fulfillment schema and its usage * Render history events regarding waiting fulfillments (#1265) * Add awaiting for approval fulfillment order event * Fix warehouse name * Change fulfillment quantity calculation (#1267) * Change fulfillment quantity calculation * Fix warehouse name * Update messages * Trigger CI * Refactor * Fix refactor * Fix fulfillment for no variant * Allow creating fulfillments waiting for acceptance (#1248) * Fix fulfillment page style and typescript classname types perfomance issue * Allow creating fulfillments waiting for acceptance * Make fulfillment approvement naming consistent * Update schema * Add tooltip to fulfillment savebar * Update unpaid fulfillment creation restriction * Update fulfillment cration restriction * Update test snapshots * Add possibility to cancel "waiting" fulfillments (#1288) * Allow to cancel waiting fulfillments * Add delete button to fulfillment card * Update test snapshots * Handle waiting fulfillments on refund page (#1290) * Handle waiting fulfillments on refund page * Trigger CI * Trigger CI * Calculate quantity to refund on quantityToFulfill * Update changelog * Update snapshots Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-08-20 14:36:05 +00:00
<OrderFulfillmentApproveDialog
confirmButtonState={orderFulfillmentApprove.opts.status}
errors={
orderFulfillmentApprove.opts.data?.orderFulfillmentApprove.errors ||
[]
}
open={params.action === "approve-fulfillment"}
onConfirm={({ notifyCustomer }) =>
orderFulfillmentApprove.mutate({
id: params.id,
notifyCustomer
})
}
onClose={closeModal}
/>
<OrderFulfillmentCancelDialog
confirmButtonState={orderFulfillmentCancel.opts.status}
errors={
orderFulfillmentCancel.opts.data?.orderFulfillmentCancel.errors || []
}
open={params.action === "cancel-fulfillment"}
warehouses={mapEdgesToItems(warehouses?.data?.warehouses)}
onConfirm={variables =>
orderFulfillmentCancel.mutate({
id: params.id,
input: variables
})
}
onClose={closeModal}
/>
<OrderFulfillmentTrackingDialog
confirmButtonState={orderFulfillmentUpdateTracking.opts.status}
errors={
orderFulfillmentUpdateTracking.opts.data
?.orderFulfillmentUpdateTracking.errors || []
}
open={params.action === "edit-fulfillment"}
trackingNumber={getStringOrPlaceholder(
data?.order?.fulfillments.find(
fulfillment => fulfillment.id === params.id
)?.trackingNumber
)}
onConfirm={variables =>
orderFulfillmentUpdateTracking.mutate({
id: params.id,
input: {
...variables,
notifyCustomer: true
}
})
}
onClose={closeModal}
/>
<OrderInvoiceEmailSendDialog
confirmButtonState={orderInvoiceSend.opts.status}
errors={orderInvoiceSend.opts.data?.invoiceSendEmail.errors || []}
open={params.action === "invoice-send"}
invoice={order?.invoices?.find(invoice => invoice.id === params.id)}
onClose={closeModal}
onSend={() => orderInvoiceSend.mutate({ id: params.id })}
/>
</>
);
};
export default OrderUnconfirmedDetails;