@medusajs/draft-order 2.11.3-preview-20251102032220 → 2.11.3-preview-20251102060143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +863 -863
- package/.medusa/server/src/admin/index.mjs +863 -863
- package/package.json +16 -16
|
@@ -9783,6 +9783,74 @@ const CustomItemsForm = () => {
|
|
|
9783
9783
|
const schema$4 = objectType({
|
|
9784
9784
|
email: stringType().email()
|
|
9785
9785
|
});
|
|
9786
|
+
const Email = () => {
|
|
9787
|
+
const { id } = reactRouterDom.useParams();
|
|
9788
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9789
|
+
fields: "+email"
|
|
9790
|
+
});
|
|
9791
|
+
if (isError) {
|
|
9792
|
+
throw error;
|
|
9793
|
+
}
|
|
9794
|
+
const isReady = !isPending && !!order;
|
|
9795
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9796
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9797
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9798
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9799
|
+
] }),
|
|
9800
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9801
|
+
] });
|
|
9802
|
+
};
|
|
9803
|
+
const EmailForm = ({ order }) => {
|
|
9804
|
+
const form = reactHookForm.useForm({
|
|
9805
|
+
defaultValues: {
|
|
9806
|
+
email: order.email ?? ""
|
|
9807
|
+
},
|
|
9808
|
+
resolver: zod.zodResolver(schema$3)
|
|
9809
|
+
});
|
|
9810
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9811
|
+
const { handleSuccess } = useRouteModal();
|
|
9812
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9813
|
+
await mutateAsync(
|
|
9814
|
+
{ email: data.email },
|
|
9815
|
+
{
|
|
9816
|
+
onSuccess: () => {
|
|
9817
|
+
handleSuccess();
|
|
9818
|
+
},
|
|
9819
|
+
onError: (error) => {
|
|
9820
|
+
ui.toast.error(error.message);
|
|
9821
|
+
}
|
|
9822
|
+
}
|
|
9823
|
+
);
|
|
9824
|
+
});
|
|
9825
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9826
|
+
KeyboundForm,
|
|
9827
|
+
{
|
|
9828
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9829
|
+
onSubmit,
|
|
9830
|
+
children: [
|
|
9831
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9832
|
+
Form$2.Field,
|
|
9833
|
+
{
|
|
9834
|
+
control: form.control,
|
|
9835
|
+
name: "email",
|
|
9836
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9837
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9838
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9839
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9840
|
+
] })
|
|
9841
|
+
}
|
|
9842
|
+
) }),
|
|
9843
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9844
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9845
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9846
|
+
] }) })
|
|
9847
|
+
]
|
|
9848
|
+
}
|
|
9849
|
+
) });
|
|
9850
|
+
};
|
|
9851
|
+
const schema$3 = objectType({
|
|
9852
|
+
email: stringType().email()
|
|
9853
|
+
});
|
|
9786
9854
|
const NumberInput = React.forwardRef(
|
|
9787
9855
|
({
|
|
9788
9856
|
value,
|
|
@@ -10757,74 +10825,6 @@ const customItemSchema = objectType({
|
|
|
10757
10825
|
quantity: numberType(),
|
|
10758
10826
|
unit_price: unionType([numberType(), stringType()])
|
|
10759
10827
|
});
|
|
10760
|
-
const Email = () => {
|
|
10761
|
-
const { id } = reactRouterDom.useParams();
|
|
10762
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
10763
|
-
fields: "+email"
|
|
10764
|
-
});
|
|
10765
|
-
if (isError) {
|
|
10766
|
-
throw error;
|
|
10767
|
-
}
|
|
10768
|
-
const isReady = !isPending && !!order;
|
|
10769
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10770
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
10771
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
10772
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
10773
|
-
] }),
|
|
10774
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
10775
|
-
] });
|
|
10776
|
-
};
|
|
10777
|
-
const EmailForm = ({ order }) => {
|
|
10778
|
-
const form = reactHookForm.useForm({
|
|
10779
|
-
defaultValues: {
|
|
10780
|
-
email: order.email ?? ""
|
|
10781
|
-
},
|
|
10782
|
-
resolver: zod.zodResolver(schema$3)
|
|
10783
|
-
});
|
|
10784
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
10785
|
-
const { handleSuccess } = useRouteModal();
|
|
10786
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
10787
|
-
await mutateAsync(
|
|
10788
|
-
{ email: data.email },
|
|
10789
|
-
{
|
|
10790
|
-
onSuccess: () => {
|
|
10791
|
-
handleSuccess();
|
|
10792
|
-
},
|
|
10793
|
-
onError: (error) => {
|
|
10794
|
-
ui.toast.error(error.message);
|
|
10795
|
-
}
|
|
10796
|
-
}
|
|
10797
|
-
);
|
|
10798
|
-
});
|
|
10799
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10800
|
-
KeyboundForm,
|
|
10801
|
-
{
|
|
10802
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
10803
|
-
onSubmit,
|
|
10804
|
-
children: [
|
|
10805
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10806
|
-
Form$2.Field,
|
|
10807
|
-
{
|
|
10808
|
-
control: form.control,
|
|
10809
|
-
name: "email",
|
|
10810
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
10811
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
10812
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
10813
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
10814
|
-
] })
|
|
10815
|
-
}
|
|
10816
|
-
) }),
|
|
10817
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10818
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10819
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10820
|
-
] }) })
|
|
10821
|
-
]
|
|
10822
|
-
}
|
|
10823
|
-
) });
|
|
10824
|
-
};
|
|
10825
|
-
const schema$3 = objectType({
|
|
10826
|
-
email: stringType().email()
|
|
10827
|
-
});
|
|
10828
10828
|
const InlineTip = React.forwardRef(
|
|
10829
10829
|
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10830
10830
|
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
@@ -11452,171 +11452,480 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11452
11452
|
}
|
|
11453
11453
|
return Array.from(promotionIds);
|
|
11454
11454
|
}
|
|
11455
|
-
const
|
|
11456
|
-
const Shipping = () => {
|
|
11457
|
-
var _a;
|
|
11455
|
+
const SalesChannel = () => {
|
|
11458
11456
|
const { id } = reactRouterDom.useParams();
|
|
11459
|
-
const {
|
|
11460
|
-
|
|
11461
|
-
});
|
|
11462
|
-
const {
|
|
11463
|
-
order: preview,
|
|
11464
|
-
isPending: isPreviewPending,
|
|
11465
|
-
isError: isPreviewError,
|
|
11466
|
-
error: previewError
|
|
11467
|
-
} = useOrderPreview(id);
|
|
11468
|
-
useInitiateOrderEdit({ preview });
|
|
11469
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11470
|
-
if (isError) {
|
|
11471
|
-
throw error;
|
|
11472
|
-
}
|
|
11473
|
-
if (isPreviewError) {
|
|
11474
|
-
throw previewError;
|
|
11475
|
-
}
|
|
11476
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11477
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11478
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11479
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11480
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
11481
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11482
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11483
|
-
] }) }) }),
|
|
11484
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11485
|
-
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11486
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11487
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11488
|
-
] }) });
|
|
11489
|
-
};
|
|
11490
|
-
const ShippingForm = ({ preview, order }) => {
|
|
11491
|
-
var _a;
|
|
11492
|
-
const { setIsOpen } = useStackedModal();
|
|
11493
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11494
|
-
const [data, setData] = React.useState(null);
|
|
11495
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11496
|
-
const { shipping_options } = useShippingOptions(
|
|
11457
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11458
|
+
id,
|
|
11497
11459
|
{
|
|
11498
|
-
|
|
11499
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11460
|
+
fields: "+sales_channel_id"
|
|
11500
11461
|
},
|
|
11501
11462
|
{
|
|
11502
|
-
enabled:
|
|
11463
|
+
enabled: !!id
|
|
11503
11464
|
}
|
|
11504
11465
|
);
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11466
|
+
if (isError) {
|
|
11467
|
+
throw error;
|
|
11468
|
+
}
|
|
11469
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11470
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11471
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11472
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11473
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11474
|
+
] }),
|
|
11475
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11476
|
+
] });
|
|
11477
|
+
};
|
|
11478
|
+
const SalesChannelForm = ({ order }) => {
|
|
11479
|
+
const form = reactHookForm.useForm({
|
|
11480
|
+
defaultValues: {
|
|
11481
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11482
|
+
},
|
|
11483
|
+
resolver: zod.zodResolver(schema$2)
|
|
11484
|
+
});
|
|
11485
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11515
11486
|
const { handleSuccess } = useRouteModal();
|
|
11516
|
-
const
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
const onSubmit = async () => {
|
|
11521
|
-
setIsSubmitting(true);
|
|
11522
|
-
let requestSucceeded = false;
|
|
11523
|
-
await requestOrderEdit(void 0, {
|
|
11524
|
-
onError: (e) => {
|
|
11525
|
-
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
11526
|
-
},
|
|
11527
|
-
onSuccess: () => {
|
|
11528
|
-
requestSucceeded = true;
|
|
11529
|
-
}
|
|
11530
|
-
});
|
|
11531
|
-
if (!requestSucceeded) {
|
|
11532
|
-
setIsSubmitting(false);
|
|
11533
|
-
return;
|
|
11534
|
-
}
|
|
11535
|
-
await confirmOrderEdit(void 0, {
|
|
11536
|
-
onError: (e) => {
|
|
11537
|
-
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
11538
|
-
},
|
|
11539
|
-
onSuccess: () => {
|
|
11540
|
-
handleSuccess();
|
|
11487
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11488
|
+
await mutateAsync(
|
|
11489
|
+
{
|
|
11490
|
+
sales_channel_id: data.sales_channel_id
|
|
11541
11491
|
},
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
if (data || isSubmitting) {
|
|
11551
|
-
return;
|
|
11552
|
-
}
|
|
11553
|
-
onSubmit();
|
|
11492
|
+
{
|
|
11493
|
+
onSuccess: () => {
|
|
11494
|
+
ui.toast.success("Sales channel updated");
|
|
11495
|
+
handleSuccess();
|
|
11496
|
+
},
|
|
11497
|
+
onError: (error) => {
|
|
11498
|
+
ui.toast.error(error.message);
|
|
11499
|
+
}
|
|
11554
11500
|
}
|
|
11501
|
+
);
|
|
11502
|
+
});
|
|
11503
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11504
|
+
KeyboundForm,
|
|
11505
|
+
{
|
|
11506
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11507
|
+
onSubmit,
|
|
11508
|
+
children: [
|
|
11509
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11510
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11511
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11512
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11513
|
+
] }) })
|
|
11514
|
+
]
|
|
11515
|
+
}
|
|
11516
|
+
) });
|
|
11517
|
+
};
|
|
11518
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11519
|
+
const salesChannels = useComboboxData({
|
|
11520
|
+
queryFn: async (params) => {
|
|
11521
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11555
11522
|
},
|
|
11556
|
-
[
|
|
11523
|
+
queryKey: ["sales-channels"],
|
|
11524
|
+
getOptions: (data) => {
|
|
11525
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11526
|
+
label: salesChannel.name,
|
|
11527
|
+
value: salesChannel.id
|
|
11528
|
+
}));
|
|
11529
|
+
},
|
|
11530
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11531
|
+
});
|
|
11532
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11533
|
+
Form$2.Field,
|
|
11534
|
+
{
|
|
11535
|
+
control,
|
|
11536
|
+
name: "sales_channel_id",
|
|
11537
|
+
render: ({ field }) => {
|
|
11538
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11539
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11540
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11541
|
+
Combobox,
|
|
11542
|
+
{
|
|
11543
|
+
options: salesChannels.options,
|
|
11544
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11545
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11546
|
+
searchValue: salesChannels.searchValue,
|
|
11547
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11548
|
+
placeholder: "Select sales channel",
|
|
11549
|
+
...field
|
|
11550
|
+
}
|
|
11551
|
+
) }),
|
|
11552
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11553
|
+
] });
|
|
11554
|
+
}
|
|
11555
|
+
}
|
|
11557
11556
|
);
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
}
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
|
|
11574
|
-
|
|
11557
|
+
};
|
|
11558
|
+
const schema$2 = objectType({
|
|
11559
|
+
sales_channel_id: stringType().min(1)
|
|
11560
|
+
});
|
|
11561
|
+
const ShippingAddress = () => {
|
|
11562
|
+
const { id } = reactRouterDom.useParams();
|
|
11563
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11564
|
+
fields: "+shipping_address"
|
|
11565
|
+
});
|
|
11566
|
+
if (isError) {
|
|
11567
|
+
throw error;
|
|
11568
|
+
}
|
|
11569
|
+
const isReady = !isPending && !!order;
|
|
11570
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11571
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11572
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
11573
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
11574
|
+
] }),
|
|
11575
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
11576
|
+
] });
|
|
11577
|
+
};
|
|
11578
|
+
const ShippingAddressForm = ({ order }) => {
|
|
11579
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11580
|
+
const form = reactHookForm.useForm({
|
|
11581
|
+
defaultValues: {
|
|
11582
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11583
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11584
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
11585
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11586
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11587
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11588
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11589
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11590
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11591
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11592
|
+
},
|
|
11593
|
+
resolver: zod.zodResolver(schema$1)
|
|
11594
|
+
});
|
|
11595
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11596
|
+
const { handleSuccess } = useRouteModal();
|
|
11597
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11598
|
+
await mutateAsync(
|
|
11599
|
+
{
|
|
11600
|
+
shipping_address: {
|
|
11601
|
+
first_name: data.first_name,
|
|
11602
|
+
last_name: data.last_name,
|
|
11603
|
+
company: data.company,
|
|
11604
|
+
address_1: data.address_1,
|
|
11605
|
+
address_2: data.address_2,
|
|
11606
|
+
city: data.city,
|
|
11607
|
+
province: data.province,
|
|
11608
|
+
country_code: data.country_code,
|
|
11609
|
+
postal_code: data.postal_code,
|
|
11610
|
+
phone: data.phone
|
|
11611
|
+
}
|
|
11612
|
+
},
|
|
11613
|
+
{
|
|
11614
|
+
onSuccess: () => {
|
|
11615
|
+
handleSuccess();
|
|
11616
|
+
},
|
|
11617
|
+
onError: (error) => {
|
|
11618
|
+
ui.toast.error(error.message);
|
|
11619
|
+
}
|
|
11620
|
+
}
|
|
11621
|
+
);
|
|
11622
|
+
});
|
|
11623
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11624
|
+
KeyboundForm,
|
|
11625
|
+
{
|
|
11626
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11627
|
+
onSubmit,
|
|
11628
|
+
children: [
|
|
11629
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
11630
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11631
|
+
Form$2.Field,
|
|
11632
|
+
{
|
|
11633
|
+
control: form.control,
|
|
11634
|
+
name: "country_code",
|
|
11635
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11636
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
11637
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
11638
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11639
|
+
] })
|
|
11640
|
+
}
|
|
11641
|
+
),
|
|
11642
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11575
11643
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11576
|
-
|
|
11644
|
+
Form$2.Field,
|
|
11577
11645
|
{
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11646
|
+
control: form.control,
|
|
11647
|
+
name: "first_name",
|
|
11648
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11649
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
11650
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11651
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11652
|
+
] })
|
|
11582
11653
|
}
|
|
11583
11654
|
),
|
|
11584
11655
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11585
|
-
|
|
11656
|
+
Form$2.Field,
|
|
11586
11657
|
{
|
|
11587
|
-
|
|
11588
|
-
|
|
11589
|
-
|
|
11590
|
-
|
|
11658
|
+
control: form.control,
|
|
11659
|
+
name: "last_name",
|
|
11660
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11661
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
11662
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11663
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11664
|
+
] })
|
|
11591
11665
|
}
|
|
11592
11666
|
)
|
|
11593
11667
|
] }),
|
|
11594
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11595
|
-
|
|
11596
|
-
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
|
|
11601
|
-
|
|
11602
|
-
|
|
11603
|
-
|
|
11604
|
-
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11668
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11669
|
+
Form$2.Field,
|
|
11670
|
+
{
|
|
11671
|
+
control: form.control,
|
|
11672
|
+
name: "company",
|
|
11673
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11674
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11675
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11676
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11677
|
+
] })
|
|
11678
|
+
}
|
|
11679
|
+
),
|
|
11680
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11681
|
+
Form$2.Field,
|
|
11682
|
+
{
|
|
11683
|
+
control: form.control,
|
|
11684
|
+
name: "address_1",
|
|
11685
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11686
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
11687
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11688
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11689
|
+
] })
|
|
11690
|
+
}
|
|
11691
|
+
),
|
|
11692
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11693
|
+
Form$2.Field,
|
|
11694
|
+
{
|
|
11695
|
+
control: form.control,
|
|
11696
|
+
name: "address_2",
|
|
11697
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11698
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11699
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11700
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11701
|
+
] })
|
|
11702
|
+
}
|
|
11703
|
+
),
|
|
11704
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11705
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11706
|
+
Form$2.Field,
|
|
11612
11707
|
{
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
children: [
|
|
11616
|
-
/* @__PURE__ */ jsxRuntime.
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11708
|
+
control: form.control,
|
|
11709
|
+
name: "postal_code",
|
|
11710
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11711
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
11712
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11713
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11714
|
+
] })
|
|
11715
|
+
}
|
|
11716
|
+
),
|
|
11717
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11718
|
+
Form$2.Field,
|
|
11719
|
+
{
|
|
11720
|
+
control: form.control,
|
|
11721
|
+
name: "city",
|
|
11722
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11723
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
11724
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11725
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11726
|
+
] })
|
|
11727
|
+
}
|
|
11728
|
+
)
|
|
11729
|
+
] }),
|
|
11730
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11731
|
+
Form$2.Field,
|
|
11732
|
+
{
|
|
11733
|
+
control: form.control,
|
|
11734
|
+
name: "province",
|
|
11735
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11736
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11737
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11738
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11739
|
+
] })
|
|
11740
|
+
}
|
|
11741
|
+
),
|
|
11742
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11743
|
+
Form$2.Field,
|
|
11744
|
+
{
|
|
11745
|
+
control: form.control,
|
|
11746
|
+
name: "phone",
|
|
11747
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11748
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11749
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11750
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11751
|
+
] })
|
|
11752
|
+
}
|
|
11753
|
+
)
|
|
11754
|
+
] }) }),
|
|
11755
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11756
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11757
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11758
|
+
] }) })
|
|
11759
|
+
]
|
|
11760
|
+
}
|
|
11761
|
+
) });
|
|
11762
|
+
};
|
|
11763
|
+
const schema$1 = addressSchema;
|
|
11764
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11765
|
+
const Shipping = () => {
|
|
11766
|
+
var _a;
|
|
11767
|
+
const { id } = reactRouterDom.useParams();
|
|
11768
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11769
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11770
|
+
});
|
|
11771
|
+
const {
|
|
11772
|
+
order: preview,
|
|
11773
|
+
isPending: isPreviewPending,
|
|
11774
|
+
isError: isPreviewError,
|
|
11775
|
+
error: previewError
|
|
11776
|
+
} = useOrderPreview(id);
|
|
11777
|
+
useInitiateOrderEdit({ preview });
|
|
11778
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11779
|
+
if (isError) {
|
|
11780
|
+
throw error;
|
|
11781
|
+
}
|
|
11782
|
+
if (isPreviewError) {
|
|
11783
|
+
throw previewError;
|
|
11784
|
+
}
|
|
11785
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11786
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11787
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11788
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11789
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
11790
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11791
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11792
|
+
] }) }) }),
|
|
11793
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11794
|
+
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11795
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11796
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11797
|
+
] }) });
|
|
11798
|
+
};
|
|
11799
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11800
|
+
var _a;
|
|
11801
|
+
const { setIsOpen } = useStackedModal();
|
|
11802
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11803
|
+
const [data, setData] = React.useState(null);
|
|
11804
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11805
|
+
const { shipping_options } = useShippingOptions(
|
|
11806
|
+
{
|
|
11807
|
+
id: appliedShippingOptionIds,
|
|
11808
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11809
|
+
},
|
|
11810
|
+
{
|
|
11811
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11812
|
+
}
|
|
11813
|
+
);
|
|
11814
|
+
const uniqueShippingProfiles = React.useMemo(() => {
|
|
11815
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11816
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11817
|
+
profiles.set(profile.id, profile);
|
|
11818
|
+
});
|
|
11819
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11820
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11821
|
+
});
|
|
11822
|
+
return Array.from(profiles.values());
|
|
11823
|
+
}, [order.items, shipping_options]);
|
|
11824
|
+
const { handleSuccess } = useRouteModal();
|
|
11825
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11826
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11827
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11828
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11829
|
+
const onSubmit = async () => {
|
|
11830
|
+
setIsSubmitting(true);
|
|
11831
|
+
let requestSucceeded = false;
|
|
11832
|
+
await requestOrderEdit(void 0, {
|
|
11833
|
+
onError: (e) => {
|
|
11834
|
+
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
11835
|
+
},
|
|
11836
|
+
onSuccess: () => {
|
|
11837
|
+
requestSucceeded = true;
|
|
11838
|
+
}
|
|
11839
|
+
});
|
|
11840
|
+
if (!requestSucceeded) {
|
|
11841
|
+
setIsSubmitting(false);
|
|
11842
|
+
return;
|
|
11843
|
+
}
|
|
11844
|
+
await confirmOrderEdit(void 0, {
|
|
11845
|
+
onError: (e) => {
|
|
11846
|
+
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
11847
|
+
},
|
|
11848
|
+
onSuccess: () => {
|
|
11849
|
+
handleSuccess();
|
|
11850
|
+
},
|
|
11851
|
+
onSettled: () => {
|
|
11852
|
+
setIsSubmitting(false);
|
|
11853
|
+
}
|
|
11854
|
+
});
|
|
11855
|
+
};
|
|
11856
|
+
const onKeydown = React.useCallback(
|
|
11857
|
+
(e) => {
|
|
11858
|
+
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
11859
|
+
if (data || isSubmitting) {
|
|
11860
|
+
return;
|
|
11861
|
+
}
|
|
11862
|
+
onSubmit();
|
|
11863
|
+
}
|
|
11864
|
+
},
|
|
11865
|
+
[data, isSubmitting, onSubmit]
|
|
11866
|
+
);
|
|
11867
|
+
React.useEffect(() => {
|
|
11868
|
+
document.addEventListener("keydown", onKeydown);
|
|
11869
|
+
return () => {
|
|
11870
|
+
document.removeEventListener("keydown", onKeydown);
|
|
11871
|
+
};
|
|
11872
|
+
}, [onKeydown]);
|
|
11873
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
11874
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11875
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11876
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
11877
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11878
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11879
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
11880
|
+
] }),
|
|
11881
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11882
|
+
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
11883
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
|
|
11884
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11885
|
+
ui.Text,
|
|
11886
|
+
{
|
|
11887
|
+
size: "xsmall",
|
|
11888
|
+
weight: "plus",
|
|
11889
|
+
className: "text-ui-fg-muted",
|
|
11890
|
+
children: "Shipping profile"
|
|
11891
|
+
}
|
|
11892
|
+
),
|
|
11893
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11894
|
+
ui.Text,
|
|
11895
|
+
{
|
|
11896
|
+
size: "xsmall",
|
|
11897
|
+
weight: "plus",
|
|
11898
|
+
className: "text-ui-fg-muted",
|
|
11899
|
+
children: "Action"
|
|
11900
|
+
}
|
|
11901
|
+
)
|
|
11902
|
+
] }),
|
|
11903
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-[5px] pb-[5px]", children: uniqueShippingProfiles.map((profile) => {
|
|
11904
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
11905
|
+
const items = getItemsWithShippingProfile(
|
|
11906
|
+
profile.id,
|
|
11907
|
+
order.items
|
|
11908
|
+
);
|
|
11909
|
+
const hasItems = items.length > 0;
|
|
11910
|
+
const shippingOption = shipping_options == null ? void 0 : shipping_options.find(
|
|
11911
|
+
(option) => option.shipping_profile_id === profile.id
|
|
11912
|
+
);
|
|
11913
|
+
const shippingMethod = preview.shipping_methods.find(
|
|
11914
|
+
(method) => method.shipping_option_id === (shippingOption == null ? void 0 : shippingOption.id)
|
|
11915
|
+
);
|
|
11916
|
+
const addShippingMethodAction = (_a2 = shippingMethod == null ? void 0 : shippingMethod.actions) == null ? void 0 : _a2.find(
|
|
11917
|
+
(action) => action.action === "SHIPPING_ADD"
|
|
11918
|
+
);
|
|
11919
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11920
|
+
radixUi.Accordion.Item,
|
|
11921
|
+
{
|
|
11922
|
+
value: profile.id,
|
|
11923
|
+
className: "bg-ui-bg-base shadow-elevation-card-rest rounded-lg",
|
|
11924
|
+
children: [
|
|
11925
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-3 px-3 py-2", children: [
|
|
11926
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center gap-x-3 overflow-hidden", children: [
|
|
11927
|
+
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11928
|
+
ui.IconButton,
|
|
11620
11929
|
{
|
|
11621
11930
|
size: "2xsmall",
|
|
11622
11931
|
variant: "transparent",
|
|
@@ -11878,696 +12187,387 @@ const StackedModalTrigger = ({
|
|
|
11878
12187
|
children
|
|
11879
12188
|
}) => {
|
|
11880
12189
|
const { setIsOpen, getIsOpen } = useStackedModal();
|
|
11881
|
-
const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
|
|
11882
|
-
const onToggle = () => {
|
|
11883
|
-
if (isOpen) {
|
|
11884
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
11885
|
-
setData(null);
|
|
11886
|
-
} else {
|
|
11887
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, true);
|
|
11888
|
-
setData({
|
|
11889
|
-
shippingProfileId,
|
|
11890
|
-
shippingOption,
|
|
11891
|
-
shippingMethod
|
|
11892
|
-
});
|
|
11893
|
-
}
|
|
11894
|
-
};
|
|
11895
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11896
|
-
ui.Button,
|
|
11897
|
-
{
|
|
11898
|
-
size: "small",
|
|
11899
|
-
variant: "secondary",
|
|
11900
|
-
onClick: onToggle,
|
|
11901
|
-
className: "text-ui-fg-primary shrink-0",
|
|
11902
|
-
children
|
|
11903
|
-
}
|
|
11904
|
-
);
|
|
11905
|
-
};
|
|
11906
|
-
const ShippingProfileForm = ({
|
|
11907
|
-
data,
|
|
11908
|
-
order,
|
|
11909
|
-
preview
|
|
11910
|
-
}) => {
|
|
11911
|
-
var _a, _b, _c, _d, _e, _f;
|
|
11912
|
-
const { setIsOpen } = useStackedModal();
|
|
11913
|
-
const form = reactHookForm.useForm({
|
|
11914
|
-
resolver: zod.zodResolver(shippingMethodSchema),
|
|
11915
|
-
defaultValues: {
|
|
11916
|
-
location_id: (_d = (_c = (_b = (_a = data.shippingOption) == null ? void 0 : _a.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.id,
|
|
11917
|
-
shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
|
|
11918
|
-
custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
|
|
11919
|
-
}
|
|
11920
|
-
});
|
|
11921
|
-
const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
|
|
11922
|
-
const {
|
|
11923
|
-
mutateAsync: updateShippingMethod,
|
|
11924
|
-
isPending: isUpdatingShippingMethod
|
|
11925
|
-
} = useDraftOrderUpdateShippingMethod(order.id);
|
|
11926
|
-
const onSubmit = form.handleSubmit(async (values) => {
|
|
11927
|
-
if (isEqual__default.default(values, form.formState.defaultValues)) {
|
|
11928
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
11929
|
-
return;
|
|
11930
|
-
}
|
|
11931
|
-
if (data.shippingMethod) {
|
|
11932
|
-
await updateShippingMethod(
|
|
11933
|
-
{
|
|
11934
|
-
method_id: data.shippingMethod.id,
|
|
11935
|
-
shipping_option_id: values.shipping_option_id,
|
|
11936
|
-
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
11937
|
-
},
|
|
11938
|
-
{
|
|
11939
|
-
onError: (e) => {
|
|
11940
|
-
ui.toast.error(e.message);
|
|
11941
|
-
},
|
|
11942
|
-
onSuccess: () => {
|
|
11943
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
11944
|
-
}
|
|
11945
|
-
}
|
|
11946
|
-
);
|
|
11947
|
-
return;
|
|
11948
|
-
}
|
|
11949
|
-
await addShippingMethod(
|
|
11950
|
-
{
|
|
11951
|
-
shipping_option_id: values.shipping_option_id,
|
|
11952
|
-
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
11953
|
-
},
|
|
11954
|
-
{
|
|
11955
|
-
onError: (e) => {
|
|
11956
|
-
ui.toast.error(e.message);
|
|
11957
|
-
},
|
|
11958
|
-
onSuccess: () => {
|
|
11959
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
11960
|
-
}
|
|
11961
|
-
}
|
|
11962
|
-
);
|
|
11963
|
-
});
|
|
11964
|
-
return /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11965
|
-
KeyboundForm,
|
|
11966
|
-
{
|
|
11967
|
-
className: "flex h-full flex-col overflow-hidden",
|
|
11968
|
-
onSubmit,
|
|
11969
|
-
children: [
|
|
11970
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
|
|
11971
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
11972
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11973
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11974
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
|
|
11975
|
-
] }),
|
|
11976
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11977
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11978
|
-
LocationField,
|
|
11979
|
-
{
|
|
11980
|
-
control: form.control,
|
|
11981
|
-
setValue: form.setValue
|
|
11982
|
-
}
|
|
11983
|
-
),
|
|
11984
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11985
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11986
|
-
ShippingOptionField,
|
|
11987
|
-
{
|
|
11988
|
-
shippingProfileId: data.shippingProfileId,
|
|
11989
|
-
preview,
|
|
11990
|
-
control: form.control
|
|
11991
|
-
}
|
|
11992
|
-
),
|
|
11993
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11994
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11995
|
-
CustomAmountField,
|
|
11996
|
-
{
|
|
11997
|
-
control: form.control,
|
|
11998
|
-
currencyCode: order.currency_code
|
|
11999
|
-
}
|
|
12000
|
-
),
|
|
12001
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12002
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12003
|
-
ItemsPreview,
|
|
12004
|
-
{
|
|
12005
|
-
order,
|
|
12006
|
-
shippingProfileId: data.shippingProfileId
|
|
12007
|
-
}
|
|
12008
|
-
)
|
|
12009
|
-
] }) }) }),
|
|
12010
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
12011
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12012
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12013
|
-
ui.Button,
|
|
12014
|
-
{
|
|
12015
|
-
size: "small",
|
|
12016
|
-
type: "submit",
|
|
12017
|
-
isLoading: isPending || isUpdatingShippingMethod,
|
|
12018
|
-
children: data.shippingMethod ? "Update" : "Add"
|
|
12019
|
-
}
|
|
12020
|
-
)
|
|
12021
|
-
] }) })
|
|
12022
|
-
]
|
|
12023
|
-
}
|
|
12024
|
-
) }) });
|
|
12025
|
-
};
|
|
12026
|
-
const shippingMethodSchema = objectType({
|
|
12027
|
-
location_id: stringType(),
|
|
12028
|
-
shipping_option_id: stringType(),
|
|
12029
|
-
custom_amount: unionType([numberType(), stringType()]).optional()
|
|
12030
|
-
});
|
|
12031
|
-
const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
12032
|
-
const matches = order.items.filter(
|
|
12033
|
-
(item) => {
|
|
12034
|
-
var _a, _b, _c;
|
|
12035
|
-
return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
|
|
12036
|
-
}
|
|
12037
|
-
);
|
|
12038
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-6", children: [
|
|
12039
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12040
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
|
|
12041
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
|
|
12042
|
-
] }) }),
|
|
12043
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
12044
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-muted grid grid-cols-2 gap-3 px-4 py-2", children: [
|
|
12045
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
12046
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) })
|
|
12047
|
-
] }),
|
|
12048
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12049
|
-
"div",
|
|
12050
|
-
{
|
|
12051
|
-
className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-2 items-center gap-3 rounded-lg px-4 py-2",
|
|
12052
|
-
children: [
|
|
12053
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
12054
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12055
|
-
Thumbnail,
|
|
12056
|
-
{
|
|
12057
|
-
thumbnail: item.thumbnail,
|
|
12058
|
-
alt: item.product_title ?? void 0
|
|
12059
|
-
}
|
|
12060
|
-
),
|
|
12061
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12062
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
12063
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
12064
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12065
|
-
ui.Text,
|
|
12066
|
-
{
|
|
12067
|
-
size: "small",
|
|
12068
|
-
leading: "compact",
|
|
12069
|
-
className: "text-ui-fg-subtle",
|
|
12070
|
-
children: [
|
|
12071
|
-
"(",
|
|
12072
|
-
item.variant_title,
|
|
12073
|
-
")"
|
|
12074
|
-
]
|
|
12075
|
-
}
|
|
12076
|
-
)
|
|
12077
|
-
] }),
|
|
12078
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12079
|
-
ui.Text,
|
|
12080
|
-
{
|
|
12081
|
-
size: "small",
|
|
12082
|
-
leading: "compact",
|
|
12083
|
-
className: "text-ui-fg-subtle",
|
|
12084
|
-
children: item.variant_sku
|
|
12085
|
-
}
|
|
12086
|
-
)
|
|
12087
|
-
] })
|
|
12088
|
-
] }),
|
|
12089
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12090
|
-
ui.Text,
|
|
12091
|
-
{
|
|
12092
|
-
size: "small",
|
|
12093
|
-
leading: "compact",
|
|
12094
|
-
className: "text-ui-fg-subtle",
|
|
12095
|
-
children: [
|
|
12096
|
-
item.quantity,
|
|
12097
|
-
"x"
|
|
12098
|
-
]
|
|
12099
|
-
}
|
|
12100
|
-
)
|
|
12101
|
-
]
|
|
12102
|
-
},
|
|
12103
|
-
item.id
|
|
12104
|
-
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
|
|
12105
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
12106
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
12107
|
-
'No items found for "',
|
|
12108
|
-
query,
|
|
12109
|
-
'".'
|
|
12110
|
-
] })
|
|
12111
|
-
] }) })
|
|
12112
|
-
] })
|
|
12113
|
-
] });
|
|
12114
|
-
};
|
|
12115
|
-
const LocationField = ({ control, setValue }) => {
|
|
12116
|
-
const locations = useComboboxData({
|
|
12117
|
-
queryKey: ["locations"],
|
|
12118
|
-
queryFn: async (params) => {
|
|
12119
|
-
return await sdk.admin.stockLocation.list(params);
|
|
12120
|
-
},
|
|
12121
|
-
getOptions: (data) => {
|
|
12122
|
-
return data.stock_locations.map((location) => ({
|
|
12123
|
-
label: location.name,
|
|
12124
|
-
value: location.id
|
|
12125
|
-
}));
|
|
12126
|
-
}
|
|
12127
|
-
});
|
|
12128
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12129
|
-
Form$2.Field,
|
|
12130
|
-
{
|
|
12131
|
-
control,
|
|
12132
|
-
name: "location_id",
|
|
12133
|
-
render: ({ field: { onChange, ...field } }) => {
|
|
12134
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12135
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12136
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Location" }),
|
|
12137
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
|
|
12138
|
-
] }),
|
|
12139
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12140
|
-
Combobox,
|
|
12141
|
-
{
|
|
12142
|
-
options: locations.options,
|
|
12143
|
-
fetchNextPage: locations.fetchNextPage,
|
|
12144
|
-
isFetchingNextPage: locations.isFetchingNextPage,
|
|
12145
|
-
searchValue: locations.searchValue,
|
|
12146
|
-
onSearchValueChange: locations.onSearchValueChange,
|
|
12147
|
-
placeholder: "Select location",
|
|
12148
|
-
onChange: (value) => {
|
|
12149
|
-
setValue("shipping_option_id", "", {
|
|
12150
|
-
shouldDirty: true,
|
|
12151
|
-
shouldTouch: true
|
|
12152
|
-
});
|
|
12153
|
-
onChange(value);
|
|
12154
|
-
},
|
|
12155
|
-
...field
|
|
12156
|
-
}
|
|
12157
|
-
) })
|
|
12158
|
-
] }) });
|
|
12159
|
-
}
|
|
12160
|
-
}
|
|
12161
|
-
);
|
|
12162
|
-
};
|
|
12163
|
-
const ShippingOptionField = ({
|
|
12164
|
-
shippingProfileId,
|
|
12165
|
-
preview,
|
|
12166
|
-
control
|
|
12167
|
-
}) => {
|
|
12168
|
-
var _a;
|
|
12169
|
-
const locationId = reactHookForm.useWatch({ control, name: "location_id" });
|
|
12170
|
-
const shippingOptions = useComboboxData({
|
|
12171
|
-
queryKey: ["shipping_options", locationId, shippingProfileId],
|
|
12172
|
-
queryFn: async (params) => {
|
|
12173
|
-
return await sdk.admin.shippingOption.list({
|
|
12174
|
-
...params,
|
|
12175
|
-
stock_location_id: locationId,
|
|
12176
|
-
shipping_profile_id: shippingProfileId
|
|
12177
|
-
});
|
|
12178
|
-
},
|
|
12179
|
-
getOptions: (data) => {
|
|
12180
|
-
return data.shipping_options.map((option) => {
|
|
12181
|
-
var _a2;
|
|
12182
|
-
if ((_a2 = option.rules) == null ? void 0 : _a2.find(
|
|
12183
|
-
(r) => r.attribute === "is_return" && r.value === "true"
|
|
12184
|
-
)) {
|
|
12185
|
-
return void 0;
|
|
12186
|
-
}
|
|
12187
|
-
return {
|
|
12188
|
-
label: option.name,
|
|
12189
|
-
value: option.id
|
|
12190
|
-
};
|
|
12191
|
-
}).filter(Boolean);
|
|
12192
|
-
},
|
|
12193
|
-
enabled: !!locationId && !!shippingProfileId,
|
|
12194
|
-
defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
|
|
12195
|
-
});
|
|
12196
|
-
const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
|
|
12197
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12198
|
-
Form$2.Field,
|
|
12199
|
-
{
|
|
12200
|
-
control,
|
|
12201
|
-
name: "shipping_option_id",
|
|
12202
|
-
render: ({ field }) => {
|
|
12203
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12204
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12205
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
|
|
12206
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
|
|
12207
|
-
] }),
|
|
12208
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12209
|
-
ConditionalTooltip,
|
|
12210
|
-
{
|
|
12211
|
-
content: tooltipContent,
|
|
12212
|
-
showTooltip: !locationId || !shippingProfileId,
|
|
12213
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12214
|
-
Combobox,
|
|
12215
|
-
{
|
|
12216
|
-
options: shippingOptions.options,
|
|
12217
|
-
fetchNextPage: shippingOptions.fetchNextPage,
|
|
12218
|
-
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
12219
|
-
searchValue: shippingOptions.searchValue,
|
|
12220
|
-
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
12221
|
-
placeholder: "Select shipping option",
|
|
12222
|
-
...field,
|
|
12223
|
-
disabled: !locationId || !shippingProfileId
|
|
12224
|
-
}
|
|
12225
|
-
) }) })
|
|
12226
|
-
}
|
|
12227
|
-
)
|
|
12228
|
-
] }) });
|
|
12229
|
-
}
|
|
12230
|
-
}
|
|
12231
|
-
);
|
|
12232
|
-
};
|
|
12233
|
-
const CustomAmountField = ({
|
|
12234
|
-
control,
|
|
12235
|
-
currencyCode
|
|
12236
|
-
}) => {
|
|
12237
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12238
|
-
Form$2.Field,
|
|
12239
|
-
{
|
|
12240
|
-
control,
|
|
12241
|
-
name: "custom_amount",
|
|
12242
|
-
render: ({ field: { onChange, ...field } }) => {
|
|
12243
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12244
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12245
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
|
|
12246
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
|
|
12247
|
-
] }),
|
|
12248
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12249
|
-
ui.CurrencyInput,
|
|
12250
|
-
{
|
|
12251
|
-
...field,
|
|
12252
|
-
onValueChange: (value) => onChange(value),
|
|
12253
|
-
symbol: getNativeSymbol(currencyCode),
|
|
12254
|
-
code: currencyCode
|
|
12255
|
-
}
|
|
12256
|
-
) })
|
|
12257
|
-
] });
|
|
12258
|
-
}
|
|
12259
|
-
}
|
|
12260
|
-
);
|
|
12261
|
-
};
|
|
12262
|
-
const SalesChannel = () => {
|
|
12263
|
-
const { id } = reactRouterDom.useParams();
|
|
12264
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12265
|
-
id,
|
|
12266
|
-
{
|
|
12267
|
-
fields: "+sales_channel_id"
|
|
12268
|
-
},
|
|
12269
|
-
{
|
|
12270
|
-
enabled: !!id
|
|
12271
|
-
}
|
|
12272
|
-
);
|
|
12273
|
-
if (isError) {
|
|
12274
|
-
throw error;
|
|
12275
|
-
}
|
|
12276
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12277
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12278
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12279
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12280
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12281
|
-
] }),
|
|
12282
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12283
|
-
] });
|
|
12284
|
-
};
|
|
12285
|
-
const SalesChannelForm = ({ order }) => {
|
|
12286
|
-
const form = reactHookForm.useForm({
|
|
12287
|
-
defaultValues: {
|
|
12288
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12289
|
-
},
|
|
12290
|
-
resolver: zod.zodResolver(schema$2)
|
|
12291
|
-
});
|
|
12292
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12293
|
-
const { handleSuccess } = useRouteModal();
|
|
12294
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12295
|
-
await mutateAsync(
|
|
12296
|
-
{
|
|
12297
|
-
sales_channel_id: data.sales_channel_id
|
|
12298
|
-
},
|
|
12299
|
-
{
|
|
12300
|
-
onSuccess: () => {
|
|
12301
|
-
ui.toast.success("Sales channel updated");
|
|
12302
|
-
handleSuccess();
|
|
12303
|
-
},
|
|
12304
|
-
onError: (error) => {
|
|
12305
|
-
ui.toast.error(error.message);
|
|
12306
|
-
}
|
|
12307
|
-
}
|
|
12308
|
-
);
|
|
12309
|
-
});
|
|
12310
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12311
|
-
KeyboundForm,
|
|
12312
|
-
{
|
|
12313
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12314
|
-
onSubmit,
|
|
12315
|
-
children: [
|
|
12316
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12317
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12318
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12319
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12320
|
-
] }) })
|
|
12321
|
-
]
|
|
12322
|
-
}
|
|
12323
|
-
) });
|
|
12324
|
-
};
|
|
12325
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12326
|
-
const salesChannels = useComboboxData({
|
|
12327
|
-
queryFn: async (params) => {
|
|
12328
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12329
|
-
},
|
|
12330
|
-
queryKey: ["sales-channels"],
|
|
12331
|
-
getOptions: (data) => {
|
|
12332
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
12333
|
-
label: salesChannel.name,
|
|
12334
|
-
value: salesChannel.id
|
|
12335
|
-
}));
|
|
12336
|
-
},
|
|
12337
|
-
defaultValue: order.sales_channel_id || void 0
|
|
12338
|
-
});
|
|
12339
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12340
|
-
Form$2.Field,
|
|
12341
|
-
{
|
|
12342
|
-
control,
|
|
12343
|
-
name: "sales_channel_id",
|
|
12344
|
-
render: ({ field }) => {
|
|
12345
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12346
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12347
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12348
|
-
Combobox,
|
|
12349
|
-
{
|
|
12350
|
-
options: salesChannels.options,
|
|
12351
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12352
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12353
|
-
searchValue: salesChannels.searchValue,
|
|
12354
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12355
|
-
placeholder: "Select sales channel",
|
|
12356
|
-
...field
|
|
12357
|
-
}
|
|
12358
|
-
) }),
|
|
12359
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12360
|
-
] });
|
|
12361
|
-
}
|
|
12190
|
+
const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
|
|
12191
|
+
const onToggle = () => {
|
|
12192
|
+
if (isOpen) {
|
|
12193
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
12194
|
+
setData(null);
|
|
12195
|
+
} else {
|
|
12196
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, true);
|
|
12197
|
+
setData({
|
|
12198
|
+
shippingProfileId,
|
|
12199
|
+
shippingOption,
|
|
12200
|
+
shippingMethod
|
|
12201
|
+
});
|
|
12202
|
+
}
|
|
12203
|
+
};
|
|
12204
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12205
|
+
ui.Button,
|
|
12206
|
+
{
|
|
12207
|
+
size: "small",
|
|
12208
|
+
variant: "secondary",
|
|
12209
|
+
onClick: onToggle,
|
|
12210
|
+
className: "text-ui-fg-primary shrink-0",
|
|
12211
|
+
children
|
|
12362
12212
|
}
|
|
12363
12213
|
);
|
|
12364
12214
|
};
|
|
12365
|
-
const
|
|
12366
|
-
|
|
12367
|
-
|
|
12368
|
-
|
|
12369
|
-
|
|
12370
|
-
|
|
12371
|
-
|
|
12372
|
-
});
|
|
12373
|
-
if (isError) {
|
|
12374
|
-
throw error;
|
|
12375
|
-
}
|
|
12376
|
-
const isReady = !isPending && !!order;
|
|
12377
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12378
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12379
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
12380
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12381
|
-
] }),
|
|
12382
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
12383
|
-
] });
|
|
12384
|
-
};
|
|
12385
|
-
const ShippingAddressForm = ({ order }) => {
|
|
12386
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12215
|
+
const ShippingProfileForm = ({
|
|
12216
|
+
data,
|
|
12217
|
+
order,
|
|
12218
|
+
preview
|
|
12219
|
+
}) => {
|
|
12220
|
+
var _a, _b, _c, _d, _e, _f;
|
|
12221
|
+
const { setIsOpen } = useStackedModal();
|
|
12387
12222
|
const form = reactHookForm.useForm({
|
|
12223
|
+
resolver: zod.zodResolver(shippingMethodSchema),
|
|
12388
12224
|
defaultValues: {
|
|
12389
|
-
|
|
12390
|
-
|
|
12391
|
-
|
|
12392
|
-
|
|
12393
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12394
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12395
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12396
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12397
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12398
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12399
|
-
},
|
|
12400
|
-
resolver: zod.zodResolver(schema$1)
|
|
12225
|
+
location_id: (_d = (_c = (_b = (_a = data.shippingOption) == null ? void 0 : _a.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.id,
|
|
12226
|
+
shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
|
|
12227
|
+
custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
|
|
12228
|
+
}
|
|
12401
12229
|
});
|
|
12402
|
-
const { mutateAsync, isPending } =
|
|
12403
|
-
const {
|
|
12404
|
-
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12410
|
-
|
|
12411
|
-
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12415
|
-
|
|
12416
|
-
|
|
12417
|
-
|
|
12230
|
+
const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
|
|
12231
|
+
const {
|
|
12232
|
+
mutateAsync: updateShippingMethod,
|
|
12233
|
+
isPending: isUpdatingShippingMethod
|
|
12234
|
+
} = useDraftOrderUpdateShippingMethod(order.id);
|
|
12235
|
+
const onSubmit = form.handleSubmit(async (values) => {
|
|
12236
|
+
if (isEqual__default.default(values, form.formState.defaultValues)) {
|
|
12237
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
12238
|
+
return;
|
|
12239
|
+
}
|
|
12240
|
+
if (data.shippingMethod) {
|
|
12241
|
+
await updateShippingMethod(
|
|
12242
|
+
{
|
|
12243
|
+
method_id: data.shippingMethod.id,
|
|
12244
|
+
shipping_option_id: values.shipping_option_id,
|
|
12245
|
+
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
12246
|
+
},
|
|
12247
|
+
{
|
|
12248
|
+
onError: (e) => {
|
|
12249
|
+
ui.toast.error(e.message);
|
|
12250
|
+
},
|
|
12251
|
+
onSuccess: () => {
|
|
12252
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
12253
|
+
}
|
|
12418
12254
|
}
|
|
12255
|
+
);
|
|
12256
|
+
return;
|
|
12257
|
+
}
|
|
12258
|
+
await addShippingMethod(
|
|
12259
|
+
{
|
|
12260
|
+
shipping_option_id: values.shipping_option_id,
|
|
12261
|
+
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
12419
12262
|
},
|
|
12420
12263
|
{
|
|
12421
|
-
|
|
12422
|
-
|
|
12264
|
+
onError: (e) => {
|
|
12265
|
+
ui.toast.error(e.message);
|
|
12423
12266
|
},
|
|
12424
|
-
|
|
12425
|
-
|
|
12267
|
+
onSuccess: () => {
|
|
12268
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
12426
12269
|
}
|
|
12427
12270
|
}
|
|
12428
12271
|
);
|
|
12429
12272
|
});
|
|
12430
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12273
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12431
12274
|
KeyboundForm,
|
|
12432
12275
|
{
|
|
12433
|
-
className: "flex
|
|
12276
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
12434
12277
|
onSubmit,
|
|
12435
12278
|
children: [
|
|
12436
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12279
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
|
|
12280
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
12281
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12282
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
12283
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
|
|
12284
|
+
] }),
|
|
12285
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12437
12286
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12438
|
-
|
|
12287
|
+
LocationField,
|
|
12439
12288
|
{
|
|
12440
12289
|
control: form.control,
|
|
12441
|
-
|
|
12442
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12443
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
12444
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12445
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12446
|
-
] })
|
|
12290
|
+
setValue: form.setValue
|
|
12447
12291
|
}
|
|
12448
12292
|
),
|
|
12449
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12450
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12451
|
-
Form$2.Field,
|
|
12452
|
-
{
|
|
12453
|
-
control: form.control,
|
|
12454
|
-
name: "first_name",
|
|
12455
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12456
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12457
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12458
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12459
|
-
] })
|
|
12460
|
-
}
|
|
12461
|
-
),
|
|
12462
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12463
|
-
Form$2.Field,
|
|
12464
|
-
{
|
|
12465
|
-
control: form.control,
|
|
12466
|
-
name: "last_name",
|
|
12467
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12468
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12469
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12470
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12471
|
-
] })
|
|
12472
|
-
}
|
|
12473
|
-
)
|
|
12474
|
-
] }),
|
|
12293
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12475
12294
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12476
|
-
|
|
12295
|
+
ShippingOptionField,
|
|
12477
12296
|
{
|
|
12478
|
-
|
|
12479
|
-
|
|
12480
|
-
|
|
12481
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12482
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12483
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12484
|
-
] })
|
|
12297
|
+
shippingProfileId: data.shippingProfileId,
|
|
12298
|
+
preview,
|
|
12299
|
+
control: form.control
|
|
12485
12300
|
}
|
|
12486
12301
|
),
|
|
12302
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12487
12303
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12488
|
-
|
|
12304
|
+
CustomAmountField,
|
|
12489
12305
|
{
|
|
12490
12306
|
control: form.control,
|
|
12491
|
-
|
|
12492
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12493
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
12494
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12495
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12496
|
-
] })
|
|
12307
|
+
currencyCode: order.currency_code
|
|
12497
12308
|
}
|
|
12498
12309
|
),
|
|
12310
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12499
12311
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12500
|
-
|
|
12312
|
+
ItemsPreview,
|
|
12501
12313
|
{
|
|
12502
|
-
|
|
12503
|
-
|
|
12504
|
-
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
|
|
12314
|
+
order,
|
|
12315
|
+
shippingProfileId: data.shippingProfileId
|
|
12316
|
+
}
|
|
12317
|
+
)
|
|
12318
|
+
] }) }) }),
|
|
12319
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
12320
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12321
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12322
|
+
ui.Button,
|
|
12323
|
+
{
|
|
12324
|
+
size: "small",
|
|
12325
|
+
type: "submit",
|
|
12326
|
+
isLoading: isPending || isUpdatingShippingMethod,
|
|
12327
|
+
children: data.shippingMethod ? "Update" : "Add"
|
|
12328
|
+
}
|
|
12329
|
+
)
|
|
12330
|
+
] }) })
|
|
12331
|
+
]
|
|
12332
|
+
}
|
|
12333
|
+
) }) });
|
|
12334
|
+
};
|
|
12335
|
+
const shippingMethodSchema = objectType({
|
|
12336
|
+
location_id: stringType(),
|
|
12337
|
+
shipping_option_id: stringType(),
|
|
12338
|
+
custom_amount: unionType([numberType(), stringType()]).optional()
|
|
12339
|
+
});
|
|
12340
|
+
const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
12341
|
+
const matches = order.items.filter(
|
|
12342
|
+
(item) => {
|
|
12343
|
+
var _a, _b, _c;
|
|
12344
|
+
return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
|
|
12345
|
+
}
|
|
12346
|
+
);
|
|
12347
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-6", children: [
|
|
12348
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12349
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
|
|
12350
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
|
|
12351
|
+
] }) }),
|
|
12352
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
12353
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-muted grid grid-cols-2 gap-3 px-4 py-2", children: [
|
|
12354
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
12355
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) })
|
|
12356
|
+
] }),
|
|
12357
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12358
|
+
"div",
|
|
12359
|
+
{
|
|
12360
|
+
className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-2 items-center gap-3 rounded-lg px-4 py-2",
|
|
12361
|
+
children: [
|
|
12362
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
12363
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12364
|
+
Thumbnail,
|
|
12365
|
+
{
|
|
12366
|
+
thumbnail: item.thumbnail,
|
|
12367
|
+
alt: item.product_title ?? void 0
|
|
12368
|
+
}
|
|
12369
|
+
),
|
|
12370
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12371
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
12372
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
12373
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12374
|
+
ui.Text,
|
|
12375
|
+
{
|
|
12376
|
+
size: "small",
|
|
12377
|
+
leading: "compact",
|
|
12378
|
+
className: "text-ui-fg-subtle",
|
|
12379
|
+
children: [
|
|
12380
|
+
"(",
|
|
12381
|
+
item.variant_title,
|
|
12382
|
+
")"
|
|
12383
|
+
]
|
|
12384
|
+
}
|
|
12385
|
+
)
|
|
12386
|
+
] }),
|
|
12387
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12388
|
+
ui.Text,
|
|
12389
|
+
{
|
|
12390
|
+
size: "small",
|
|
12391
|
+
leading: "compact",
|
|
12392
|
+
className: "text-ui-fg-subtle",
|
|
12393
|
+
children: item.variant_sku
|
|
12394
|
+
}
|
|
12395
|
+
)
|
|
12508
12396
|
] })
|
|
12509
|
-
}
|
|
12510
|
-
|
|
12511
|
-
|
|
12512
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12513
|
-
Form$2.Field,
|
|
12514
|
-
{
|
|
12515
|
-
control: form.control,
|
|
12516
|
-
name: "postal_code",
|
|
12517
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12518
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12519
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12520
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12521
|
-
] })
|
|
12522
|
-
}
|
|
12523
|
-
),
|
|
12524
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12525
|
-
Form$2.Field,
|
|
12397
|
+
] }),
|
|
12398
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12399
|
+
ui.Text,
|
|
12526
12400
|
{
|
|
12527
|
-
|
|
12528
|
-
|
|
12529
|
-
|
|
12530
|
-
|
|
12531
|
-
|
|
12532
|
-
|
|
12533
|
-
]
|
|
12401
|
+
size: "small",
|
|
12402
|
+
leading: "compact",
|
|
12403
|
+
className: "text-ui-fg-subtle",
|
|
12404
|
+
children: [
|
|
12405
|
+
item.quantity,
|
|
12406
|
+
"x"
|
|
12407
|
+
]
|
|
12534
12408
|
}
|
|
12535
12409
|
)
|
|
12410
|
+
]
|
|
12411
|
+
},
|
|
12412
|
+
item.id
|
|
12413
|
+
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
|
|
12414
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
12415
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
12416
|
+
'No items found for "',
|
|
12417
|
+
query,
|
|
12418
|
+
'".'
|
|
12419
|
+
] })
|
|
12420
|
+
] }) })
|
|
12421
|
+
] })
|
|
12422
|
+
] });
|
|
12423
|
+
};
|
|
12424
|
+
const LocationField = ({ control, setValue }) => {
|
|
12425
|
+
const locations = useComboboxData({
|
|
12426
|
+
queryKey: ["locations"],
|
|
12427
|
+
queryFn: async (params) => {
|
|
12428
|
+
return await sdk.admin.stockLocation.list(params);
|
|
12429
|
+
},
|
|
12430
|
+
getOptions: (data) => {
|
|
12431
|
+
return data.stock_locations.map((location) => ({
|
|
12432
|
+
label: location.name,
|
|
12433
|
+
value: location.id
|
|
12434
|
+
}));
|
|
12435
|
+
}
|
|
12436
|
+
});
|
|
12437
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12438
|
+
Form$2.Field,
|
|
12439
|
+
{
|
|
12440
|
+
control,
|
|
12441
|
+
name: "location_id",
|
|
12442
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
12443
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12444
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12445
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Location" }),
|
|
12446
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
|
|
12536
12447
|
] }),
|
|
12537
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12538
|
-
|
|
12448
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12449
|
+
Combobox,
|
|
12539
12450
|
{
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12451
|
+
options: locations.options,
|
|
12452
|
+
fetchNextPage: locations.fetchNextPage,
|
|
12453
|
+
isFetchingNextPage: locations.isFetchingNextPage,
|
|
12454
|
+
searchValue: locations.searchValue,
|
|
12455
|
+
onSearchValueChange: locations.onSearchValueChange,
|
|
12456
|
+
placeholder: "Select location",
|
|
12457
|
+
onChange: (value) => {
|
|
12458
|
+
setValue("shipping_option_id", "", {
|
|
12459
|
+
shouldDirty: true,
|
|
12460
|
+
shouldTouch: true
|
|
12461
|
+
});
|
|
12462
|
+
onChange(value);
|
|
12463
|
+
},
|
|
12464
|
+
...field
|
|
12547
12465
|
}
|
|
12548
|
-
)
|
|
12466
|
+
) })
|
|
12467
|
+
] }) });
|
|
12468
|
+
}
|
|
12469
|
+
}
|
|
12470
|
+
);
|
|
12471
|
+
};
|
|
12472
|
+
const ShippingOptionField = ({
|
|
12473
|
+
shippingProfileId,
|
|
12474
|
+
preview,
|
|
12475
|
+
control
|
|
12476
|
+
}) => {
|
|
12477
|
+
var _a;
|
|
12478
|
+
const locationId = reactHookForm.useWatch({ control, name: "location_id" });
|
|
12479
|
+
const shippingOptions = useComboboxData({
|
|
12480
|
+
queryKey: ["shipping_options", locationId, shippingProfileId],
|
|
12481
|
+
queryFn: async (params) => {
|
|
12482
|
+
return await sdk.admin.shippingOption.list({
|
|
12483
|
+
...params,
|
|
12484
|
+
stock_location_id: locationId,
|
|
12485
|
+
shipping_profile_id: shippingProfileId
|
|
12486
|
+
});
|
|
12487
|
+
},
|
|
12488
|
+
getOptions: (data) => {
|
|
12489
|
+
return data.shipping_options.map((option) => {
|
|
12490
|
+
var _a2;
|
|
12491
|
+
if ((_a2 = option.rules) == null ? void 0 : _a2.find(
|
|
12492
|
+
(r) => r.attribute === "is_return" && r.value === "true"
|
|
12493
|
+
)) {
|
|
12494
|
+
return void 0;
|
|
12495
|
+
}
|
|
12496
|
+
return {
|
|
12497
|
+
label: option.name,
|
|
12498
|
+
value: option.id
|
|
12499
|
+
};
|
|
12500
|
+
}).filter(Boolean);
|
|
12501
|
+
},
|
|
12502
|
+
enabled: !!locationId && !!shippingProfileId,
|
|
12503
|
+
defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
|
|
12504
|
+
});
|
|
12505
|
+
const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
|
|
12506
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12507
|
+
Form$2.Field,
|
|
12508
|
+
{
|
|
12509
|
+
control,
|
|
12510
|
+
name: "shipping_option_id",
|
|
12511
|
+
render: ({ field }) => {
|
|
12512
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12513
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12514
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
|
|
12515
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
|
|
12516
|
+
] }),
|
|
12549
12517
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12550
|
-
|
|
12518
|
+
ConditionalTooltip,
|
|
12551
12519
|
{
|
|
12552
|
-
|
|
12553
|
-
|
|
12554
|
-
|
|
12555
|
-
|
|
12556
|
-
|
|
12557
|
-
|
|
12558
|
-
|
|
12520
|
+
content: tooltipContent,
|
|
12521
|
+
showTooltip: !locationId || !shippingProfileId,
|
|
12522
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12523
|
+
Combobox,
|
|
12524
|
+
{
|
|
12525
|
+
options: shippingOptions.options,
|
|
12526
|
+
fetchNextPage: shippingOptions.fetchNextPage,
|
|
12527
|
+
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
12528
|
+
searchValue: shippingOptions.searchValue,
|
|
12529
|
+
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
12530
|
+
placeholder: "Select shipping option",
|
|
12531
|
+
...field,
|
|
12532
|
+
disabled: !locationId || !shippingProfileId
|
|
12533
|
+
}
|
|
12534
|
+
) }) })
|
|
12559
12535
|
}
|
|
12560
12536
|
)
|
|
12561
|
-
] }) })
|
|
12562
|
-
|
|
12563
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12564
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12565
|
-
] }) })
|
|
12566
|
-
]
|
|
12537
|
+
] }) });
|
|
12538
|
+
}
|
|
12567
12539
|
}
|
|
12568
|
-
)
|
|
12540
|
+
);
|
|
12541
|
+
};
|
|
12542
|
+
const CustomAmountField = ({
|
|
12543
|
+
control,
|
|
12544
|
+
currencyCode
|
|
12545
|
+
}) => {
|
|
12546
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12547
|
+
Form$2.Field,
|
|
12548
|
+
{
|
|
12549
|
+
control,
|
|
12550
|
+
name: "custom_amount",
|
|
12551
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
12552
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12553
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12554
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
|
|
12555
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
|
|
12556
|
+
] }),
|
|
12557
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12558
|
+
ui.CurrencyInput,
|
|
12559
|
+
{
|
|
12560
|
+
...field,
|
|
12561
|
+
onValueChange: (value) => onChange(value),
|
|
12562
|
+
symbol: getNativeSymbol(currencyCode),
|
|
12563
|
+
code: currencyCode
|
|
12564
|
+
}
|
|
12565
|
+
) })
|
|
12566
|
+
] });
|
|
12567
|
+
}
|
|
12568
|
+
}
|
|
12569
|
+
);
|
|
12569
12570
|
};
|
|
12570
|
-
const schema$1 = addressSchema;
|
|
12571
12571
|
const TransferOwnership = () => {
|
|
12572
12572
|
const { id } = reactRouterDom.useParams();
|
|
12573
12573
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -13072,14 +13072,14 @@ const routeModule = {
|
|
|
13072
13072
|
Component: CustomItems,
|
|
13073
13073
|
path: "/draft-orders/:id/custom-items"
|
|
13074
13074
|
},
|
|
13075
|
-
{
|
|
13076
|
-
Component: Items,
|
|
13077
|
-
path: "/draft-orders/:id/items"
|
|
13078
|
-
},
|
|
13079
13075
|
{
|
|
13080
13076
|
Component: Email,
|
|
13081
13077
|
path: "/draft-orders/:id/email"
|
|
13082
13078
|
},
|
|
13079
|
+
{
|
|
13080
|
+
Component: Items,
|
|
13081
|
+
path: "/draft-orders/:id/items"
|
|
13082
|
+
},
|
|
13083
13083
|
{
|
|
13084
13084
|
Component: Metadata,
|
|
13085
13085
|
path: "/draft-orders/:id/metadata"
|
|
@@ -13088,10 +13088,6 @@ const routeModule = {
|
|
|
13088
13088
|
Component: Promotions,
|
|
13089
13089
|
path: "/draft-orders/:id/promotions"
|
|
13090
13090
|
},
|
|
13091
|
-
{
|
|
13092
|
-
Component: Shipping,
|
|
13093
|
-
path: "/draft-orders/:id/shipping"
|
|
13094
|
-
},
|
|
13095
13091
|
{
|
|
13096
13092
|
Component: SalesChannel,
|
|
13097
13093
|
path: "/draft-orders/:id/sales-channel"
|
|
@@ -13100,6 +13096,10 @@ const routeModule = {
|
|
|
13100
13096
|
Component: ShippingAddress,
|
|
13101
13097
|
path: "/draft-orders/:id/shipping-address"
|
|
13102
13098
|
},
|
|
13099
|
+
{
|
|
13100
|
+
Component: Shipping,
|
|
13101
|
+
path: "/draft-orders/:id/shipping"
|
|
13102
|
+
},
|
|
13103
13103
|
{
|
|
13104
13104
|
Component: TransferOwnership,
|
|
13105
13105
|
path: "/draft-orders/:id/transfer-ownership"
|