@medusajs/draft-order 2.15.2 → 2.15.3-preview-20260514154320
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 +110 -110
- package/.medusa/server/src/admin/index.mjs +110 -110
- package/package.json +16 -16
|
@@ -11779,112 +11779,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11779
11779
|
}
|
|
11780
11780
|
return Array.from(promotionIds);
|
|
11781
11781
|
}
|
|
11782
|
-
const SalesChannel = () => {
|
|
11783
|
-
const { id } = reactRouterDom.useParams();
|
|
11784
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11785
|
-
id,
|
|
11786
|
-
{
|
|
11787
|
-
fields: "+sales_channel_id"
|
|
11788
|
-
},
|
|
11789
|
-
{
|
|
11790
|
-
enabled: !!id
|
|
11791
|
-
}
|
|
11792
|
-
);
|
|
11793
|
-
if (isError) {
|
|
11794
|
-
throw error;
|
|
11795
|
-
}
|
|
11796
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11797
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11798
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11799
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11800
|
-
/* @__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" }) })
|
|
11801
|
-
] }),
|
|
11802
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11803
|
-
] });
|
|
11804
|
-
};
|
|
11805
|
-
const SalesChannelForm = ({ order }) => {
|
|
11806
|
-
const form = reactHookForm.useForm({
|
|
11807
|
-
defaultValues: {
|
|
11808
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11809
|
-
},
|
|
11810
|
-
resolver: zod.zodResolver(schema$2)
|
|
11811
|
-
});
|
|
11812
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11813
|
-
const { handleSuccess } = useRouteModal();
|
|
11814
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11815
|
-
await mutateAsync(
|
|
11816
|
-
{
|
|
11817
|
-
sales_channel_id: data.sales_channel_id
|
|
11818
|
-
},
|
|
11819
|
-
{
|
|
11820
|
-
onSuccess: () => {
|
|
11821
|
-
ui.toast.success("Sales channel updated");
|
|
11822
|
-
handleSuccess();
|
|
11823
|
-
},
|
|
11824
|
-
onError: (error) => {
|
|
11825
|
-
ui.toast.error(error.message);
|
|
11826
|
-
}
|
|
11827
|
-
}
|
|
11828
|
-
);
|
|
11829
|
-
});
|
|
11830
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11831
|
-
KeyboundForm,
|
|
11832
|
-
{
|
|
11833
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11834
|
-
onSubmit,
|
|
11835
|
-
children: [
|
|
11836
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11837
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11838
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11839
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11840
|
-
] }) })
|
|
11841
|
-
]
|
|
11842
|
-
}
|
|
11843
|
-
) });
|
|
11844
|
-
};
|
|
11845
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11846
|
-
const salesChannels = useComboboxData({
|
|
11847
|
-
queryFn: async (params) => {
|
|
11848
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11849
|
-
},
|
|
11850
|
-
queryKey: ["sales-channels"],
|
|
11851
|
-
getOptions: (data) => {
|
|
11852
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11853
|
-
label: salesChannel.name,
|
|
11854
|
-
value: salesChannel.id
|
|
11855
|
-
}));
|
|
11856
|
-
},
|
|
11857
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11858
|
-
});
|
|
11859
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11860
|
-
Form$2.Field,
|
|
11861
|
-
{
|
|
11862
|
-
control,
|
|
11863
|
-
name: "sales_channel_id",
|
|
11864
|
-
render: ({ field }) => {
|
|
11865
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11866
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11867
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11868
|
-
Combobox,
|
|
11869
|
-
{
|
|
11870
|
-
options: salesChannels.options,
|
|
11871
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11872
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11873
|
-
searchValue: salesChannels.searchValue,
|
|
11874
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11875
|
-
placeholder: "Select sales channel",
|
|
11876
|
-
...field
|
|
11877
|
-
}
|
|
11878
|
-
) }),
|
|
11879
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11880
|
-
] });
|
|
11881
|
-
}
|
|
11882
|
-
}
|
|
11883
|
-
);
|
|
11884
|
-
};
|
|
11885
|
-
const schema$2 = object({
|
|
11886
|
-
sales_channel_id: string().min(1)
|
|
11887
|
-
});
|
|
11888
11782
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11889
11783
|
const Shipping = () => {
|
|
11890
11784
|
var _a2;
|
|
@@ -12692,6 +12586,112 @@ const CustomAmountField = ({
|
|
|
12692
12586
|
}
|
|
12693
12587
|
);
|
|
12694
12588
|
};
|
|
12589
|
+
const SalesChannel = () => {
|
|
12590
|
+
const { id } = reactRouterDom.useParams();
|
|
12591
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12592
|
+
id,
|
|
12593
|
+
{
|
|
12594
|
+
fields: "+sales_channel_id"
|
|
12595
|
+
},
|
|
12596
|
+
{
|
|
12597
|
+
enabled: !!id
|
|
12598
|
+
}
|
|
12599
|
+
);
|
|
12600
|
+
if (isError) {
|
|
12601
|
+
throw error;
|
|
12602
|
+
}
|
|
12603
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12604
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12605
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12606
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12607
|
+
/* @__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" }) })
|
|
12608
|
+
] }),
|
|
12609
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12610
|
+
] });
|
|
12611
|
+
};
|
|
12612
|
+
const SalesChannelForm = ({ order }) => {
|
|
12613
|
+
const form = reactHookForm.useForm({
|
|
12614
|
+
defaultValues: {
|
|
12615
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12616
|
+
},
|
|
12617
|
+
resolver: zod.zodResolver(schema$2)
|
|
12618
|
+
});
|
|
12619
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12620
|
+
const { handleSuccess } = useRouteModal();
|
|
12621
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12622
|
+
await mutateAsync(
|
|
12623
|
+
{
|
|
12624
|
+
sales_channel_id: data.sales_channel_id
|
|
12625
|
+
},
|
|
12626
|
+
{
|
|
12627
|
+
onSuccess: () => {
|
|
12628
|
+
ui.toast.success("Sales channel updated");
|
|
12629
|
+
handleSuccess();
|
|
12630
|
+
},
|
|
12631
|
+
onError: (error) => {
|
|
12632
|
+
ui.toast.error(error.message);
|
|
12633
|
+
}
|
|
12634
|
+
}
|
|
12635
|
+
);
|
|
12636
|
+
});
|
|
12637
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12638
|
+
KeyboundForm,
|
|
12639
|
+
{
|
|
12640
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12641
|
+
onSubmit,
|
|
12642
|
+
children: [
|
|
12643
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12644
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12645
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12646
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12647
|
+
] }) })
|
|
12648
|
+
]
|
|
12649
|
+
}
|
|
12650
|
+
) });
|
|
12651
|
+
};
|
|
12652
|
+
const SalesChannelField = ({ control, order }) => {
|
|
12653
|
+
const salesChannels = useComboboxData({
|
|
12654
|
+
queryFn: async (params) => {
|
|
12655
|
+
return await sdk.admin.salesChannel.list(params);
|
|
12656
|
+
},
|
|
12657
|
+
queryKey: ["sales-channels"],
|
|
12658
|
+
getOptions: (data) => {
|
|
12659
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
12660
|
+
label: salesChannel.name,
|
|
12661
|
+
value: salesChannel.id
|
|
12662
|
+
}));
|
|
12663
|
+
},
|
|
12664
|
+
defaultValue: order.sales_channel_id || void 0
|
|
12665
|
+
});
|
|
12666
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12667
|
+
Form$2.Field,
|
|
12668
|
+
{
|
|
12669
|
+
control,
|
|
12670
|
+
name: "sales_channel_id",
|
|
12671
|
+
render: ({ field }) => {
|
|
12672
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12673
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12674
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12675
|
+
Combobox,
|
|
12676
|
+
{
|
|
12677
|
+
options: salesChannels.options,
|
|
12678
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
12679
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12680
|
+
searchValue: salesChannels.searchValue,
|
|
12681
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12682
|
+
placeholder: "Select sales channel",
|
|
12683
|
+
...field
|
|
12684
|
+
}
|
|
12685
|
+
) }),
|
|
12686
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12687
|
+
] });
|
|
12688
|
+
}
|
|
12689
|
+
}
|
|
12690
|
+
);
|
|
12691
|
+
};
|
|
12692
|
+
const schema$2 = object({
|
|
12693
|
+
sales_channel_id: string().min(1)
|
|
12694
|
+
});
|
|
12695
12695
|
const ShippingAddress = () => {
|
|
12696
12696
|
const { id } = reactRouterDom.useParams();
|
|
12697
12697
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -13415,14 +13415,14 @@ const routeModule = {
|
|
|
13415
13415
|
Component: Promotions,
|
|
13416
13416
|
path: "/draft-orders/:id/promotions"
|
|
13417
13417
|
},
|
|
13418
|
-
{
|
|
13419
|
-
Component: SalesChannel,
|
|
13420
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13421
|
-
},
|
|
13422
13418
|
{
|
|
13423
13419
|
Component: Shipping,
|
|
13424
13420
|
path: "/draft-orders/:id/shipping"
|
|
13425
13421
|
},
|
|
13422
|
+
{
|
|
13423
|
+
Component: SalesChannel,
|
|
13424
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13425
|
+
},
|
|
13426
13426
|
{
|
|
13427
13427
|
Component: ShippingAddress,
|
|
13428
13428
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -11772,112 +11772,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11772
11772
|
}
|
|
11773
11773
|
return Array.from(promotionIds);
|
|
11774
11774
|
}
|
|
11775
|
-
const SalesChannel = () => {
|
|
11776
|
-
const { id } = useParams();
|
|
11777
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11778
|
-
id,
|
|
11779
|
-
{
|
|
11780
|
-
fields: "+sales_channel_id"
|
|
11781
|
-
},
|
|
11782
|
-
{
|
|
11783
|
-
enabled: !!id
|
|
11784
|
-
}
|
|
11785
|
-
);
|
|
11786
|
-
if (isError) {
|
|
11787
|
-
throw error;
|
|
11788
|
-
}
|
|
11789
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11790
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11791
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11792
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11793
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11794
|
-
] }),
|
|
11795
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11796
|
-
] });
|
|
11797
|
-
};
|
|
11798
|
-
const SalesChannelForm = ({ order }) => {
|
|
11799
|
-
const form = useForm({
|
|
11800
|
-
defaultValues: {
|
|
11801
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11802
|
-
},
|
|
11803
|
-
resolver: zodResolver(schema$2)
|
|
11804
|
-
});
|
|
11805
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11806
|
-
const { handleSuccess } = useRouteModal();
|
|
11807
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11808
|
-
await mutateAsync(
|
|
11809
|
-
{
|
|
11810
|
-
sales_channel_id: data.sales_channel_id
|
|
11811
|
-
},
|
|
11812
|
-
{
|
|
11813
|
-
onSuccess: () => {
|
|
11814
|
-
toast.success("Sales channel updated");
|
|
11815
|
-
handleSuccess();
|
|
11816
|
-
},
|
|
11817
|
-
onError: (error) => {
|
|
11818
|
-
toast.error(error.message);
|
|
11819
|
-
}
|
|
11820
|
-
}
|
|
11821
|
-
);
|
|
11822
|
-
});
|
|
11823
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11824
|
-
KeyboundForm,
|
|
11825
|
-
{
|
|
11826
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11827
|
-
onSubmit,
|
|
11828
|
-
children: [
|
|
11829
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11830
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11831
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11832
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11833
|
-
] }) })
|
|
11834
|
-
]
|
|
11835
|
-
}
|
|
11836
|
-
) });
|
|
11837
|
-
};
|
|
11838
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11839
|
-
const salesChannels = useComboboxData({
|
|
11840
|
-
queryFn: async (params) => {
|
|
11841
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11842
|
-
},
|
|
11843
|
-
queryKey: ["sales-channels"],
|
|
11844
|
-
getOptions: (data) => {
|
|
11845
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11846
|
-
label: salesChannel.name,
|
|
11847
|
-
value: salesChannel.id
|
|
11848
|
-
}));
|
|
11849
|
-
},
|
|
11850
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11851
|
-
});
|
|
11852
|
-
return /* @__PURE__ */ jsx(
|
|
11853
|
-
Form$2.Field,
|
|
11854
|
-
{
|
|
11855
|
-
control,
|
|
11856
|
-
name: "sales_channel_id",
|
|
11857
|
-
render: ({ field }) => {
|
|
11858
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11859
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11860
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11861
|
-
Combobox,
|
|
11862
|
-
{
|
|
11863
|
-
options: salesChannels.options,
|
|
11864
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11865
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11866
|
-
searchValue: salesChannels.searchValue,
|
|
11867
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11868
|
-
placeholder: "Select sales channel",
|
|
11869
|
-
...field
|
|
11870
|
-
}
|
|
11871
|
-
) }),
|
|
11872
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11873
|
-
] });
|
|
11874
|
-
}
|
|
11875
|
-
}
|
|
11876
|
-
);
|
|
11877
|
-
};
|
|
11878
|
-
const schema$2 = object({
|
|
11879
|
-
sales_channel_id: string().min(1)
|
|
11880
|
-
});
|
|
11881
11775
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11882
11776
|
const Shipping = () => {
|
|
11883
11777
|
var _a2;
|
|
@@ -12685,6 +12579,112 @@ const CustomAmountField = ({
|
|
|
12685
12579
|
}
|
|
12686
12580
|
);
|
|
12687
12581
|
};
|
|
12582
|
+
const SalesChannel = () => {
|
|
12583
|
+
const { id } = useParams();
|
|
12584
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12585
|
+
id,
|
|
12586
|
+
{
|
|
12587
|
+
fields: "+sales_channel_id"
|
|
12588
|
+
},
|
|
12589
|
+
{
|
|
12590
|
+
enabled: !!id
|
|
12591
|
+
}
|
|
12592
|
+
);
|
|
12593
|
+
if (isError) {
|
|
12594
|
+
throw error;
|
|
12595
|
+
}
|
|
12596
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12597
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12598
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12599
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12600
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12601
|
+
] }),
|
|
12602
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12603
|
+
] });
|
|
12604
|
+
};
|
|
12605
|
+
const SalesChannelForm = ({ order }) => {
|
|
12606
|
+
const form = useForm({
|
|
12607
|
+
defaultValues: {
|
|
12608
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12609
|
+
},
|
|
12610
|
+
resolver: zodResolver(schema$2)
|
|
12611
|
+
});
|
|
12612
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12613
|
+
const { handleSuccess } = useRouteModal();
|
|
12614
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12615
|
+
await mutateAsync(
|
|
12616
|
+
{
|
|
12617
|
+
sales_channel_id: data.sales_channel_id
|
|
12618
|
+
},
|
|
12619
|
+
{
|
|
12620
|
+
onSuccess: () => {
|
|
12621
|
+
toast.success("Sales channel updated");
|
|
12622
|
+
handleSuccess();
|
|
12623
|
+
},
|
|
12624
|
+
onError: (error) => {
|
|
12625
|
+
toast.error(error.message);
|
|
12626
|
+
}
|
|
12627
|
+
}
|
|
12628
|
+
);
|
|
12629
|
+
});
|
|
12630
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12631
|
+
KeyboundForm,
|
|
12632
|
+
{
|
|
12633
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12634
|
+
onSubmit,
|
|
12635
|
+
children: [
|
|
12636
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12637
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12638
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12639
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12640
|
+
] }) })
|
|
12641
|
+
]
|
|
12642
|
+
}
|
|
12643
|
+
) });
|
|
12644
|
+
};
|
|
12645
|
+
const SalesChannelField = ({ control, order }) => {
|
|
12646
|
+
const salesChannels = useComboboxData({
|
|
12647
|
+
queryFn: async (params) => {
|
|
12648
|
+
return await sdk.admin.salesChannel.list(params);
|
|
12649
|
+
},
|
|
12650
|
+
queryKey: ["sales-channels"],
|
|
12651
|
+
getOptions: (data) => {
|
|
12652
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
12653
|
+
label: salesChannel.name,
|
|
12654
|
+
value: salesChannel.id
|
|
12655
|
+
}));
|
|
12656
|
+
},
|
|
12657
|
+
defaultValue: order.sales_channel_id || void 0
|
|
12658
|
+
});
|
|
12659
|
+
return /* @__PURE__ */ jsx(
|
|
12660
|
+
Form$2.Field,
|
|
12661
|
+
{
|
|
12662
|
+
control,
|
|
12663
|
+
name: "sales_channel_id",
|
|
12664
|
+
render: ({ field }) => {
|
|
12665
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12666
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12667
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12668
|
+
Combobox,
|
|
12669
|
+
{
|
|
12670
|
+
options: salesChannels.options,
|
|
12671
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
12672
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12673
|
+
searchValue: salesChannels.searchValue,
|
|
12674
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12675
|
+
placeholder: "Select sales channel",
|
|
12676
|
+
...field
|
|
12677
|
+
}
|
|
12678
|
+
) }),
|
|
12679
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12680
|
+
] });
|
|
12681
|
+
}
|
|
12682
|
+
}
|
|
12683
|
+
);
|
|
12684
|
+
};
|
|
12685
|
+
const schema$2 = object({
|
|
12686
|
+
sales_channel_id: string().min(1)
|
|
12687
|
+
});
|
|
12688
12688
|
const ShippingAddress = () => {
|
|
12689
12689
|
const { id } = useParams();
|
|
12690
12690
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -13408,14 +13408,14 @@ const routeModule = {
|
|
|
13408
13408
|
Component: Promotions,
|
|
13409
13409
|
path: "/draft-orders/:id/promotions"
|
|
13410
13410
|
},
|
|
13411
|
-
{
|
|
13412
|
-
Component: SalesChannel,
|
|
13413
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13414
|
-
},
|
|
13415
13411
|
{
|
|
13416
13412
|
Component: Shipping,
|
|
13417
13413
|
path: "/draft-orders/:id/shipping"
|
|
13418
13414
|
},
|
|
13415
|
+
{
|
|
13416
|
+
Component: SalesChannel,
|
|
13417
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13418
|
+
},
|
|
13419
13419
|
{
|
|
13420
13420
|
Component: ShippingAddress,
|
|
13421
13421
|
path: "/draft-orders/:id/shipping-address"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.3-preview-20260514154320",
|
|
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.15.
|
|
45
|
+
"@medusajs/js-sdk": "2.15.3-preview-20260514154320",
|
|
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.15.
|
|
57
|
-
"@medusajs/cli": "2.15.
|
|
58
|
-
"@medusajs/framework": "2.15.
|
|
59
|
-
"@medusajs/icons": "2.15.
|
|
60
|
-
"@medusajs/test-utils": "2.15.
|
|
61
|
-
"@medusajs/types": "2.15.
|
|
62
|
-
"@medusajs/ui": "4.1.
|
|
63
|
-
"@medusajs/ui-preset": "2.15.
|
|
56
|
+
"@medusajs/admin-sdk": "2.15.3-preview-20260514154320",
|
|
57
|
+
"@medusajs/cli": "2.15.3-preview-20260514154320",
|
|
58
|
+
"@medusajs/framework": "2.15.3-preview-20260514154320",
|
|
59
|
+
"@medusajs/icons": "2.15.3-preview-20260514154320",
|
|
60
|
+
"@medusajs/test-utils": "2.15.3-preview-20260514154320",
|
|
61
|
+
"@medusajs/types": "2.15.3-preview-20260514154320",
|
|
62
|
+
"@medusajs/ui": "4.1.13-preview-20260514154320",
|
|
63
|
+
"@medusajs/ui-preset": "2.15.3-preview-20260514154320"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@medusajs/admin-sdk": "2.15.
|
|
67
|
-
"@medusajs/cli": "2.15.
|
|
68
|
-
"@medusajs/framework": "2.15.
|
|
69
|
-
"@medusajs/icons": "2.15.
|
|
70
|
-
"@medusajs/test-utils": "2.15.
|
|
71
|
-
"@medusajs/ui": "4.1.
|
|
66
|
+
"@medusajs/admin-sdk": "2.15.3-preview-20260514154320",
|
|
67
|
+
"@medusajs/cli": "2.15.3-preview-20260514154320",
|
|
68
|
+
"@medusajs/framework": "2.15.3-preview-20260514154320",
|
|
69
|
+
"@medusajs/icons": "2.15.3-preview-20260514154320",
|
|
70
|
+
"@medusajs/test-utils": "2.15.3-preview-20260514154320",
|
|
71
|
+
"@medusajs/ui": "4.1.13-preview-20260514154320",
|
|
72
72
|
"react": "^18.3.1",
|
|
73
73
|
"react-dom": "^18.3.1",
|
|
74
74
|
"react-router-dom": "6.30.3"
|