2020-09-01 16:22:54 +00:00
|
|
|
import { MetadataFormData } from "@saleor/components/Metadata";
|
2020-05-14 09:30:32 +00:00
|
|
|
import NotFoundPage from "@saleor/components/NotFoundPage";
|
2019-06-19 14:40:52 +00:00
|
|
|
import { WindowTitle } from "@saleor/components/WindowTitle";
|
2019-11-21 14:59:06 +00:00
|
|
|
import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config";
|
2020-06-26 17:06:48 +00:00
|
|
|
import { Task } from "@saleor/containers/BackgroundTasks/types";
|
|
|
|
import useBackgroundTask from "@saleor/hooks/useBackgroundTask";
|
2019-06-19 14:40:52 +00:00
|
|
|
import useNavigator from "@saleor/hooks/useNavigator";
|
2020-09-01 16:22:54 +00:00
|
|
|
import useNotifier from "@saleor/hooks/useNotifier";
|
2019-10-09 10:18:44 +00:00
|
|
|
import useUser from "@saleor/hooks/useUser";
|
2020-09-01 16:22:54 +00:00
|
|
|
import { commonMessages } from "@saleor/intl";
|
2020-05-14 09:30:32 +00:00
|
|
|
import OrderCannotCancelOrderDialog from "@saleor/orders/components/OrderCannotCancelOrderDialog";
|
2020-06-24 15:29:13 +00:00
|
|
|
import OrderInvoiceEmailSendDialog from "@saleor/orders/components/OrderInvoiceEmailSendDialog";
|
2020-11-30 13:19:57 +00:00
|
|
|
import { useOrderConfirmMutation } from "@saleor/orders/mutations";
|
2020-06-26 17:06:48 +00:00
|
|
|
import { InvoiceRequest } from "@saleor/orders/types/InvoiceRequest";
|
2019-11-19 16:32:35 +00:00
|
|
|
import useCustomerSearch from "@saleor/searches/useCustomerSearch";
|
2020-11-30 13:19:57 +00:00
|
|
|
import getOrderErrorMessage from "@saleor/utils/errors/order";
|
2019-12-06 14:58:28 +00:00
|
|
|
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
|
2020-09-01 16:22:54 +00:00
|
|
|
import createMetadataUpdateHandler from "@saleor/utils/handlers/metadataUpdateHandler";
|
|
|
|
import {
|
|
|
|
useMetadataUpdate,
|
|
|
|
usePrivateMetadataUpdate
|
|
|
|
} from "@saleor/utils/metadata/updateMetadata";
|
2020-04-27 14:26:57 +00:00
|
|
|
import { useWarehouseList } from "@saleor/warehouses/queries";
|
2020-05-14 09:30:32 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useIntl } from "react-intl";
|
|
|
|
|
2019-06-19 14:40:52 +00:00
|
|
|
import { customerUrl } from "../../../customers/urls";
|
2020-10-29 11:59:48 +00:00
|
|
|
import { getMutationState, getStringOrPlaceholder, maybe } from "../../../misc";
|
2019-06-19 14:40:52 +00:00
|
|
|
import { productUrl } from "../../../products/urls";
|
2020-06-26 17:06:48 +00:00
|
|
|
import {
|
|
|
|
FulfillmentStatus,
|
|
|
|
JobStatusEnum,
|
2020-07-02 10:54:15 +00:00
|
|
|
OrderStatus
|
2020-06-26 17:06:48 +00:00
|
|
|
} from "../../../types/globalTypes";
|
2019-06-19 14:40:52 +00:00
|
|
|
import OrderCancelDialog from "../../components/OrderCancelDialog";
|
|
|
|
import OrderDetailsPage from "../../components/OrderDetailsPage";
|
|
|
|
import OrderDraftCancelDialog from "../../components/OrderDraftCancelDialog/OrderDraftCancelDialog";
|
|
|
|
import OrderDraftPage from "../../components/OrderDraftPage";
|
|
|
|
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 OrderOperations from "../../containers/OrderOperations";
|
2019-11-20 10:24:42 +00:00
|
|
|
import { TypedOrderDetailsQuery, useOrderVariantSearch } from "../../queries";
|
2019-06-19 14:40:52 +00:00
|
|
|
import {
|
2020-10-08 10:39:26 +00:00
|
|
|
orderDraftListUrl,
|
2020-05-14 09:30:32 +00:00
|
|
|
orderFulfillUrl,
|
2019-06-19 14:40:52 +00:00
|
|
|
orderListUrl,
|
2020-12-01 13:13:05 +00:00
|
|
|
orderRefundUrl,
|
2021-01-20 16:16:43 +00:00
|
|
|
orderReturnPath,
|
2019-06-19 14:40:52 +00:00
|
|
|
orderUrl,
|
2020-04-20 17:18:20 +00:00
|
|
|
OrderUrlDialog,
|
2020-07-02 10:54:15 +00:00
|
|
|
OrderUrlQueryParams
|
2019-06-19 14:40:52 +00:00
|
|
|
} from "../../urls";
|
2020-10-29 11:59:48 +00:00
|
|
|
import OrderAddressFields from "./OrderAddressFields";
|
2019-06-19 14:40:52 +00:00
|
|
|
import { OrderDetailsMessages } from "./OrderDetailsMessages";
|
|
|
|
|
|
|
|
interface OrderDetailsProps {
|
|
|
|
id: string;
|
|
|
|
params: OrderUrlQueryParams;
|
|
|
|
}
|
|
|
|
|
2019-11-07 11:34:54 +00:00
|
|
|
export const OrderDetails: React.FC<OrderDetailsProps> = ({ id, params }) => {
|
2019-06-19 14:40:52 +00:00
|
|
|
const navigate = useNavigator();
|
2019-10-09 10:18:44 +00:00
|
|
|
const { user } = useUser();
|
Multichannel (#833)
* add multichannel to configuration view
* create multichannels list view
* create multichannels list view
* add ChannelsCreate view
* update channels in configuration
* add stories
* update default messages
* fix ChannelForm props
* update channels list styles
* update snapshots
* update channel form currency input
* update Channels fragments
* extract messages
* remove tabs from channelsList
* channel details, channel delete modal (#598)
* create Channel details view
* create ChannelDeleteDialog
* add channels delete dialog to channels list
* update messages and types
* fixes after review
* channels availability (#609)
* create Channel details view
* update messages and types
* create ChannelsAvailability component
* create more product channels components
* create channels stories, update fixtures, types
* update product views with channels data
* update schema and snapshots
* update defaultMessages
* update ProductUpdate view
* create ChannelsAvailabilityDropdown component
* add product channels to local storage
* update globalTypes
* Update to new schema and resolve issues
* Update messages
* create deleteChannel mutation
* add channels availability component to product create view
* refactor ProductCreate and ProductUpdate views
* CollectionProducts view cleanup
* add disabled prop to ActionDialog
* use updateChannels mutation in ProductCreate view
* ProductCreate - update submit function
* fixes after review
* update snapshots and messages
Co-authored-by: Krzysztof Wolski <krzysztof.k.wolski@gmail.com>
* channels shipping components (#655)
* create PricingCard, OrderValue and OrderWeight components
* create ShippingZoneRatesPage and DeleteShippingRateDialog
* update ChannelsAvailability component
* updates after review
* channels shipping views (#662)
* update ChannelsAvailability component
* updates after review
* create PriceRate views, update types
* create weight rates views
* update shipping views, stories, messages
* update snapshots
* update snapshots
* update useChannels hook
* orders channels components (#698)
* create OrderChannelSectionCard component
* update OrderDetailsPage
* update DraftOrderChannelCard
* update snapshots
* update fixtures
* small change after review, update snapshots
* product pricing (#702)
* update product types
* update Pricing in simple product view
* use productVariantCreate mutation in simple product view
* update snapshots and messages
* handle create variant (#715)
* update product types
* update Pricing in simple product view
* handle product create and update errors
* update snapshots and messages
* fix update and create product handlers
* update pricing types
* channels modal - new styles, search input (#717)
* update product types
* update Pricing in simple product view
* handle product create and update errors
* update pricing types
* add search input in ChannelsAvailabilityDialog
* update ChannelsAvailabilityDialog in all views
* update snapshots
* fix search input label styles
* update toggleAllChannels function
* update variant creator (#724)
* update product types
* update Pricing in simple product view
* handle product create and update errors
* update pricing types
* add search input in ChannelsAvailabilityDialog
* update ChannelsAvailabilityDialog in all views
* update snapshots
* add channelLisitngs to variant creator
* update variant creator price styles
* update product variant creator reducer tests
* update createVariants tests
* update error handling in product variant creator
* add Skip pricing for now option
* use PriceField instead of TextField in ProductVariantCreatorSummary
* create price validation function
* fix errors handling in ProductVariantPrice component
* fixes after review
* Product List - remove publish/unpublish buttons (#727)
* ProductList - remove publish and unpublish buttons
* update messages
* update snapshots, messages
* revert changes in ChannelsAvailabilityDropdown
* products/shipping/discount list settings (#739)
* create ChannelSettingsDialog component
* update snapshots
* ProductList - open settings modal when there is no selected channel
* add settings modal to vouchers list
* add settings dialog to sales list
* add setting modal to shipping list
* update shipping
* update snapshots, messages
* useChannelsSettings - remove selectedChannelSlug
* fix channels update handler in product and shipping view
* messages update in ChannelSettingsDialog
* handle product/discount list when there is no channels
* update onSettingsOpen prop
* collection availability dropdown (#743)
* add availability dropdown to collection products list
* update channelListingProduct fragment name
* update voucher view/components with channels (#746)
* update voucher view/components with channels
* update VoucherSummary, remove defaultCurrency from voucher components
* update snapshots
* move getChannelsVariables func to discounts handlers
* update voucher messages
* sale view/components with channels (#750)
* update sale views with channels
* small fixes in discounts
* order views with channels (#752)
* update draft orders with channels
* add channel activate/deactivate mutations
* remove sort by total in orders list
* add error notification on channel activate/deactivate
* product variants channel select (#755)
* add channels selector to ProductVariants component
* remove selectedChannel from ProductUpdate, update messages and snapshots
* update product fragments
* update translations (#762)
* update translations
* fix translation types
* update messages
* update Availability component (#766)
* update ChannelsAvailability component
* update product fixtures
* update collection and channel fixtures
* ChannelsAvailability - handle errors
* update product handlers
* update ChannelsAvailability styles
* update ProductVariant
* update snapshots
* fix missing things in multichannel (#785)
* add availability dropdown to discount products list
* fix error handling in shipping components
* update product views and components
* update messages
* update category view/components
* update CategoryProducts styles
* remove defaultCurrency from shipping components
* create ChannelsSelect component
* update channels error handling after review
* another fixes after review
* Add channels to collection views/components (#791)
** update collection components and views
* update create collection view
* update error handling in collection
* remove filter bar from collection list
* update products fragments
* small fix in collection create view
* use collectionFragment in useCatalogSearch
* update defaultMessages and snapshots
* update homepage view/drop defaultCurrency (#801)
* update homepage view
* drop defaultCurrency prop
* fix onChannelChange function in home view
* remove visibility from product list filters
* update export products with channels (#803)
* update ProductExportDialog with channels
* add new channel error code
* remover VISIBLE from product export dialog Financial information
* fix input size in ProductVariantCreatorSummary (#804)
* channels currency code select (#806)
* create select with currency codes
* fix ChannelDeleteDialog
* update defaultMessages, remove unneeded ChannelDetails handlers
* fixes after rebase
* replace channelListing with channelListings
* [multichannel] Update schema]
* Fix product create test
Co-authored-by: AlicjaSzu <alicja.szukuc@gmail.com>
Co-authored-by: Krzysztof Wolski <krzysztof.k.wolski@gmail.com>
Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2020-11-17 16:10:42 +00:00
|
|
|
|
2019-11-19 16:32:35 +00:00
|
|
|
const {
|
|
|
|
loadMore: loadMoreCustomers,
|
|
|
|
search: searchUsers,
|
2020-07-02 10:54:15 +00:00
|
|
|
result: users
|
2019-11-19 16:32:35 +00:00
|
|
|
} = useCustomerSearch({
|
2020-07-02 10:54:15 +00:00
|
|
|
variables: DEFAULT_INITIAL_SEARCH_DATA
|
2019-11-19 16:32:35 +00:00
|
|
|
});
|
2020-11-30 13:19:57 +00:00
|
|
|
|
2019-11-20 10:24:42 +00:00
|
|
|
const {
|
|
|
|
loadMore,
|
|
|
|
search: variantSearch,
|
2020-07-02 10:54:15 +00:00
|
|
|
result: variantSearchOpts
|
2019-11-20 10:24:42 +00:00
|
|
|
} = useOrderVariantSearch({
|
2020-07-02 10:54:15 +00:00
|
|
|
variables: DEFAULT_INITIAL_SEARCH_DATA
|
2019-11-20 10:24:42 +00:00
|
|
|
});
|
2020-04-27 14:26:57 +00:00
|
|
|
const warehouses = useWarehouseList({
|
|
|
|
displayLoader: true,
|
|
|
|
variables: {
|
2020-07-02 10:54:15 +00:00
|
|
|
first: 30
|
|
|
|
}
|
2020-04-27 14:26:57 +00:00
|
|
|
});
|
2020-06-26 17:06:48 +00:00
|
|
|
const { queue } = useBackgroundTask();
|
2020-03-16 12:28:52 +00:00
|
|
|
const intl = useIntl();
|
2020-09-01 16:22:54 +00:00
|
|
|
const [updateMetadata, updateMetadataOpts] = useMetadataUpdate({});
|
|
|
|
const [
|
|
|
|
updatePrivateMetadata,
|
|
|
|
updatePrivateMetadataOpts
|
|
|
|
] = usePrivateMetadataUpdate({});
|
|
|
|
const notify = useNotifier();
|
2020-11-24 16:02:50 +00:00
|
|
|
const [transactionReference, setTransactionReference] = React.useState("");
|
2020-03-16 12:28:52 +00:00
|
|
|
|
|
|
|
const [openModal, closeModal] = createDialogActionHandlers<
|
|
|
|
OrderUrlDialog,
|
|
|
|
OrderUrlQueryParams
|
2020-07-02 10:54:15 +00:00
|
|
|
>(navigate, params => orderUrl(id, params), params);
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2020-02-20 14:18:22 +00:00
|
|
|
const handleBack = () => navigate(orderListUrl());
|
|
|
|
|
2020-11-30 13:19:57 +00:00
|
|
|
const [orderConfirm] = useOrderConfirmMutation({
|
|
|
|
onCompleted: ({ orderConfirm: { errors } }) => {
|
|
|
|
const isError = !!errors.length;
|
|
|
|
|
|
|
|
notify({
|
|
|
|
status: isError ? "error" : "success",
|
|
|
|
text: isError
|
|
|
|
? getOrderErrorMessage(errors[0], intl)
|
|
|
|
: "Confirmed Order"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-06-19 14:40:52 +00:00
|
|
|
return (
|
2020-02-20 14:18:22 +00:00
|
|
|
<TypedOrderDetailsQuery displayLoader variables={{ id }}>
|
2019-06-19 14:40:52 +00:00
|
|
|
{({ data, loading }) => {
|
2020-02-20 14:18:22 +00:00
|
|
|
const order = data?.order;
|
|
|
|
if (order === null) {
|
|
|
|
return <NotFoundPage onBack={handleBack} />;
|
|
|
|
}
|
|
|
|
|
2021-02-05 12:46:15 +00:00
|
|
|
const isOrderUnconfirmed = order?.status === OrderStatus.UNCONFIRMED;
|
|
|
|
const isOrderDraft = order?.status === OrderStatus.DRAFT;
|
|
|
|
|
2020-09-01 16:22:54 +00:00
|
|
|
const handleSubmit = async (data: MetadataFormData) => {
|
2020-11-30 13:19:57 +00:00
|
|
|
if (order?.status === OrderStatus.UNCONFIRMED) {
|
|
|
|
await orderConfirm({ variables: { id: order?.id } });
|
|
|
|
}
|
|
|
|
|
2020-09-01 16:22:54 +00:00
|
|
|
const update = createMetadataUpdateHandler(
|
|
|
|
order,
|
|
|
|
() => Promise.resolve([]),
|
|
|
|
variables => updateMetadata({ variables }),
|
|
|
|
variables => updatePrivateMetadata({ variables })
|
|
|
|
);
|
|
|
|
const result = await update(data);
|
|
|
|
|
|
|
|
if (result.length === 0) {
|
|
|
|
notify({
|
|
|
|
status: "success",
|
|
|
|
text: intl.formatMessage(commonMessages.savedChanges)
|
|
|
|
});
|
|
|
|
}
|
2020-10-22 11:33:29 +00:00
|
|
|
|
|
|
|
return result;
|
2020-09-01 16:22:54 +00:00
|
|
|
};
|
|
|
|
|
2019-06-19 14:40:52 +00:00
|
|
|
return (
|
2020-03-16 12:28:52 +00:00
|
|
|
<OrderDetailsMessages id={id} params={params}>
|
2020-07-02 10:54:15 +00:00
|
|
|
{orderMessages => (
|
2019-11-19 16:32:35 +00:00
|
|
|
<OrderOperations
|
|
|
|
order={id}
|
|
|
|
onNoteAdd={orderMessages.handleNoteAdd}
|
|
|
|
onOrderCancel={orderMessages.handleOrderCancel}
|
|
|
|
onOrderVoid={orderMessages.handleOrderVoid}
|
|
|
|
onPaymentCapture={orderMessages.handlePaymentCapture}
|
|
|
|
onUpdate={orderMessages.handleUpdate}
|
|
|
|
onDraftUpdate={orderMessages.handleDraftUpdate}
|
|
|
|
onShippingMethodUpdate={
|
|
|
|
orderMessages.handleShippingMethodUpdate
|
|
|
|
}
|
|
|
|
onOrderLineDelete={orderMessages.handleOrderLineDelete}
|
|
|
|
onOrderLinesAdd={orderMessages.handleOrderLinesAdd}
|
|
|
|
onOrderLineUpdate={orderMessages.handleOrderLineUpdate}
|
|
|
|
onOrderFulfillmentCancel={
|
|
|
|
orderMessages.handleOrderFulfillmentCancel
|
|
|
|
}
|
|
|
|
onOrderFulfillmentUpdate={
|
|
|
|
orderMessages.handleOrderFulfillmentUpdate
|
|
|
|
}
|
|
|
|
onDraftFinalize={orderMessages.handleDraftFinalize}
|
|
|
|
onDraftCancel={orderMessages.handleDraftCancel}
|
|
|
|
onOrderMarkAsPaid={orderMessages.handleOrderMarkAsPaid}
|
2020-06-26 17:06:48 +00:00
|
|
|
onInvoiceRequest={(data: InvoiceRequest) => {
|
|
|
|
if (
|
|
|
|
data.invoiceRequest.invoice.status === JobStatusEnum.SUCCESS
|
|
|
|
) {
|
|
|
|
orderMessages.handleInvoiceGenerateFinished(data);
|
|
|
|
} else {
|
|
|
|
orderMessages.handleInvoiceGeneratePending(data);
|
|
|
|
queue(Task.INVOICE_GENERATE, {
|
2020-07-06 23:57:43 +00:00
|
|
|
generateInvoice: {
|
2020-06-26 17:06:48 +00:00
|
|
|
invoiceId: data.invoiceRequest.invoice.id,
|
2020-07-02 10:54:15 +00:00
|
|
|
orderId: id
|
|
|
|
}
|
2020-06-26 17:06:48 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
2020-06-24 12:50:14 +00:00
|
|
|
onInvoiceSend={orderMessages.handleInvoiceSend}
|
2019-11-19 16:32:35 +00:00
|
|
|
>
|
|
|
|
{({
|
|
|
|
orderAddNote,
|
|
|
|
orderCancel,
|
|
|
|
orderDraftUpdate,
|
|
|
|
orderLinesAdd,
|
|
|
|
orderLineDelete,
|
|
|
|
orderLineUpdate,
|
|
|
|
orderPaymentCapture,
|
|
|
|
orderVoid,
|
|
|
|
orderShippingMethodUpdate,
|
|
|
|
orderUpdate,
|
|
|
|
orderFulfillmentCancel,
|
|
|
|
orderFulfillmentUpdateTracking,
|
|
|
|
orderDraftCancel,
|
|
|
|
orderDraftFinalize,
|
2020-06-22 16:34:59 +00:00
|
|
|
orderPaymentMarkAsPaid,
|
2020-06-23 12:27:44 +00:00
|
|
|
orderInvoiceRequest,
|
2020-07-02 10:54:15 +00:00
|
|
|
orderInvoiceSend
|
2019-12-06 17:11:46 +00:00
|
|
|
}) => (
|
|
|
|
<>
|
2021-02-05 12:46:15 +00:00
|
|
|
{!isOrderDraft && !isOrderUnconfirmed && (
|
|
|
|
<>
|
|
|
|
<WindowTitle
|
|
|
|
title={intl.formatMessage(
|
|
|
|
{
|
|
|
|
defaultMessage: "Order #{orderNumber}",
|
|
|
|
description: "window title"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
orderNumber: getStringOrPlaceholder(
|
|
|
|
data?.order?.number
|
2021-01-29 13:14:31 +00:00
|
|
|
)
|
|
|
|
}
|
2021-02-05 12:46:15 +00:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<OrderDetailsPage
|
|
|
|
onOrderReturn={() => navigate(orderReturnPath(id))}
|
|
|
|
disabled={
|
|
|
|
updateMetadataOpts.loading ||
|
|
|
|
updatePrivateMetadataOpts.loading
|
|
|
|
}
|
|
|
|
onNoteAdd={variables =>
|
|
|
|
orderAddNote.mutate({
|
|
|
|
input: variables,
|
|
|
|
order: id
|
|
|
|
})
|
|
|
|
}
|
|
|
|
onBack={handleBack}
|
|
|
|
order={order}
|
|
|
|
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={maybe(
|
|
|
|
() => data.order.availableShippingMethods,
|
|
|
|
[]
|
|
|
|
)}
|
|
|
|
userPermissions={user?.userPermissions || []}
|
|
|
|
onOrderCancel={() => openModal("cancel")}
|
|
|
|
onOrderFulfill={() => navigate(orderFulfillUrl(id))}
|
|
|
|
onFulfillmentCancel={fulfillmentId =>
|
|
|
|
navigate(
|
|
|
|
orderUrl(id, {
|
|
|
|
action: "cancel-fulfillment",
|
|
|
|
id: fulfillmentId
|
2021-01-29 13:14:31 +00:00
|
|
|
})
|
2021-02-05 12:46:15 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
onFulfillmentTrackingNumberUpdate={fulfillmentId =>
|
|
|
|
navigate(
|
|
|
|
orderUrl(id, {
|
|
|
|
action: "edit-fulfillment",
|
|
|
|
id: fulfillmentId
|
2021-01-29 13:14:31 +00:00
|
|
|
})
|
2021-02-05 12:46:15 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
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}
|
|
|
|
/>
|
|
|
|
<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
|
|
|
|
})
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<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
|
|
|
|
})
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<OrderFulfillmentCancelDialog
|
|
|
|
confirmButtonState={
|
|
|
|
orderFulfillmentCancel.opts.status
|
|
|
|
}
|
|
|
|
errors={
|
|
|
|
orderFulfillmentCancel.opts.data
|
|
|
|
?.orderFulfillmentCancel.errors || []
|
|
|
|
}
|
|
|
|
open={params.action === "cancel-fulfillment"}
|
|
|
|
warehouses={
|
|
|
|
warehouses.data?.warehouses.edges.map(
|
|
|
|
edge => edge.node
|
|
|
|
) || []
|
|
|
|
}
|
|
|
|
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: {
|
2021-01-29 13:14:31 +00:00
|
|
|
...variables,
|
2021-02-05 12:46:15 +00:00
|
|
|
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 })
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{isOrderDraft && (
|
2021-01-29 13:14:31 +00:00
|
|
|
<>
|
|
|
|
<WindowTitle
|
|
|
|
title={intl.formatMessage(
|
|
|
|
{
|
|
|
|
defaultMessage: "Draft Order #{orderNumber}",
|
|
|
|
description: "window title"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
orderNumber: getStringOrPlaceholder(
|
|
|
|
data?.order?.number
|
|
|
|
)
|
|
|
|
}
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<OrderDraftPage
|
|
|
|
disabled={loading}
|
|
|
|
onNoteAdd={variables =>
|
|
|
|
orderAddNote.mutate({
|
|
|
|
input: variables,
|
|
|
|
order: id
|
|
|
|
})
|
|
|
|
}
|
|
|
|
users={maybe(
|
|
|
|
() =>
|
|
|
|
users.data.search.edges.map(edge => edge.node),
|
|
|
|
[]
|
|
|
|
)}
|
|
|
|
hasMore={maybe(
|
|
|
|
() => users.data.search.pageInfo.hasNextPage,
|
|
|
|
false
|
|
|
|
)}
|
|
|
|
onFetchMore={loadMoreCustomers}
|
|
|
|
fetchUsers={searchUsers}
|
|
|
|
loading={users.loading}
|
|
|
|
usersLoading={users.loading}
|
|
|
|
onCustomerEdit={data =>
|
|
|
|
orderDraftUpdate.mutate({
|
|
|
|
id,
|
|
|
|
input: data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
onDraftFinalize={() =>
|
|
|
|
orderDraftFinalize.mutate({ id })
|
|
|
|
}
|
|
|
|
onDraftRemove={() => openModal("cancel")}
|
|
|
|
onOrderLineAdd={() => openModal("add-order-line")}
|
|
|
|
onBack={() => navigate(orderDraftListUrl())}
|
|
|
|
order={order}
|
|
|
|
countries={maybe(() => data.shop.countries, []).map(
|
|
|
|
country => ({
|
|
|
|
code: country.code,
|
|
|
|
label: country.country
|
|
|
|
})
|
|
|
|
)}
|
|
|
|
onProductClick={id => () =>
|
|
|
|
navigate(productUrl(encodeURIComponent(id)))}
|
|
|
|
onBillingAddressEdit={() =>
|
|
|
|
openModal("edit-billing-address")
|
|
|
|
}
|
|
|
|
onShippingAddressEdit={() =>
|
|
|
|
openModal("edit-shipping-address")
|
|
|
|
}
|
|
|
|
onShippingMethodEdit={() =>
|
|
|
|
openModal("edit-shipping")
|
|
|
|
}
|
|
|
|
onOrderLineRemove={id =>
|
|
|
|
orderLineDelete.mutate({ id })
|
|
|
|
}
|
|
|
|
onOrderLineChange={(id, data) =>
|
|
|
|
orderLineUpdate.mutate({
|
|
|
|
id,
|
|
|
|
input: data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
saveButtonBarState="default"
|
|
|
|
onProfileView={() =>
|
|
|
|
navigate(customerUrl(order.user.id))
|
|
|
|
}
|
|
|
|
userPermissions={user?.userPermissions || []}
|
|
|
|
/>
|
|
|
|
<OrderDraftCancelDialog
|
|
|
|
confirmButtonState={orderDraftCancel.opts.status}
|
|
|
|
errors={
|
|
|
|
orderDraftCancel.opts.data?.draftOrderDelete
|
|
|
|
.errors || []
|
|
|
|
}
|
|
|
|
onClose={closeModal}
|
|
|
|
onConfirm={() => orderDraftCancel.mutate({ id })}
|
|
|
|
open={params.action === "cancel"}
|
|
|
|
orderNumber={getStringOrPlaceholder(order?.number)}
|
|
|
|
/>
|
|
|
|
<OrderShippingMethodEditDialog
|
|
|
|
confirmButtonState={
|
|
|
|
orderShippingMethodUpdate.opts.status
|
|
|
|
}
|
|
|
|
errors={
|
|
|
|
orderShippingMethodUpdate.opts.data
|
|
|
|
?.orderUpdateShipping.errors || []
|
|
|
|
}
|
|
|
|
open={params.action === "edit-shipping"}
|
|
|
|
shippingMethod={order?.shippingMethod?.id}
|
|
|
|
shippingMethods={order?.availableShippingMethods}
|
|
|
|
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={variantSearchOpts.data?.search.edges.map(
|
|
|
|
edge => edge.node
|
|
|
|
)}
|
|
|
|
selectedChannelId={order?.channel?.id}
|
|
|
|
onClose={closeModal}
|
|
|
|
onFetch={variantSearch}
|
|
|
|
onFetchMore={loadMore}
|
|
|
|
onSubmit={variants =>
|
|
|
|
orderLinesAdd.mutate({
|
|
|
|
id,
|
|
|
|
input: variants.map(variant => ({
|
|
|
|
quantity: 1,
|
|
|
|
variantId: variant.id
|
|
|
|
}))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
2021-02-05 12:46:15 +00:00
|
|
|
{isOrderUnconfirmed && (
|
2019-12-06 17:11:46 +00:00
|
|
|
<>
|
|
|
|
<WindowTitle
|
2020-03-16 12:28:52 +00:00
|
|
|
title={intl.formatMessage(
|
|
|
|
{
|
|
|
|
defaultMessage: "Order #{orderNumber}",
|
2020-07-02 10:54:15 +00:00
|
|
|
description: "window title"
|
2020-03-16 12:28:52 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
orderNumber: getStringOrPlaceholder(
|
|
|
|
data?.order?.number
|
2020-07-02 10:54:15 +00:00
|
|
|
)
|
2020-03-16 12:28:52 +00:00
|
|
|
}
|
|
|
|
)}
|
2019-12-06 17:11:46 +00:00
|
|
|
/>
|
|
|
|
<OrderDetailsPage
|
2021-01-20 16:16:43 +00:00
|
|
|
onOrderReturn={() => navigate(orderReturnPath(id))}
|
2020-09-01 16:22:54 +00:00
|
|
|
disabled={
|
|
|
|
updateMetadataOpts.loading ||
|
|
|
|
updatePrivateMetadataOpts.loading
|
|
|
|
}
|
2020-07-02 10:54:15 +00:00
|
|
|
onNoteAdd={variables =>
|
2019-12-06 17:11:46 +00:00
|
|
|
orderAddNote.mutate({
|
|
|
|
input: variables,
|
2020-07-02 10:54:15 +00:00
|
|
|
order: id
|
2019-12-06 17:11:46 +00:00
|
|
|
})
|
|
|
|
}
|
2020-02-20 14:18:22 +00:00
|
|
|
onBack={handleBack}
|
2019-12-06 17:11:46 +00:00
|
|
|
order={order}
|
2021-01-29 13:14:31 +00:00
|
|
|
onOrderLineAdd={() => openModal("add-order-line")}
|
|
|
|
onOrderLineChange={(id, data) =>
|
|
|
|
orderLineUpdate.mutate({
|
|
|
|
id,
|
|
|
|
input: data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
onOrderLineRemove={id =>
|
|
|
|
orderLineDelete.mutate({ id })
|
|
|
|
}
|
|
|
|
onShippingMethodEdit={() =>
|
|
|
|
openModal("edit-shipping")
|
|
|
|
}
|
2020-09-01 16:22:54 +00:00
|
|
|
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 || [])
|
|
|
|
]
|
|
|
|
)}
|
2019-12-06 17:11:46 +00:00
|
|
|
shippingMethods={maybe(
|
|
|
|
() => data.order.availableShippingMethods,
|
|
|
|
[]
|
|
|
|
)}
|
2020-04-23 15:43:08 +00:00
|
|
|
userPermissions={user?.userPermissions || []}
|
2019-12-06 17:11:46 +00:00
|
|
|
onOrderCancel={() => openModal("cancel")}
|
2020-04-20 17:18:20 +00:00
|
|
|
onOrderFulfill={() => navigate(orderFulfillUrl(id))}
|
2020-07-02 10:54:15 +00:00
|
|
|
onFulfillmentCancel={fulfillmentId =>
|
2019-12-06 17:11:46 +00:00
|
|
|
navigate(
|
|
|
|
orderUrl(id, {
|
|
|
|
action: "cancel-fulfillment",
|
2020-07-02 10:54:15 +00:00
|
|
|
id: fulfillmentId
|
2019-11-19 16:32:35 +00:00
|
|
|
})
|
2019-12-06 17:11:46 +00:00
|
|
|
)
|
|
|
|
}
|
2020-07-02 10:54:15 +00:00
|
|
|
onFulfillmentTrackingNumberUpdate={fulfillmentId =>
|
2019-12-06 17:11:46 +00:00
|
|
|
navigate(
|
|
|
|
orderUrl(id, {
|
|
|
|
action: "edit-fulfillment",
|
2020-07-02 10:54:15 +00:00
|
|
|
id: fulfillmentId
|
2019-11-19 16:32:35 +00:00
|
|
|
})
|
2019-12-06 17:11:46 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
onPaymentCapture={() => openModal("capture")}
|
|
|
|
onPaymentVoid={() => openModal("void")}
|
2020-12-01 13:13:05 +00:00
|
|
|
onPaymentRefund={() => navigate(orderRefundUrl(id))}
|
2020-07-02 10:54:15 +00:00
|
|
|
onProductClick={id => () => navigate(productUrl(id))}
|
2019-12-06 17:11:46 +00:00
|
|
|
onBillingAddressEdit={() =>
|
|
|
|
openModal("edit-billing-address")
|
|
|
|
}
|
|
|
|
onShippingAddressEdit={() =>
|
|
|
|
openModal("edit-shipping-address")
|
|
|
|
}
|
|
|
|
onPaymentPaid={() => openModal("mark-paid")}
|
|
|
|
onProfileView={() =>
|
|
|
|
navigate(customerUrl(order.user.id))
|
|
|
|
}
|
2020-07-02 11:58:44 +00:00
|
|
|
onInvoiceClick={id =>
|
|
|
|
window.open(
|
|
|
|
order.invoices.find(invoice => invoice.id === id)
|
|
|
|
?.url,
|
|
|
|
"_blank"
|
|
|
|
)
|
2020-06-22 16:34:59 +00:00
|
|
|
}
|
2020-06-24 15:29:13 +00:00
|
|
|
onInvoiceGenerate={() =>
|
2020-06-23 12:27:44 +00:00
|
|
|
orderInvoiceRequest.mutate({
|
2020-07-02 10:54:15 +00:00
|
|
|
orderId: id
|
2020-06-23 12:27:44 +00:00
|
|
|
})
|
|
|
|
}
|
2020-07-02 11:58:44 +00:00
|
|
|
onInvoiceSend={id =>
|
|
|
|
openModal("invoice-send", { id })
|
2020-06-23 14:44:34 +00:00
|
|
|
}
|
2020-09-01 16:22:54 +00:00
|
|
|
onSubmit={handleSubmit}
|
2019-12-06 17:11:46 +00:00
|
|
|
/>
|
2020-04-28 01:09:31 +00:00
|
|
|
<OrderCannotCancelOrderDialog
|
|
|
|
onClose={closeModal}
|
|
|
|
open={
|
|
|
|
params.action === "cancel" &&
|
|
|
|
order?.fulfillments.some(
|
2020-07-02 10:54:15 +00:00
|
|
|
fulfillment =>
|
2020-04-28 01:09:31 +00:00
|
|
|
fulfillment.status ===
|
|
|
|
FulfillmentStatus.FULFILLED
|
|
|
|
)
|
|
|
|
}
|
|
|
|
/>
|
2019-12-06 17:11:46 +00:00
|
|
|
<OrderCancelDialog
|
2020-03-16 12:28:52 +00:00
|
|
|
confirmButtonState={orderCancel.opts.status}
|
|
|
|
errors={
|
2020-03-03 11:20:39 +00:00
|
|
|
orderCancel.opts.data?.orderCancel.errors || []
|
2020-03-16 12:28:52 +00:00
|
|
|
}
|
|
|
|
number={order?.number}
|
2019-12-06 17:11:46 +00:00
|
|
|
open={params.action === "cancel"}
|
|
|
|
onClose={closeModal}
|
2020-04-28 01:09:31 +00:00
|
|
|
onSubmit={() =>
|
2019-12-06 17:11:46 +00:00
|
|
|
orderCancel.mutate({
|
2020-07-02 10:54:15 +00:00
|
|
|
id
|
2019-12-06 17:11:46 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
/>
|
2021-01-29 13:14:31 +00:00
|
|
|
<OrderShippingMethodEditDialog
|
|
|
|
confirmButtonState={
|
|
|
|
orderShippingMethodUpdate.opts.status
|
|
|
|
}
|
|
|
|
errors={
|
|
|
|
orderShippingMethodUpdate.opts.data
|
|
|
|
?.orderUpdateShipping.errors || []
|
|
|
|
}
|
|
|
|
open={params.action === "edit-shipping"}
|
|
|
|
shippingMethod={order?.shippingMethod?.id}
|
|
|
|
shippingMethods={order?.availableShippingMethods}
|
|
|
|
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={variantSearchOpts.data?.search.edges.map(
|
|
|
|
edge => edge.node
|
|
|
|
)}
|
|
|
|
selectedChannelId={order?.channel?.id}
|
|
|
|
onClose={closeModal}
|
|
|
|
onFetch={variantSearch}
|
|
|
|
onFetchMore={loadMore}
|
|
|
|
onSubmit={variants =>
|
|
|
|
orderLinesAdd.mutate({
|
|
|
|
id,
|
|
|
|
input: variants.map(variant => ({
|
|
|
|
quantity: 1,
|
|
|
|
variantId: variant.id
|
|
|
|
}))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
/>
|
2019-12-06 17:11:46 +00:00
|
|
|
<OrderMarkAsPaidDialog
|
2020-03-16 12:28:52 +00:00
|
|
|
confirmButtonState={
|
|
|
|
orderPaymentMarkAsPaid.opts.status
|
|
|
|
}
|
|
|
|
errors={
|
|
|
|
orderPaymentMarkAsPaid.opts.data?.orderMarkAsPaid
|
|
|
|
.errors || []
|
|
|
|
}
|
2019-12-06 17:11:46 +00:00
|
|
|
onClose={closeModal}
|
|
|
|
onConfirm={() =>
|
|
|
|
orderPaymentMarkAsPaid.mutate({
|
2020-11-24 16:02:50 +00:00
|
|
|
id,
|
|
|
|
transactionReference
|
2019-12-06 17:11:46 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
open={params.action === "mark-paid"}
|
2020-11-24 16:02:50 +00:00
|
|
|
transactionReference={transactionReference}
|
|
|
|
handleTransactionReference={({ target }) =>
|
|
|
|
setTransactionReference(target.value)
|
|
|
|
}
|
2019-12-06 17:11:46 +00:00
|
|
|
/>
|
|
|
|
<OrderPaymentVoidDialog
|
2020-03-16 12:28:52 +00:00
|
|
|
confirmButtonState={orderVoid.opts.status}
|
|
|
|
errors={orderVoid.opts.data?.orderVoid.errors || []}
|
2019-12-06 17:11:46 +00:00
|
|
|
open={params.action === "void"}
|
|
|
|
onClose={closeModal}
|
|
|
|
onConfirm={() => orderVoid.mutate({ id })}
|
|
|
|
/>
|
|
|
|
<OrderPaymentDialog
|
2020-03-16 12:28:52 +00:00
|
|
|
confirmButtonState={orderPaymentCapture.opts.status}
|
|
|
|
errors={
|
|
|
|
orderPaymentCapture.opts.data?.orderCapture
|
|
|
|
.errors || []
|
|
|
|
}
|
|
|
|
initial={order?.total.gross.amount}
|
2019-12-06 17:11:46 +00:00
|
|
|
open={params.action === "capture"}
|
|
|
|
onClose={closeModal}
|
2020-07-02 10:54:15 +00:00
|
|
|
onSubmit={variables =>
|
2019-12-06 17:11:46 +00:00
|
|
|
orderPaymentCapture.mutate({
|
|
|
|
...variables,
|
2020-07-02 10:54:15 +00:00
|
|
|
id
|
2019-12-06 17:11:46 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<OrderFulfillmentCancelDialog
|
2020-03-16 12:28:52 +00:00
|
|
|
confirmButtonState={
|
|
|
|
orderFulfillmentCancel.opts.status
|
|
|
|
}
|
|
|
|
errors={
|
|
|
|
orderFulfillmentCancel.opts.data
|
|
|
|
?.orderFulfillmentCancel.errors || []
|
|
|
|
}
|
2019-12-06 17:11:46 +00:00
|
|
|
open={params.action === "cancel-fulfillment"}
|
2020-04-27 14:26:57 +00:00
|
|
|
warehouses={
|
|
|
|
warehouses.data?.warehouses.edges.map(
|
2020-07-02 10:54:15 +00:00
|
|
|
edge => edge.node
|
2020-04-27 14:26:57 +00:00
|
|
|
) || []
|
|
|
|
}
|
2020-07-02 10:54:15 +00:00
|
|
|
onConfirm={variables =>
|
2019-12-06 17:11:46 +00:00
|
|
|
orderFulfillmentCancel.mutate({
|
|
|
|
id: params.id,
|
2020-07-02 10:54:15 +00:00
|
|
|
input: variables
|
2019-12-06 17:11:46 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
onClose={closeModal}
|
|
|
|
/>
|
|
|
|
<OrderFulfillmentTrackingDialog
|
2020-03-16 12:28:52 +00:00
|
|
|
confirmButtonState={
|
|
|
|
orderFulfillmentUpdateTracking.opts.status
|
|
|
|
}
|
|
|
|
errors={
|
|
|
|
orderFulfillmentUpdateTracking.opts.data
|
|
|
|
?.orderFulfillmentUpdateTracking.errors || []
|
|
|
|
}
|
2019-12-06 17:11:46 +00:00
|
|
|
open={params.action === "edit-fulfillment"}
|
2020-03-16 12:28:52 +00:00
|
|
|
trackingNumber={getStringOrPlaceholder(
|
|
|
|
data?.order?.fulfillments.find(
|
2020-07-02 10:54:15 +00:00
|
|
|
fulfillment => fulfillment.id === params.id
|
2020-03-16 12:28:52 +00:00
|
|
|
)?.trackingNumber
|
2019-12-06 17:11:46 +00:00
|
|
|
)}
|
2020-07-02 10:54:15 +00:00
|
|
|
onConfirm={variables =>
|
2019-12-06 17:11:46 +00:00
|
|
|
orderFulfillmentUpdateTracking.mutate({
|
|
|
|
id: params.id,
|
|
|
|
input: {
|
2019-11-19 16:32:35 +00:00
|
|
|
...variables,
|
2020-07-02 10:54:15 +00:00
|
|
|
notifyCustomer: true
|
|
|
|
}
|
2019-12-06 17:11:46 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
onClose={closeModal}
|
|
|
|
/>
|
2020-06-24 15:29:13 +00:00
|
|
|
<OrderInvoiceEmailSendDialog
|
|
|
|
confirmButtonState={orderInvoiceSend.opts.status}
|
|
|
|
errors={
|
2020-06-25 11:36:43 +00:00
|
|
|
orderInvoiceSend.opts.data?.invoiceSendEmail
|
2020-06-24 15:29:13 +00:00
|
|
|
.errors || []
|
|
|
|
}
|
|
|
|
open={params.action === "invoice-send"}
|
|
|
|
invoice={order?.invoices?.find(
|
2020-07-02 10:54:15 +00:00
|
|
|
invoice => invoice.id === params.id
|
2020-06-24 15:29:13 +00:00
|
|
|
)}
|
|
|
|
onClose={closeModal}
|
2020-07-02 10:54:15 +00:00
|
|
|
onSend={() =>
|
2020-06-24 15:29:13 +00:00
|
|
|
orderInvoiceSend.mutate({ id: params.id })
|
|
|
|
}
|
|
|
|
/>
|
2019-12-06 17:11:46 +00:00
|
|
|
</>
|
|
|
|
)}
|
2020-10-29 11:59:48 +00:00
|
|
|
<OrderAddressFields
|
|
|
|
isDraft={order?.status === OrderStatus.DRAFT}
|
|
|
|
orderUpdate={orderUpdate}
|
|
|
|
orderDraftUpdate={orderDraftUpdate}
|
|
|
|
data={data}
|
|
|
|
id={id}
|
2019-12-06 17:11:46 +00:00
|
|
|
onClose={closeModal}
|
2020-10-29 11:59:48 +00:00
|
|
|
action={params.action}
|
2019-12-06 17:11:46 +00:00
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
2019-11-19 16:32:35 +00:00
|
|
|
</OrderOperations>
|
2019-06-19 14:40:52 +00:00
|
|
|
)}
|
2019-11-19 16:32:35 +00:00
|
|
|
</OrderDetailsMessages>
|
2019-06-19 14:40:52 +00:00
|
|
|
);
|
|
|
|
}}
|
|
|
|
</TypedOrderDetailsQuery>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default OrderDetails;
|