@medusajs/draft-order 2.12.4-snapshot-20251226061341 → 2.12.4-snapshot-20251226070522
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 +209 -209
- package/.medusa/server/src/admin/index.mjs +209 -209
- package/package.json +16 -16
|
@@ -9572,6 +9572,27 @@ const ID = () => {
|
|
|
9572
9572
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9573
9573
|
] });
|
|
9574
9574
|
};
|
|
9575
|
+
const CustomItems = () => {
|
|
9576
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9577
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9578
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9579
|
+
] });
|
|
9580
|
+
};
|
|
9581
|
+
const CustomItemsForm = () => {
|
|
9582
|
+
const form = reactHookForm.useForm({
|
|
9583
|
+
resolver: zod.zodResolver(schema$5)
|
|
9584
|
+
});
|
|
9585
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9586
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9587
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9588
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9589
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9590
|
+
] }) })
|
|
9591
|
+
] }) });
|
|
9592
|
+
};
|
|
9593
|
+
const schema$5 = objectType({
|
|
9594
|
+
email: stringType().email()
|
|
9595
|
+
});
|
|
9575
9596
|
const BillingAddress = () => {
|
|
9576
9597
|
const { id } = reactRouterDom.useParams();
|
|
9577
9598
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9604,7 +9625,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9604
9625
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9605
9626
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9606
9627
|
},
|
|
9607
|
-
resolver: zod.zodResolver(schema$
|
|
9628
|
+
resolver: zod.zodResolver(schema$4)
|
|
9608
9629
|
});
|
|
9609
9630
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9610
9631
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9761,96 +9782,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9761
9782
|
}
|
|
9762
9783
|
) });
|
|
9763
9784
|
};
|
|
9764
|
-
const schema$
|
|
9765
|
-
const CustomItems = () => {
|
|
9766
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9767
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9768
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9769
|
-
] });
|
|
9770
|
-
};
|
|
9771
|
-
const CustomItemsForm = () => {
|
|
9772
|
-
const form = reactHookForm.useForm({
|
|
9773
|
-
resolver: zod.zodResolver(schema$4)
|
|
9774
|
-
});
|
|
9775
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9776
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9777
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9778
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9779
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9780
|
-
] }) })
|
|
9781
|
-
] }) });
|
|
9782
|
-
};
|
|
9783
|
-
const schema$4 = objectType({
|
|
9784
|
-
email: stringType().email()
|
|
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
|
-
});
|
|
9785
|
+
const schema$4 = addressSchema;
|
|
9854
9786
|
const NumberInput = React.forwardRef(
|
|
9855
9787
|
({
|
|
9856
9788
|
value,
|
|
@@ -10825,6 +10757,74 @@ const customItemSchema = objectType({
|
|
|
10825
10757
|
quantity: numberType(),
|
|
10826
10758
|
unit_price: unionType([numberType(), stringType()])
|
|
10827
10759
|
});
|
|
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,6 +11452,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11452
11452
|
}
|
|
11453
11453
|
return Array.from(promotionIds);
|
|
11454
11454
|
}
|
|
11455
|
+
const SalesChannel = () => {
|
|
11456
|
+
const { id } = reactRouterDom.useParams();
|
|
11457
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11458
|
+
id,
|
|
11459
|
+
{
|
|
11460
|
+
fields: "+sales_channel_id"
|
|
11461
|
+
},
|
|
11462
|
+
{
|
|
11463
|
+
enabled: !!id
|
|
11464
|
+
}
|
|
11465
|
+
);
|
|
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);
|
|
11486
|
+
const { handleSuccess } = useRouteModal();
|
|
11487
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11488
|
+
await mutateAsync(
|
|
11489
|
+
{
|
|
11490
|
+
sales_channel_id: data.sales_channel_id
|
|
11491
|
+
},
|
|
11492
|
+
{
|
|
11493
|
+
onSuccess: () => {
|
|
11494
|
+
ui.toast.success("Sales channel updated");
|
|
11495
|
+
handleSuccess();
|
|
11496
|
+
},
|
|
11497
|
+
onError: (error) => {
|
|
11498
|
+
ui.toast.error(error.message);
|
|
11499
|
+
}
|
|
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);
|
|
11522
|
+
},
|
|
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
|
+
}
|
|
11556
|
+
);
|
|
11557
|
+
};
|
|
11558
|
+
const schema$2 = objectType({
|
|
11559
|
+
sales_channel_id: stringType().min(1)
|
|
11560
|
+
});
|
|
11455
11561
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11456
11562
|
const Shipping = () => {
|
|
11457
11563
|
var _a;
|
|
@@ -12291,7 +12397,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12291
12397
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12292
12398
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12293
12399
|
},
|
|
12294
|
-
resolver: zod.zodResolver(schema$
|
|
12400
|
+
resolver: zod.zodResolver(schema$1)
|
|
12295
12401
|
});
|
|
12296
12402
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12297
12403
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12461,113 +12567,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12461
12567
|
}
|
|
12462
12568
|
) });
|
|
12463
12569
|
};
|
|
12464
|
-
const schema$
|
|
12465
|
-
const SalesChannel = () => {
|
|
12466
|
-
const { id } = reactRouterDom.useParams();
|
|
12467
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12468
|
-
id,
|
|
12469
|
-
{
|
|
12470
|
-
fields: "+sales_channel_id"
|
|
12471
|
-
},
|
|
12472
|
-
{
|
|
12473
|
-
enabled: !!id
|
|
12474
|
-
}
|
|
12475
|
-
);
|
|
12476
|
-
if (isError) {
|
|
12477
|
-
throw error;
|
|
12478
|
-
}
|
|
12479
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12480
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12481
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12482
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12483
|
-
/* @__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" }) })
|
|
12484
|
-
] }),
|
|
12485
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12486
|
-
] });
|
|
12487
|
-
};
|
|
12488
|
-
const SalesChannelForm = ({ order }) => {
|
|
12489
|
-
const form = reactHookForm.useForm({
|
|
12490
|
-
defaultValues: {
|
|
12491
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12492
|
-
},
|
|
12493
|
-
resolver: zod.zodResolver(schema$1)
|
|
12494
|
-
});
|
|
12495
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12496
|
-
const { handleSuccess } = useRouteModal();
|
|
12497
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12498
|
-
await mutateAsync(
|
|
12499
|
-
{
|
|
12500
|
-
sales_channel_id: data.sales_channel_id
|
|
12501
|
-
},
|
|
12502
|
-
{
|
|
12503
|
-
onSuccess: () => {
|
|
12504
|
-
ui.toast.success("Sales channel updated");
|
|
12505
|
-
handleSuccess();
|
|
12506
|
-
},
|
|
12507
|
-
onError: (error) => {
|
|
12508
|
-
ui.toast.error(error.message);
|
|
12509
|
-
}
|
|
12510
|
-
}
|
|
12511
|
-
);
|
|
12512
|
-
});
|
|
12513
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12514
|
-
KeyboundForm,
|
|
12515
|
-
{
|
|
12516
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12517
|
-
onSubmit,
|
|
12518
|
-
children: [
|
|
12519
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12520
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12521
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12522
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12523
|
-
] }) })
|
|
12524
|
-
]
|
|
12525
|
-
}
|
|
12526
|
-
) });
|
|
12527
|
-
};
|
|
12528
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12529
|
-
const salesChannels = useComboboxData({
|
|
12530
|
-
queryFn: async (params) => {
|
|
12531
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12532
|
-
},
|
|
12533
|
-
queryKey: ["sales-channels"],
|
|
12534
|
-
getOptions: (data) => {
|
|
12535
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
12536
|
-
label: salesChannel.name,
|
|
12537
|
-
value: salesChannel.id
|
|
12538
|
-
}));
|
|
12539
|
-
},
|
|
12540
|
-
defaultValue: order.sales_channel_id || void 0
|
|
12541
|
-
});
|
|
12542
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12543
|
-
Form$2.Field,
|
|
12544
|
-
{
|
|
12545
|
-
control,
|
|
12546
|
-
name: "sales_channel_id",
|
|
12547
|
-
render: ({ field }) => {
|
|
12548
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12549
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12550
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12551
|
-
Combobox,
|
|
12552
|
-
{
|
|
12553
|
-
options: salesChannels.options,
|
|
12554
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12555
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12556
|
-
searchValue: salesChannels.searchValue,
|
|
12557
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12558
|
-
placeholder: "Select sales channel",
|
|
12559
|
-
...field
|
|
12560
|
-
}
|
|
12561
|
-
) }),
|
|
12562
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12563
|
-
] });
|
|
12564
|
-
}
|
|
12565
|
-
}
|
|
12566
|
-
);
|
|
12567
|
-
};
|
|
12568
|
-
const schema$1 = objectType({
|
|
12569
|
-
sales_channel_id: stringType().min(1)
|
|
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, {
|
|
@@ -13064,22 +13064,22 @@ const routeModule = {
|
|
|
13064
13064
|
handle,
|
|
13065
13065
|
loader,
|
|
13066
13066
|
children: [
|
|
13067
|
-
{
|
|
13068
|
-
Component: BillingAddress,
|
|
13069
|
-
path: "/draft-orders/:id/billing-address"
|
|
13070
|
-
},
|
|
13071
13067
|
{
|
|
13072
13068
|
Component: CustomItems,
|
|
13073
13069
|
path: "/draft-orders/:id/custom-items"
|
|
13074
13070
|
},
|
|
13075
13071
|
{
|
|
13076
|
-
Component:
|
|
13077
|
-
path: "/draft-orders/:id/
|
|
13072
|
+
Component: BillingAddress,
|
|
13073
|
+
path: "/draft-orders/:id/billing-address"
|
|
13078
13074
|
},
|
|
13079
13075
|
{
|
|
13080
13076
|
Component: Items,
|
|
13081
13077
|
path: "/draft-orders/:id/items"
|
|
13082
13078
|
},
|
|
13079
|
+
{
|
|
13080
|
+
Component: Email,
|
|
13081
|
+
path: "/draft-orders/:id/email"
|
|
13082
|
+
},
|
|
13083
13083
|
{
|
|
13084
13084
|
Component: Metadata,
|
|
13085
13085
|
path: "/draft-orders/:id/metadata"
|
|
@@ -13088,6 +13088,10 @@ const routeModule = {
|
|
|
13088
13088
|
Component: Promotions,
|
|
13089
13089
|
path: "/draft-orders/:id/promotions"
|
|
13090
13090
|
},
|
|
13091
|
+
{
|
|
13092
|
+
Component: SalesChannel,
|
|
13093
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13094
|
+
},
|
|
13091
13095
|
{
|
|
13092
13096
|
Component: Shipping,
|
|
13093
13097
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13096,10 +13100,6 @@ const routeModule = {
|
|
|
13096
13100
|
Component: ShippingAddress,
|
|
13097
13101
|
path: "/draft-orders/:id/shipping-address"
|
|
13098
13102
|
},
|
|
13099
|
-
{
|
|
13100
|
-
Component: SalesChannel,
|
|
13101
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13102
|
-
},
|
|
13103
13103
|
{
|
|
13104
13104
|
Component: TransferOwnership,
|
|
13105
13105
|
path: "/draft-orders/:id/transfer-ownership"
|
|
@@ -9565,6 +9565,27 @@ const ID = () => {
|
|
|
9565
9565
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9566
9566
|
] });
|
|
9567
9567
|
};
|
|
9568
|
+
const CustomItems = () => {
|
|
9569
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9570
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9571
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9572
|
+
] });
|
|
9573
|
+
};
|
|
9574
|
+
const CustomItemsForm = () => {
|
|
9575
|
+
const form = useForm({
|
|
9576
|
+
resolver: zodResolver(schema$5)
|
|
9577
|
+
});
|
|
9578
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9579
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9580
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9581
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9582
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9583
|
+
] }) })
|
|
9584
|
+
] }) });
|
|
9585
|
+
};
|
|
9586
|
+
const schema$5 = objectType({
|
|
9587
|
+
email: stringType().email()
|
|
9588
|
+
});
|
|
9568
9589
|
const BillingAddress = () => {
|
|
9569
9590
|
const { id } = useParams();
|
|
9570
9591
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9597,7 +9618,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9597
9618
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9598
9619
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9599
9620
|
},
|
|
9600
|
-
resolver: zodResolver(schema$
|
|
9621
|
+
resolver: zodResolver(schema$4)
|
|
9601
9622
|
});
|
|
9602
9623
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9603
9624
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9754,96 +9775,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9754
9775
|
}
|
|
9755
9776
|
) });
|
|
9756
9777
|
};
|
|
9757
|
-
const schema$
|
|
9758
|
-
const CustomItems = () => {
|
|
9759
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9760
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9761
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9762
|
-
] });
|
|
9763
|
-
};
|
|
9764
|
-
const CustomItemsForm = () => {
|
|
9765
|
-
const form = useForm({
|
|
9766
|
-
resolver: zodResolver(schema$4)
|
|
9767
|
-
});
|
|
9768
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9769
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9770
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9771
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9772
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9773
|
-
] }) })
|
|
9774
|
-
] }) });
|
|
9775
|
-
};
|
|
9776
|
-
const schema$4 = objectType({
|
|
9777
|
-
email: stringType().email()
|
|
9778
|
-
});
|
|
9779
|
-
const Email = () => {
|
|
9780
|
-
const { id } = useParams();
|
|
9781
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9782
|
-
fields: "+email"
|
|
9783
|
-
});
|
|
9784
|
-
if (isError) {
|
|
9785
|
-
throw error;
|
|
9786
|
-
}
|
|
9787
|
-
const isReady = !isPending && !!order;
|
|
9788
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9789
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9790
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
9791
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9792
|
-
] }),
|
|
9793
|
-
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9794
|
-
] });
|
|
9795
|
-
};
|
|
9796
|
-
const EmailForm = ({ order }) => {
|
|
9797
|
-
const form = useForm({
|
|
9798
|
-
defaultValues: {
|
|
9799
|
-
email: order.email ?? ""
|
|
9800
|
-
},
|
|
9801
|
-
resolver: zodResolver(schema$3)
|
|
9802
|
-
});
|
|
9803
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9804
|
-
const { handleSuccess } = useRouteModal();
|
|
9805
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9806
|
-
await mutateAsync(
|
|
9807
|
-
{ email: data.email },
|
|
9808
|
-
{
|
|
9809
|
-
onSuccess: () => {
|
|
9810
|
-
handleSuccess();
|
|
9811
|
-
},
|
|
9812
|
-
onError: (error) => {
|
|
9813
|
-
toast.error(error.message);
|
|
9814
|
-
}
|
|
9815
|
-
}
|
|
9816
|
-
);
|
|
9817
|
-
});
|
|
9818
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9819
|
-
KeyboundForm,
|
|
9820
|
-
{
|
|
9821
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9822
|
-
onSubmit,
|
|
9823
|
-
children: [
|
|
9824
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9825
|
-
Form$2.Field,
|
|
9826
|
-
{
|
|
9827
|
-
control: form.control,
|
|
9828
|
-
name: "email",
|
|
9829
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9830
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9831
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9832
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9833
|
-
] })
|
|
9834
|
-
}
|
|
9835
|
-
) }),
|
|
9836
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9837
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9838
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9839
|
-
] }) })
|
|
9840
|
-
]
|
|
9841
|
-
}
|
|
9842
|
-
) });
|
|
9843
|
-
};
|
|
9844
|
-
const schema$3 = objectType({
|
|
9845
|
-
email: stringType().email()
|
|
9846
|
-
});
|
|
9778
|
+
const schema$4 = addressSchema;
|
|
9847
9779
|
const NumberInput = forwardRef(
|
|
9848
9780
|
({
|
|
9849
9781
|
value,
|
|
@@ -10818,6 +10750,74 @@ const customItemSchema = objectType({
|
|
|
10818
10750
|
quantity: numberType(),
|
|
10819
10751
|
unit_price: unionType([numberType(), stringType()])
|
|
10820
10752
|
});
|
|
10753
|
+
const Email = () => {
|
|
10754
|
+
const { id } = useParams();
|
|
10755
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10756
|
+
fields: "+email"
|
|
10757
|
+
});
|
|
10758
|
+
if (isError) {
|
|
10759
|
+
throw error;
|
|
10760
|
+
}
|
|
10761
|
+
const isReady = !isPending && !!order;
|
|
10762
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10763
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
10764
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
10765
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
10766
|
+
] }),
|
|
10767
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
10768
|
+
] });
|
|
10769
|
+
};
|
|
10770
|
+
const EmailForm = ({ order }) => {
|
|
10771
|
+
const form = useForm({
|
|
10772
|
+
defaultValues: {
|
|
10773
|
+
email: order.email ?? ""
|
|
10774
|
+
},
|
|
10775
|
+
resolver: zodResolver(schema$3)
|
|
10776
|
+
});
|
|
10777
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
10778
|
+
const { handleSuccess } = useRouteModal();
|
|
10779
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
10780
|
+
await mutateAsync(
|
|
10781
|
+
{ email: data.email },
|
|
10782
|
+
{
|
|
10783
|
+
onSuccess: () => {
|
|
10784
|
+
handleSuccess();
|
|
10785
|
+
},
|
|
10786
|
+
onError: (error) => {
|
|
10787
|
+
toast.error(error.message);
|
|
10788
|
+
}
|
|
10789
|
+
}
|
|
10790
|
+
);
|
|
10791
|
+
});
|
|
10792
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
10793
|
+
KeyboundForm,
|
|
10794
|
+
{
|
|
10795
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
10796
|
+
onSubmit,
|
|
10797
|
+
children: [
|
|
10798
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
10799
|
+
Form$2.Field,
|
|
10800
|
+
{
|
|
10801
|
+
control: form.control,
|
|
10802
|
+
name: "email",
|
|
10803
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10804
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
10805
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10806
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10807
|
+
] })
|
|
10808
|
+
}
|
|
10809
|
+
) }),
|
|
10810
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10811
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10812
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10813
|
+
] }) })
|
|
10814
|
+
]
|
|
10815
|
+
}
|
|
10816
|
+
) });
|
|
10817
|
+
};
|
|
10818
|
+
const schema$3 = objectType({
|
|
10819
|
+
email: stringType().email()
|
|
10820
|
+
});
|
|
10821
10821
|
const InlineTip = forwardRef(
|
|
10822
10822
|
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10823
10823
|
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
@@ -11445,6 +11445,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11445
11445
|
}
|
|
11446
11446
|
return Array.from(promotionIds);
|
|
11447
11447
|
}
|
|
11448
|
+
const SalesChannel = () => {
|
|
11449
|
+
const { id } = useParams();
|
|
11450
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11451
|
+
id,
|
|
11452
|
+
{
|
|
11453
|
+
fields: "+sales_channel_id"
|
|
11454
|
+
},
|
|
11455
|
+
{
|
|
11456
|
+
enabled: !!id
|
|
11457
|
+
}
|
|
11458
|
+
);
|
|
11459
|
+
if (isError) {
|
|
11460
|
+
throw error;
|
|
11461
|
+
}
|
|
11462
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11463
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11464
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11465
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11466
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11467
|
+
] }),
|
|
11468
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11469
|
+
] });
|
|
11470
|
+
};
|
|
11471
|
+
const SalesChannelForm = ({ order }) => {
|
|
11472
|
+
const form = useForm({
|
|
11473
|
+
defaultValues: {
|
|
11474
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11475
|
+
},
|
|
11476
|
+
resolver: zodResolver(schema$2)
|
|
11477
|
+
});
|
|
11478
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11479
|
+
const { handleSuccess } = useRouteModal();
|
|
11480
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11481
|
+
await mutateAsync(
|
|
11482
|
+
{
|
|
11483
|
+
sales_channel_id: data.sales_channel_id
|
|
11484
|
+
},
|
|
11485
|
+
{
|
|
11486
|
+
onSuccess: () => {
|
|
11487
|
+
toast.success("Sales channel updated");
|
|
11488
|
+
handleSuccess();
|
|
11489
|
+
},
|
|
11490
|
+
onError: (error) => {
|
|
11491
|
+
toast.error(error.message);
|
|
11492
|
+
}
|
|
11493
|
+
}
|
|
11494
|
+
);
|
|
11495
|
+
});
|
|
11496
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11497
|
+
KeyboundForm,
|
|
11498
|
+
{
|
|
11499
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11500
|
+
onSubmit,
|
|
11501
|
+
children: [
|
|
11502
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11503
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11504
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11505
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11506
|
+
] }) })
|
|
11507
|
+
]
|
|
11508
|
+
}
|
|
11509
|
+
) });
|
|
11510
|
+
};
|
|
11511
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11512
|
+
const salesChannels = useComboboxData({
|
|
11513
|
+
queryFn: async (params) => {
|
|
11514
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11515
|
+
},
|
|
11516
|
+
queryKey: ["sales-channels"],
|
|
11517
|
+
getOptions: (data) => {
|
|
11518
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11519
|
+
label: salesChannel.name,
|
|
11520
|
+
value: salesChannel.id
|
|
11521
|
+
}));
|
|
11522
|
+
},
|
|
11523
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11524
|
+
});
|
|
11525
|
+
return /* @__PURE__ */ jsx(
|
|
11526
|
+
Form$2.Field,
|
|
11527
|
+
{
|
|
11528
|
+
control,
|
|
11529
|
+
name: "sales_channel_id",
|
|
11530
|
+
render: ({ field }) => {
|
|
11531
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11532
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11533
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11534
|
+
Combobox,
|
|
11535
|
+
{
|
|
11536
|
+
options: salesChannels.options,
|
|
11537
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11538
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11539
|
+
searchValue: salesChannels.searchValue,
|
|
11540
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11541
|
+
placeholder: "Select sales channel",
|
|
11542
|
+
...field
|
|
11543
|
+
}
|
|
11544
|
+
) }),
|
|
11545
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11546
|
+
] });
|
|
11547
|
+
}
|
|
11548
|
+
}
|
|
11549
|
+
);
|
|
11550
|
+
};
|
|
11551
|
+
const schema$2 = objectType({
|
|
11552
|
+
sales_channel_id: stringType().min(1)
|
|
11553
|
+
});
|
|
11448
11554
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11449
11555
|
const Shipping = () => {
|
|
11450
11556
|
var _a;
|
|
@@ -12284,7 +12390,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12284
12390
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12285
12391
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12286
12392
|
},
|
|
12287
|
-
resolver: zodResolver(schema$
|
|
12393
|
+
resolver: zodResolver(schema$1)
|
|
12288
12394
|
});
|
|
12289
12395
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12290
12396
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12454,113 +12560,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12454
12560
|
}
|
|
12455
12561
|
) });
|
|
12456
12562
|
};
|
|
12457
|
-
const schema$
|
|
12458
|
-
const SalesChannel = () => {
|
|
12459
|
-
const { id } = useParams();
|
|
12460
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12461
|
-
id,
|
|
12462
|
-
{
|
|
12463
|
-
fields: "+sales_channel_id"
|
|
12464
|
-
},
|
|
12465
|
-
{
|
|
12466
|
-
enabled: !!id
|
|
12467
|
-
}
|
|
12468
|
-
);
|
|
12469
|
-
if (isError) {
|
|
12470
|
-
throw error;
|
|
12471
|
-
}
|
|
12472
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12473
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12474
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12475
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12476
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12477
|
-
] }),
|
|
12478
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12479
|
-
] });
|
|
12480
|
-
};
|
|
12481
|
-
const SalesChannelForm = ({ order }) => {
|
|
12482
|
-
const form = useForm({
|
|
12483
|
-
defaultValues: {
|
|
12484
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12485
|
-
},
|
|
12486
|
-
resolver: zodResolver(schema$1)
|
|
12487
|
-
});
|
|
12488
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12489
|
-
const { handleSuccess } = useRouteModal();
|
|
12490
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12491
|
-
await mutateAsync(
|
|
12492
|
-
{
|
|
12493
|
-
sales_channel_id: data.sales_channel_id
|
|
12494
|
-
},
|
|
12495
|
-
{
|
|
12496
|
-
onSuccess: () => {
|
|
12497
|
-
toast.success("Sales channel updated");
|
|
12498
|
-
handleSuccess();
|
|
12499
|
-
},
|
|
12500
|
-
onError: (error) => {
|
|
12501
|
-
toast.error(error.message);
|
|
12502
|
-
}
|
|
12503
|
-
}
|
|
12504
|
-
);
|
|
12505
|
-
});
|
|
12506
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12507
|
-
KeyboundForm,
|
|
12508
|
-
{
|
|
12509
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12510
|
-
onSubmit,
|
|
12511
|
-
children: [
|
|
12512
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12513
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12514
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12515
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12516
|
-
] }) })
|
|
12517
|
-
]
|
|
12518
|
-
}
|
|
12519
|
-
) });
|
|
12520
|
-
};
|
|
12521
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12522
|
-
const salesChannels = useComboboxData({
|
|
12523
|
-
queryFn: async (params) => {
|
|
12524
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12525
|
-
},
|
|
12526
|
-
queryKey: ["sales-channels"],
|
|
12527
|
-
getOptions: (data) => {
|
|
12528
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
12529
|
-
label: salesChannel.name,
|
|
12530
|
-
value: salesChannel.id
|
|
12531
|
-
}));
|
|
12532
|
-
},
|
|
12533
|
-
defaultValue: order.sales_channel_id || void 0
|
|
12534
|
-
});
|
|
12535
|
-
return /* @__PURE__ */ jsx(
|
|
12536
|
-
Form$2.Field,
|
|
12537
|
-
{
|
|
12538
|
-
control,
|
|
12539
|
-
name: "sales_channel_id",
|
|
12540
|
-
render: ({ field }) => {
|
|
12541
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12542
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12543
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12544
|
-
Combobox,
|
|
12545
|
-
{
|
|
12546
|
-
options: salesChannels.options,
|
|
12547
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12548
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12549
|
-
searchValue: salesChannels.searchValue,
|
|
12550
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12551
|
-
placeholder: "Select sales channel",
|
|
12552
|
-
...field
|
|
12553
|
-
}
|
|
12554
|
-
) }),
|
|
12555
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12556
|
-
] });
|
|
12557
|
-
}
|
|
12558
|
-
}
|
|
12559
|
-
);
|
|
12560
|
-
};
|
|
12561
|
-
const schema$1 = objectType({
|
|
12562
|
-
sales_channel_id: stringType().min(1)
|
|
12563
|
-
});
|
|
12563
|
+
const schema$1 = addressSchema;
|
|
12564
12564
|
const TransferOwnership = () => {
|
|
12565
12565
|
const { id } = useParams();
|
|
12566
12566
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -13057,22 +13057,22 @@ const routeModule = {
|
|
|
13057
13057
|
handle,
|
|
13058
13058
|
loader,
|
|
13059
13059
|
children: [
|
|
13060
|
-
{
|
|
13061
|
-
Component: BillingAddress,
|
|
13062
|
-
path: "/draft-orders/:id/billing-address"
|
|
13063
|
-
},
|
|
13064
13060
|
{
|
|
13065
13061
|
Component: CustomItems,
|
|
13066
13062
|
path: "/draft-orders/:id/custom-items"
|
|
13067
13063
|
},
|
|
13068
13064
|
{
|
|
13069
|
-
Component:
|
|
13070
|
-
path: "/draft-orders/:id/
|
|
13065
|
+
Component: BillingAddress,
|
|
13066
|
+
path: "/draft-orders/:id/billing-address"
|
|
13071
13067
|
},
|
|
13072
13068
|
{
|
|
13073
13069
|
Component: Items,
|
|
13074
13070
|
path: "/draft-orders/:id/items"
|
|
13075
13071
|
},
|
|
13072
|
+
{
|
|
13073
|
+
Component: Email,
|
|
13074
|
+
path: "/draft-orders/:id/email"
|
|
13075
|
+
},
|
|
13076
13076
|
{
|
|
13077
13077
|
Component: Metadata,
|
|
13078
13078
|
path: "/draft-orders/:id/metadata"
|
|
@@ -13081,6 +13081,10 @@ const routeModule = {
|
|
|
13081
13081
|
Component: Promotions,
|
|
13082
13082
|
path: "/draft-orders/:id/promotions"
|
|
13083
13083
|
},
|
|
13084
|
+
{
|
|
13085
|
+
Component: SalesChannel,
|
|
13086
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13087
|
+
},
|
|
13084
13088
|
{
|
|
13085
13089
|
Component: Shipping,
|
|
13086
13090
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13089,10 +13093,6 @@ const routeModule = {
|
|
|
13089
13093
|
Component: ShippingAddress,
|
|
13090
13094
|
path: "/draft-orders/:id/shipping-address"
|
|
13091
13095
|
},
|
|
13092
|
-
{
|
|
13093
|
-
Component: SalesChannel,
|
|
13094
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13095
|
-
},
|
|
13096
13096
|
{
|
|
13097
13097
|
Component: TransferOwnership,
|
|
13098
13098
|
path: "/draft-orders/:id/transfer-ownership"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.12.4-snapshot-
|
|
3
|
+
"version": "2.12.4-snapshot-20251226070522",
|
|
4
4
|
"description": "A draft order plugin for Medusa.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@ariakit/react": "^0.4.15",
|
|
43
43
|
"@babel/runtime": "^7.26.10",
|
|
44
44
|
"@hookform/resolvers": "3.4.2",
|
|
45
|
-
"@medusajs/js-sdk": "2.12.4-snapshot-
|
|
45
|
+
"@medusajs/js-sdk": "2.12.4-snapshot-20251226070522",
|
|
46
46
|
"@tanstack/react-query": "5.64.2",
|
|
47
47
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
48
48
|
"date-fns": "^3.6.0",
|
|
@@ -53,22 +53,22 @@
|
|
|
53
53
|
"react-hook-form": "7.49.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@medusajs/admin-sdk": "2.12.4-snapshot-
|
|
57
|
-
"@medusajs/cli": "2.12.4-snapshot-
|
|
58
|
-
"@medusajs/framework": "2.12.4-snapshot-
|
|
59
|
-
"@medusajs/icons": "2.12.4-snapshot-
|
|
60
|
-
"@medusajs/test-utils": "2.12.4-snapshot-
|
|
61
|
-
"@medusajs/types": "2.12.4-snapshot-
|
|
62
|
-
"@medusajs/ui": "4.0.32-snapshot-
|
|
63
|
-
"@medusajs/ui-preset": "2.12.4-snapshot-
|
|
56
|
+
"@medusajs/admin-sdk": "2.12.4-snapshot-20251226070522",
|
|
57
|
+
"@medusajs/cli": "2.12.4-snapshot-20251226070522",
|
|
58
|
+
"@medusajs/framework": "2.12.4-snapshot-20251226070522",
|
|
59
|
+
"@medusajs/icons": "2.12.4-snapshot-20251226070522",
|
|
60
|
+
"@medusajs/test-utils": "2.12.4-snapshot-20251226070522",
|
|
61
|
+
"@medusajs/types": "2.12.4-snapshot-20251226070522",
|
|
62
|
+
"@medusajs/ui": "4.0.32-snapshot-20251226070522",
|
|
63
|
+
"@medusajs/ui-preset": "2.12.4-snapshot-20251226070522"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@medusajs/admin-sdk": "2.12.4-snapshot-
|
|
67
|
-
"@medusajs/cli": "2.12.4-snapshot-
|
|
68
|
-
"@medusajs/framework": "2.12.4-snapshot-
|
|
69
|
-
"@medusajs/icons": "2.12.4-snapshot-
|
|
70
|
-
"@medusajs/test-utils": "2.12.4-snapshot-
|
|
71
|
-
"@medusajs/ui": "4.0.32-snapshot-
|
|
66
|
+
"@medusajs/admin-sdk": "2.12.4-snapshot-20251226070522",
|
|
67
|
+
"@medusajs/cli": "2.12.4-snapshot-20251226070522",
|
|
68
|
+
"@medusajs/framework": "2.12.4-snapshot-20251226070522",
|
|
69
|
+
"@medusajs/icons": "2.12.4-snapshot-20251226070522",
|
|
70
|
+
"@medusajs/test-utils": "2.12.4-snapshot-20251226070522",
|
|
71
|
+
"@medusajs/ui": "4.0.32-snapshot-20251226070522",
|
|
72
72
|
"react": "^18.3.1",
|
|
73
73
|
"react-dom": "^18.3.1",
|
|
74
74
|
"react-router-dom": "6.20.1"
|