@medusajs/draft-order 2.15.5 → 2.15.6-preview-20260601104039
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 +114 -114
- package/.medusa/server/src/admin/index.mjs +114 -114
- 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;
|
|
@@ -12724,7 +12618,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12724
12618
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12725
12619
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12726
12620
|
},
|
|
12727
|
-
resolver: zod.zodResolver(schema$
|
|
12621
|
+
resolver: zod.zodResolver(schema$2)
|
|
12728
12622
|
});
|
|
12729
12623
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12730
12624
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12894,7 +12788,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12894
12788
|
}
|
|
12895
12789
|
) });
|
|
12896
12790
|
};
|
|
12897
|
-
const schema$
|
|
12791
|
+
const schema$2 = addressSchema;
|
|
12898
12792
|
const TransferOwnership = () => {
|
|
12899
12793
|
const { id } = reactRouterDom.useParams();
|
|
12900
12794
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12918,7 +12812,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12918
12812
|
defaultValues: {
|
|
12919
12813
|
customer_id: order.customer_id || ""
|
|
12920
12814
|
},
|
|
12921
|
-
resolver: zod.zodResolver(schema)
|
|
12815
|
+
resolver: zod.zodResolver(schema$1)
|
|
12922
12816
|
});
|
|
12923
12817
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12924
12818
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13368,9 +13262,115 @@ const Illustration = () => {
|
|
|
13368
13262
|
}
|
|
13369
13263
|
);
|
|
13370
13264
|
};
|
|
13371
|
-
const schema = object({
|
|
13265
|
+
const schema$1 = object({
|
|
13372
13266
|
customer_id: string().min(1)
|
|
13373
13267
|
});
|
|
13268
|
+
const SalesChannel = () => {
|
|
13269
|
+
const { id } = reactRouterDom.useParams();
|
|
13270
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
13271
|
+
id,
|
|
13272
|
+
{
|
|
13273
|
+
fields: "+sales_channel_id"
|
|
13274
|
+
},
|
|
13275
|
+
{
|
|
13276
|
+
enabled: !!id
|
|
13277
|
+
}
|
|
13278
|
+
);
|
|
13279
|
+
if (isError) {
|
|
13280
|
+
throw error;
|
|
13281
|
+
}
|
|
13282
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
13283
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
13284
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
13285
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
13286
|
+
/* @__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" }) })
|
|
13287
|
+
] }),
|
|
13288
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
13289
|
+
] });
|
|
13290
|
+
};
|
|
13291
|
+
const SalesChannelForm = ({ order }) => {
|
|
13292
|
+
const form = reactHookForm.useForm({
|
|
13293
|
+
defaultValues: {
|
|
13294
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
13295
|
+
},
|
|
13296
|
+
resolver: zod.zodResolver(schema)
|
|
13297
|
+
});
|
|
13298
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
13299
|
+
const { handleSuccess } = useRouteModal();
|
|
13300
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
13301
|
+
await mutateAsync(
|
|
13302
|
+
{
|
|
13303
|
+
sales_channel_id: data.sales_channel_id
|
|
13304
|
+
},
|
|
13305
|
+
{
|
|
13306
|
+
onSuccess: () => {
|
|
13307
|
+
ui.toast.success("Sales channel updated");
|
|
13308
|
+
handleSuccess();
|
|
13309
|
+
},
|
|
13310
|
+
onError: (error) => {
|
|
13311
|
+
ui.toast.error(error.message);
|
|
13312
|
+
}
|
|
13313
|
+
}
|
|
13314
|
+
);
|
|
13315
|
+
});
|
|
13316
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
13317
|
+
KeyboundForm,
|
|
13318
|
+
{
|
|
13319
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
13320
|
+
onSubmit,
|
|
13321
|
+
children: [
|
|
13322
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
13323
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13324
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13325
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13326
|
+
] }) })
|
|
13327
|
+
]
|
|
13328
|
+
}
|
|
13329
|
+
) });
|
|
13330
|
+
};
|
|
13331
|
+
const SalesChannelField = ({ control, order }) => {
|
|
13332
|
+
const salesChannels = useComboboxData({
|
|
13333
|
+
queryFn: async (params) => {
|
|
13334
|
+
return await sdk.admin.salesChannel.list(params);
|
|
13335
|
+
},
|
|
13336
|
+
queryKey: ["sales-channels"],
|
|
13337
|
+
getOptions: (data) => {
|
|
13338
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
13339
|
+
label: salesChannel.name,
|
|
13340
|
+
value: salesChannel.id
|
|
13341
|
+
}));
|
|
13342
|
+
},
|
|
13343
|
+
defaultValue: order.sales_channel_id || void 0
|
|
13344
|
+
});
|
|
13345
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13346
|
+
Form$2.Field,
|
|
13347
|
+
{
|
|
13348
|
+
control,
|
|
13349
|
+
name: "sales_channel_id",
|
|
13350
|
+
render: ({ field }) => {
|
|
13351
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13352
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13353
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13354
|
+
Combobox,
|
|
13355
|
+
{
|
|
13356
|
+
options: salesChannels.options,
|
|
13357
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
13358
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13359
|
+
searchValue: salesChannels.searchValue,
|
|
13360
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13361
|
+
placeholder: "Select sales channel",
|
|
13362
|
+
...field
|
|
13363
|
+
}
|
|
13364
|
+
) }),
|
|
13365
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13366
|
+
] });
|
|
13367
|
+
}
|
|
13368
|
+
}
|
|
13369
|
+
);
|
|
13370
|
+
};
|
|
13371
|
+
const schema = object({
|
|
13372
|
+
sales_channel_id: string().min(1)
|
|
13373
|
+
});
|
|
13374
13374
|
const widgetModule = { widgets: [] };
|
|
13375
13375
|
const routeModule = {
|
|
13376
13376
|
routes: [
|
|
@@ -13415,10 +13415,6 @@ 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"
|
|
@@ -13430,6 +13426,10 @@ const routeModule = {
|
|
|
13430
13426
|
{
|
|
13431
13427
|
Component: TransferOwnership,
|
|
13432
13428
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13429
|
+
},
|
|
13430
|
+
{
|
|
13431
|
+
Component: SalesChannel,
|
|
13432
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13433
13433
|
}
|
|
13434
13434
|
]
|
|
13435
13435
|
}
|
|
@@ -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;
|
|
@@ -12717,7 +12611,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12717
12611
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12718
12612
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12719
12613
|
},
|
|
12720
|
-
resolver: zodResolver(schema$
|
|
12614
|
+
resolver: zodResolver(schema$2)
|
|
12721
12615
|
});
|
|
12722
12616
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12723
12617
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12887,7 +12781,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12887
12781
|
}
|
|
12888
12782
|
) });
|
|
12889
12783
|
};
|
|
12890
|
-
const schema$
|
|
12784
|
+
const schema$2 = addressSchema;
|
|
12891
12785
|
const TransferOwnership = () => {
|
|
12892
12786
|
const { id } = useParams();
|
|
12893
12787
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12911,7 +12805,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12911
12805
|
defaultValues: {
|
|
12912
12806
|
customer_id: order.customer_id || ""
|
|
12913
12807
|
},
|
|
12914
|
-
resolver: zodResolver(schema)
|
|
12808
|
+
resolver: zodResolver(schema$1)
|
|
12915
12809
|
});
|
|
12916
12810
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12917
12811
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13361,9 +13255,115 @@ const Illustration = () => {
|
|
|
13361
13255
|
}
|
|
13362
13256
|
);
|
|
13363
13257
|
};
|
|
13364
|
-
const schema = object({
|
|
13258
|
+
const schema$1 = object({
|
|
13365
13259
|
customer_id: string().min(1)
|
|
13366
13260
|
});
|
|
13261
|
+
const SalesChannel = () => {
|
|
13262
|
+
const { id } = useParams();
|
|
13263
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
13264
|
+
id,
|
|
13265
|
+
{
|
|
13266
|
+
fields: "+sales_channel_id"
|
|
13267
|
+
},
|
|
13268
|
+
{
|
|
13269
|
+
enabled: !!id
|
|
13270
|
+
}
|
|
13271
|
+
);
|
|
13272
|
+
if (isError) {
|
|
13273
|
+
throw error;
|
|
13274
|
+
}
|
|
13275
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
13276
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
13277
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
13278
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
13279
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
13280
|
+
] }),
|
|
13281
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
13282
|
+
] });
|
|
13283
|
+
};
|
|
13284
|
+
const SalesChannelForm = ({ order }) => {
|
|
13285
|
+
const form = useForm({
|
|
13286
|
+
defaultValues: {
|
|
13287
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
13288
|
+
},
|
|
13289
|
+
resolver: zodResolver(schema)
|
|
13290
|
+
});
|
|
13291
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
13292
|
+
const { handleSuccess } = useRouteModal();
|
|
13293
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
13294
|
+
await mutateAsync(
|
|
13295
|
+
{
|
|
13296
|
+
sales_channel_id: data.sales_channel_id
|
|
13297
|
+
},
|
|
13298
|
+
{
|
|
13299
|
+
onSuccess: () => {
|
|
13300
|
+
toast.success("Sales channel updated");
|
|
13301
|
+
handleSuccess();
|
|
13302
|
+
},
|
|
13303
|
+
onError: (error) => {
|
|
13304
|
+
toast.error(error.message);
|
|
13305
|
+
}
|
|
13306
|
+
}
|
|
13307
|
+
);
|
|
13308
|
+
});
|
|
13309
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
13310
|
+
KeyboundForm,
|
|
13311
|
+
{
|
|
13312
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
13313
|
+
onSubmit,
|
|
13314
|
+
children: [
|
|
13315
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
13316
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13317
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13318
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13319
|
+
] }) })
|
|
13320
|
+
]
|
|
13321
|
+
}
|
|
13322
|
+
) });
|
|
13323
|
+
};
|
|
13324
|
+
const SalesChannelField = ({ control, order }) => {
|
|
13325
|
+
const salesChannels = useComboboxData({
|
|
13326
|
+
queryFn: async (params) => {
|
|
13327
|
+
return await sdk.admin.salesChannel.list(params);
|
|
13328
|
+
},
|
|
13329
|
+
queryKey: ["sales-channels"],
|
|
13330
|
+
getOptions: (data) => {
|
|
13331
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
13332
|
+
label: salesChannel.name,
|
|
13333
|
+
value: salesChannel.id
|
|
13334
|
+
}));
|
|
13335
|
+
},
|
|
13336
|
+
defaultValue: order.sales_channel_id || void 0
|
|
13337
|
+
});
|
|
13338
|
+
return /* @__PURE__ */ jsx(
|
|
13339
|
+
Form$2.Field,
|
|
13340
|
+
{
|
|
13341
|
+
control,
|
|
13342
|
+
name: "sales_channel_id",
|
|
13343
|
+
render: ({ field }) => {
|
|
13344
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13345
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13346
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
13347
|
+
Combobox,
|
|
13348
|
+
{
|
|
13349
|
+
options: salesChannels.options,
|
|
13350
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
13351
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13352
|
+
searchValue: salesChannels.searchValue,
|
|
13353
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13354
|
+
placeholder: "Select sales channel",
|
|
13355
|
+
...field
|
|
13356
|
+
}
|
|
13357
|
+
) }),
|
|
13358
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13359
|
+
] });
|
|
13360
|
+
}
|
|
13361
|
+
}
|
|
13362
|
+
);
|
|
13363
|
+
};
|
|
13364
|
+
const schema = object({
|
|
13365
|
+
sales_channel_id: string().min(1)
|
|
13366
|
+
});
|
|
13367
13367
|
const widgetModule = { widgets: [] };
|
|
13368
13368
|
const routeModule = {
|
|
13369
13369
|
routes: [
|
|
@@ -13408,10 +13408,6 @@ 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"
|
|
@@ -13423,6 +13419,10 @@ const routeModule = {
|
|
|
13423
13419
|
{
|
|
13424
13420
|
Component: TransferOwnership,
|
|
13425
13421
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13422
|
+
},
|
|
13423
|
+
{
|
|
13424
|
+
Component: SalesChannel,
|
|
13425
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13426
13426
|
}
|
|
13427
13427
|
]
|
|
13428
13428
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.6-preview-20260601104039",
|
|
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.6-preview-20260601104039",
|
|
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.6-preview-20260601104039",
|
|
57
|
+
"@medusajs/cli": "2.15.6-preview-20260601104039",
|
|
58
|
+
"@medusajs/framework": "2.15.6-preview-20260601104039",
|
|
59
|
+
"@medusajs/icons": "2.15.6-preview-20260601104039",
|
|
60
|
+
"@medusajs/test-utils": "2.15.6-preview-20260601104039",
|
|
61
|
+
"@medusajs/types": "2.15.6-preview-20260601104039",
|
|
62
|
+
"@medusajs/ui": "4.1.16-preview-20260601104039",
|
|
63
|
+
"@medusajs/ui-preset": "2.15.6-preview-20260601104039"
|
|
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.6-preview-20260601104039",
|
|
67
|
+
"@medusajs/cli": "2.15.6-preview-20260601104039",
|
|
68
|
+
"@medusajs/framework": "2.15.6-preview-20260601104039",
|
|
69
|
+
"@medusajs/icons": "2.15.6-preview-20260601104039",
|
|
70
|
+
"@medusajs/test-utils": "2.15.6-preview-20260601104039",
|
|
71
|
+
"@medusajs/ui": "4.1.16-preview-20260601104039",
|
|
72
72
|
"react": "^18.3.1",
|
|
73
73
|
"react-dom": "^18.3.1",
|
|
74
74
|
"react-router-dom": "6.30.3"
|