@medusajs/draft-order 2.10.4-preview-20250919180202 → 2.10.4-preview-20250920000323
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 +28 -28
|
@@ -11453,112 +11453,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11453
11453
|
}
|
|
11454
11454
|
return Array.from(promotionIds);
|
|
11455
11455
|
}
|
|
11456
|
-
const SalesChannel = () => {
|
|
11457
|
-
const { id } = reactRouterDom.useParams();
|
|
11458
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11459
|
-
id,
|
|
11460
|
-
{
|
|
11461
|
-
fields: "+sales_channel_id"
|
|
11462
|
-
},
|
|
11463
|
-
{
|
|
11464
|
-
enabled: !!id
|
|
11465
|
-
}
|
|
11466
|
-
);
|
|
11467
|
-
if (isError) {
|
|
11468
|
-
throw error;
|
|
11469
|
-
}
|
|
11470
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11471
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11472
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11473
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11474
|
-
/* @__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" }) })
|
|
11475
|
-
] }),
|
|
11476
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11477
|
-
] });
|
|
11478
|
-
};
|
|
11479
|
-
const SalesChannelForm = ({ order }) => {
|
|
11480
|
-
const form = reactHookForm.useForm({
|
|
11481
|
-
defaultValues: {
|
|
11482
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11483
|
-
},
|
|
11484
|
-
resolver: zod.zodResolver(schema$2)
|
|
11485
|
-
});
|
|
11486
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11487
|
-
const { handleSuccess } = useRouteModal();
|
|
11488
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11489
|
-
await mutateAsync(
|
|
11490
|
-
{
|
|
11491
|
-
sales_channel_id: data.sales_channel_id
|
|
11492
|
-
},
|
|
11493
|
-
{
|
|
11494
|
-
onSuccess: () => {
|
|
11495
|
-
ui.toast.success("Sales channel updated");
|
|
11496
|
-
handleSuccess();
|
|
11497
|
-
},
|
|
11498
|
-
onError: (error) => {
|
|
11499
|
-
ui.toast.error(error.message);
|
|
11500
|
-
}
|
|
11501
|
-
}
|
|
11502
|
-
);
|
|
11503
|
-
});
|
|
11504
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11505
|
-
KeyboundForm,
|
|
11506
|
-
{
|
|
11507
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11508
|
-
onSubmit,
|
|
11509
|
-
children: [
|
|
11510
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11511
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11512
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11513
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11514
|
-
] }) })
|
|
11515
|
-
]
|
|
11516
|
-
}
|
|
11517
|
-
) });
|
|
11518
|
-
};
|
|
11519
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11520
|
-
const salesChannels = useComboboxData({
|
|
11521
|
-
queryFn: async (params) => {
|
|
11522
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11523
|
-
},
|
|
11524
|
-
queryKey: ["sales-channels"],
|
|
11525
|
-
getOptions: (data) => {
|
|
11526
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11527
|
-
label: salesChannel.name,
|
|
11528
|
-
value: salesChannel.id
|
|
11529
|
-
}));
|
|
11530
|
-
},
|
|
11531
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11532
|
-
});
|
|
11533
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11534
|
-
Form$2.Field,
|
|
11535
|
-
{
|
|
11536
|
-
control,
|
|
11537
|
-
name: "sales_channel_id",
|
|
11538
|
-
render: ({ field }) => {
|
|
11539
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11540
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11541
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11542
|
-
Combobox,
|
|
11543
|
-
{
|
|
11544
|
-
options: salesChannels.options,
|
|
11545
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11546
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11547
|
-
searchValue: salesChannels.searchValue,
|
|
11548
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11549
|
-
placeholder: "Select sales channel",
|
|
11550
|
-
...field
|
|
11551
|
-
}
|
|
11552
|
-
) }),
|
|
11553
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11554
|
-
] });
|
|
11555
|
-
}
|
|
11556
|
-
}
|
|
11557
|
-
);
|
|
11558
|
-
};
|
|
11559
|
-
const schema$2 = objectType({
|
|
11560
|
-
sales_channel_id: stringType().min(1)
|
|
11561
|
-
});
|
|
11562
11456
|
const ShippingAddress = () => {
|
|
11563
11457
|
const { id } = reactRouterDom.useParams();
|
|
11564
11458
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -11591,7 +11485,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
11591
11485
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11592
11486
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11593
11487
|
},
|
|
11594
|
-
resolver: zod.zodResolver(schema$
|
|
11488
|
+
resolver: zod.zodResolver(schema$2)
|
|
11595
11489
|
});
|
|
11596
11490
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11597
11491
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11761,7 +11655,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
11761
11655
|
}
|
|
11762
11656
|
) });
|
|
11763
11657
|
};
|
|
11764
|
-
const schema$
|
|
11658
|
+
const schema$2 = addressSchema;
|
|
11765
11659
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11766
11660
|
const Shipping = () => {
|
|
11767
11661
|
var _a;
|
|
@@ -12592,7 +12486,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12592
12486
|
defaultValues: {
|
|
12593
12487
|
customer_id: order.customer_id || ""
|
|
12594
12488
|
},
|
|
12595
|
-
resolver: zod.zodResolver(schema)
|
|
12489
|
+
resolver: zod.zodResolver(schema$1)
|
|
12596
12490
|
});
|
|
12597
12491
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12598
12492
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13042,9 +12936,115 @@ const Illustration = () => {
|
|
|
13042
12936
|
}
|
|
13043
12937
|
);
|
|
13044
12938
|
};
|
|
13045
|
-
const schema = objectType({
|
|
12939
|
+
const schema$1 = objectType({
|
|
13046
12940
|
customer_id: stringType().min(1)
|
|
13047
12941
|
});
|
|
12942
|
+
const SalesChannel = () => {
|
|
12943
|
+
const { id } = reactRouterDom.useParams();
|
|
12944
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12945
|
+
id,
|
|
12946
|
+
{
|
|
12947
|
+
fields: "+sales_channel_id"
|
|
12948
|
+
},
|
|
12949
|
+
{
|
|
12950
|
+
enabled: !!id
|
|
12951
|
+
}
|
|
12952
|
+
);
|
|
12953
|
+
if (isError) {
|
|
12954
|
+
throw error;
|
|
12955
|
+
}
|
|
12956
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12957
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12958
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12959
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12960
|
+
/* @__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" }) })
|
|
12961
|
+
] }),
|
|
12962
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12963
|
+
] });
|
|
12964
|
+
};
|
|
12965
|
+
const SalesChannelForm = ({ order }) => {
|
|
12966
|
+
const form = reactHookForm.useForm({
|
|
12967
|
+
defaultValues: {
|
|
12968
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12969
|
+
},
|
|
12970
|
+
resolver: zod.zodResolver(schema)
|
|
12971
|
+
});
|
|
12972
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12973
|
+
const { handleSuccess } = useRouteModal();
|
|
12974
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12975
|
+
await mutateAsync(
|
|
12976
|
+
{
|
|
12977
|
+
sales_channel_id: data.sales_channel_id
|
|
12978
|
+
},
|
|
12979
|
+
{
|
|
12980
|
+
onSuccess: () => {
|
|
12981
|
+
ui.toast.success("Sales channel updated");
|
|
12982
|
+
handleSuccess();
|
|
12983
|
+
},
|
|
12984
|
+
onError: (error) => {
|
|
12985
|
+
ui.toast.error(error.message);
|
|
12986
|
+
}
|
|
12987
|
+
}
|
|
12988
|
+
);
|
|
12989
|
+
});
|
|
12990
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12991
|
+
KeyboundForm,
|
|
12992
|
+
{
|
|
12993
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12994
|
+
onSubmit,
|
|
12995
|
+
children: [
|
|
12996
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12997
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12998
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12999
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13000
|
+
] }) })
|
|
13001
|
+
]
|
|
13002
|
+
}
|
|
13003
|
+
) });
|
|
13004
|
+
};
|
|
13005
|
+
const SalesChannelField = ({ control, order }) => {
|
|
13006
|
+
const salesChannels = useComboboxData({
|
|
13007
|
+
queryFn: async (params) => {
|
|
13008
|
+
return await sdk.admin.salesChannel.list(params);
|
|
13009
|
+
},
|
|
13010
|
+
queryKey: ["sales-channels"],
|
|
13011
|
+
getOptions: (data) => {
|
|
13012
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
13013
|
+
label: salesChannel.name,
|
|
13014
|
+
value: salesChannel.id
|
|
13015
|
+
}));
|
|
13016
|
+
},
|
|
13017
|
+
defaultValue: order.sales_channel_id || void 0
|
|
13018
|
+
});
|
|
13019
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13020
|
+
Form$2.Field,
|
|
13021
|
+
{
|
|
13022
|
+
control,
|
|
13023
|
+
name: "sales_channel_id",
|
|
13024
|
+
render: ({ field }) => {
|
|
13025
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13026
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13027
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13028
|
+
Combobox,
|
|
13029
|
+
{
|
|
13030
|
+
options: salesChannels.options,
|
|
13031
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
13032
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13033
|
+
searchValue: salesChannels.searchValue,
|
|
13034
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13035
|
+
placeholder: "Select sales channel",
|
|
13036
|
+
...field
|
|
13037
|
+
}
|
|
13038
|
+
) }),
|
|
13039
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13040
|
+
] });
|
|
13041
|
+
}
|
|
13042
|
+
}
|
|
13043
|
+
);
|
|
13044
|
+
};
|
|
13045
|
+
const schema = objectType({
|
|
13046
|
+
sales_channel_id: stringType().min(1)
|
|
13047
|
+
});
|
|
13048
13048
|
const widgetModule = { widgets: [] };
|
|
13049
13049
|
const routeModule = {
|
|
13050
13050
|
routes: [
|
|
@@ -13089,10 +13089,6 @@ const routeModule = {
|
|
|
13089
13089
|
Component: Promotions,
|
|
13090
13090
|
path: "/draft-orders/:id/promotions"
|
|
13091
13091
|
},
|
|
13092
|
-
{
|
|
13093
|
-
Component: SalesChannel,
|
|
13094
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13095
|
-
},
|
|
13096
13092
|
{
|
|
13097
13093
|
Component: ShippingAddress,
|
|
13098
13094
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -13104,6 +13100,10 @@ const routeModule = {
|
|
|
13104
13100
|
{
|
|
13105
13101
|
Component: TransferOwnership,
|
|
13106
13102
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13103
|
+
},
|
|
13104
|
+
{
|
|
13105
|
+
Component: SalesChannel,
|
|
13106
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13107
13107
|
}
|
|
13108
13108
|
]
|
|
13109
13109
|
}
|
|
@@ -11447,112 +11447,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11447
11447
|
}
|
|
11448
11448
|
return Array.from(promotionIds);
|
|
11449
11449
|
}
|
|
11450
|
-
const SalesChannel = () => {
|
|
11451
|
-
const { id } = useParams();
|
|
11452
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11453
|
-
id,
|
|
11454
|
-
{
|
|
11455
|
-
fields: "+sales_channel_id"
|
|
11456
|
-
},
|
|
11457
|
-
{
|
|
11458
|
-
enabled: !!id
|
|
11459
|
-
}
|
|
11460
|
-
);
|
|
11461
|
-
if (isError) {
|
|
11462
|
-
throw error;
|
|
11463
|
-
}
|
|
11464
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11465
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11466
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11467
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11468
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11469
|
-
] }),
|
|
11470
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11471
|
-
] });
|
|
11472
|
-
};
|
|
11473
|
-
const SalesChannelForm = ({ order }) => {
|
|
11474
|
-
const form = useForm({
|
|
11475
|
-
defaultValues: {
|
|
11476
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11477
|
-
},
|
|
11478
|
-
resolver: zodResolver(schema$2)
|
|
11479
|
-
});
|
|
11480
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11481
|
-
const { handleSuccess } = useRouteModal();
|
|
11482
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11483
|
-
await mutateAsync(
|
|
11484
|
-
{
|
|
11485
|
-
sales_channel_id: data.sales_channel_id
|
|
11486
|
-
},
|
|
11487
|
-
{
|
|
11488
|
-
onSuccess: () => {
|
|
11489
|
-
toast.success("Sales channel updated");
|
|
11490
|
-
handleSuccess();
|
|
11491
|
-
},
|
|
11492
|
-
onError: (error) => {
|
|
11493
|
-
toast.error(error.message);
|
|
11494
|
-
}
|
|
11495
|
-
}
|
|
11496
|
-
);
|
|
11497
|
-
});
|
|
11498
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11499
|
-
KeyboundForm,
|
|
11500
|
-
{
|
|
11501
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11502
|
-
onSubmit,
|
|
11503
|
-
children: [
|
|
11504
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11505
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11506
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11507
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11508
|
-
] }) })
|
|
11509
|
-
]
|
|
11510
|
-
}
|
|
11511
|
-
) });
|
|
11512
|
-
};
|
|
11513
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11514
|
-
const salesChannels = useComboboxData({
|
|
11515
|
-
queryFn: async (params) => {
|
|
11516
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11517
|
-
},
|
|
11518
|
-
queryKey: ["sales-channels"],
|
|
11519
|
-
getOptions: (data) => {
|
|
11520
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11521
|
-
label: salesChannel.name,
|
|
11522
|
-
value: salesChannel.id
|
|
11523
|
-
}));
|
|
11524
|
-
},
|
|
11525
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11526
|
-
});
|
|
11527
|
-
return /* @__PURE__ */ jsx(
|
|
11528
|
-
Form$2.Field,
|
|
11529
|
-
{
|
|
11530
|
-
control,
|
|
11531
|
-
name: "sales_channel_id",
|
|
11532
|
-
render: ({ field }) => {
|
|
11533
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11534
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11535
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11536
|
-
Combobox,
|
|
11537
|
-
{
|
|
11538
|
-
options: salesChannels.options,
|
|
11539
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11540
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11541
|
-
searchValue: salesChannels.searchValue,
|
|
11542
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11543
|
-
placeholder: "Select sales channel",
|
|
11544
|
-
...field
|
|
11545
|
-
}
|
|
11546
|
-
) }),
|
|
11547
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11548
|
-
] });
|
|
11549
|
-
}
|
|
11550
|
-
}
|
|
11551
|
-
);
|
|
11552
|
-
};
|
|
11553
|
-
const schema$2 = objectType({
|
|
11554
|
-
sales_channel_id: stringType().min(1)
|
|
11555
|
-
});
|
|
11556
11450
|
const ShippingAddress = () => {
|
|
11557
11451
|
const { id } = useParams();
|
|
11558
11452
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -11585,7 +11479,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
11585
11479
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11586
11480
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11587
11481
|
},
|
|
11588
|
-
resolver: zodResolver(schema$
|
|
11482
|
+
resolver: zodResolver(schema$2)
|
|
11589
11483
|
});
|
|
11590
11484
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11591
11485
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11755,7 +11649,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
11755
11649
|
}
|
|
11756
11650
|
) });
|
|
11757
11651
|
};
|
|
11758
|
-
const schema$
|
|
11652
|
+
const schema$2 = addressSchema;
|
|
11759
11653
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11760
11654
|
const Shipping = () => {
|
|
11761
11655
|
var _a;
|
|
@@ -12586,7 +12480,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12586
12480
|
defaultValues: {
|
|
12587
12481
|
customer_id: order.customer_id || ""
|
|
12588
12482
|
},
|
|
12589
|
-
resolver: zodResolver(schema)
|
|
12483
|
+
resolver: zodResolver(schema$1)
|
|
12590
12484
|
});
|
|
12591
12485
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12592
12486
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13036,9 +12930,115 @@ const Illustration = () => {
|
|
|
13036
12930
|
}
|
|
13037
12931
|
);
|
|
13038
12932
|
};
|
|
13039
|
-
const schema = objectType({
|
|
12933
|
+
const schema$1 = objectType({
|
|
13040
12934
|
customer_id: stringType().min(1)
|
|
13041
12935
|
});
|
|
12936
|
+
const SalesChannel = () => {
|
|
12937
|
+
const { id } = useParams();
|
|
12938
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12939
|
+
id,
|
|
12940
|
+
{
|
|
12941
|
+
fields: "+sales_channel_id"
|
|
12942
|
+
},
|
|
12943
|
+
{
|
|
12944
|
+
enabled: !!id
|
|
12945
|
+
}
|
|
12946
|
+
);
|
|
12947
|
+
if (isError) {
|
|
12948
|
+
throw error;
|
|
12949
|
+
}
|
|
12950
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12951
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12952
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12953
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12954
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12955
|
+
] }),
|
|
12956
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12957
|
+
] });
|
|
12958
|
+
};
|
|
12959
|
+
const SalesChannelForm = ({ order }) => {
|
|
12960
|
+
const form = useForm({
|
|
12961
|
+
defaultValues: {
|
|
12962
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12963
|
+
},
|
|
12964
|
+
resolver: zodResolver(schema)
|
|
12965
|
+
});
|
|
12966
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12967
|
+
const { handleSuccess } = useRouteModal();
|
|
12968
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12969
|
+
await mutateAsync(
|
|
12970
|
+
{
|
|
12971
|
+
sales_channel_id: data.sales_channel_id
|
|
12972
|
+
},
|
|
12973
|
+
{
|
|
12974
|
+
onSuccess: () => {
|
|
12975
|
+
toast.success("Sales channel updated");
|
|
12976
|
+
handleSuccess();
|
|
12977
|
+
},
|
|
12978
|
+
onError: (error) => {
|
|
12979
|
+
toast.error(error.message);
|
|
12980
|
+
}
|
|
12981
|
+
}
|
|
12982
|
+
);
|
|
12983
|
+
});
|
|
12984
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12985
|
+
KeyboundForm,
|
|
12986
|
+
{
|
|
12987
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12988
|
+
onSubmit,
|
|
12989
|
+
children: [
|
|
12990
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12991
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12992
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12993
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12994
|
+
] }) })
|
|
12995
|
+
]
|
|
12996
|
+
}
|
|
12997
|
+
) });
|
|
12998
|
+
};
|
|
12999
|
+
const SalesChannelField = ({ control, order }) => {
|
|
13000
|
+
const salesChannels = useComboboxData({
|
|
13001
|
+
queryFn: async (params) => {
|
|
13002
|
+
return await sdk.admin.salesChannel.list(params);
|
|
13003
|
+
},
|
|
13004
|
+
queryKey: ["sales-channels"],
|
|
13005
|
+
getOptions: (data) => {
|
|
13006
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
13007
|
+
label: salesChannel.name,
|
|
13008
|
+
value: salesChannel.id
|
|
13009
|
+
}));
|
|
13010
|
+
},
|
|
13011
|
+
defaultValue: order.sales_channel_id || void 0
|
|
13012
|
+
});
|
|
13013
|
+
return /* @__PURE__ */ jsx(
|
|
13014
|
+
Form$2.Field,
|
|
13015
|
+
{
|
|
13016
|
+
control,
|
|
13017
|
+
name: "sales_channel_id",
|
|
13018
|
+
render: ({ field }) => {
|
|
13019
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13020
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13021
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
13022
|
+
Combobox,
|
|
13023
|
+
{
|
|
13024
|
+
options: salesChannels.options,
|
|
13025
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
13026
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13027
|
+
searchValue: salesChannels.searchValue,
|
|
13028
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13029
|
+
placeholder: "Select sales channel",
|
|
13030
|
+
...field
|
|
13031
|
+
}
|
|
13032
|
+
) }),
|
|
13033
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13034
|
+
] });
|
|
13035
|
+
}
|
|
13036
|
+
}
|
|
13037
|
+
);
|
|
13038
|
+
};
|
|
13039
|
+
const schema = objectType({
|
|
13040
|
+
sales_channel_id: stringType().min(1)
|
|
13041
|
+
});
|
|
13042
13042
|
const widgetModule = { widgets: [] };
|
|
13043
13043
|
const routeModule = {
|
|
13044
13044
|
routes: [
|
|
@@ -13083,10 +13083,6 @@ const routeModule = {
|
|
|
13083
13083
|
Component: Promotions,
|
|
13084
13084
|
path: "/draft-orders/:id/promotions"
|
|
13085
13085
|
},
|
|
13086
|
-
{
|
|
13087
|
-
Component: SalesChannel,
|
|
13088
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13089
|
-
},
|
|
13090
13086
|
{
|
|
13091
13087
|
Component: ShippingAddress,
|
|
13092
13088
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -13098,6 +13094,10 @@ const routeModule = {
|
|
|
13098
13094
|
{
|
|
13099
13095
|
Component: TransferOwnership,
|
|
13100
13096
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13097
|
+
},
|
|
13098
|
+
{
|
|
13099
|
+
Component: SalesChannel,
|
|
13100
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13101
13101
|
}
|
|
13102
13102
|
]
|
|
13103
13103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.10.4-preview-
|
|
3
|
+
"version": "2.10.4-preview-20250920000323",
|
|
4
4
|
"description": "A starter for Medusa plugins.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@ariakit/react": "^0.4.15",
|
|
38
38
|
"@hookform/resolvers": "3.4.2",
|
|
39
|
-
"@medusajs/js-sdk": "2.10.4-preview-
|
|
39
|
+
"@medusajs/js-sdk": "2.10.4-preview-20250920000323",
|
|
40
40
|
"@tanstack/react-query": "5.64.2",
|
|
41
41
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
42
42
|
"date-fns": "^3.6.0",
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
"react-hook-form": "7.49.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@medusajs/admin-sdk": "2.10.4-preview-
|
|
49
|
-
"@medusajs/cli": "2.10.4-preview-
|
|
50
|
-
"@medusajs/framework": "2.10.4-preview-
|
|
51
|
-
"@medusajs/icons": "2.10.4-preview-
|
|
52
|
-
"@medusajs/test-utils": "2.10.4-preview-
|
|
53
|
-
"@medusajs/types": "2.10.4-preview-
|
|
54
|
-
"@medusajs/ui": "4.0.24-preview-
|
|
55
|
-
"@medusajs/ui-preset": "2.10.4-preview-
|
|
56
|
-
"@mikro-orm/cli": "6.4
|
|
57
|
-
"@mikro-orm/core": "6.4
|
|
58
|
-
"@mikro-orm/knex": "6.4
|
|
59
|
-
"@mikro-orm/migrations": "6.4
|
|
60
|
-
"@mikro-orm/postgresql": "6.4
|
|
48
|
+
"@medusajs/admin-sdk": "2.10.4-preview-20250920000323",
|
|
49
|
+
"@medusajs/cli": "2.10.4-preview-20250920000323",
|
|
50
|
+
"@medusajs/framework": "2.10.4-preview-20250920000323",
|
|
51
|
+
"@medusajs/icons": "2.10.4-preview-20250920000323",
|
|
52
|
+
"@medusajs/test-utils": "2.10.4-preview-20250920000323",
|
|
53
|
+
"@medusajs/types": "2.10.4-preview-20250920000323",
|
|
54
|
+
"@medusajs/ui": "4.0.24-preview-20250920000323",
|
|
55
|
+
"@medusajs/ui-preset": "2.10.4-preview-20250920000323",
|
|
56
|
+
"@mikro-orm/cli": "6.5.4",
|
|
57
|
+
"@mikro-orm/core": "6.5.4",
|
|
58
|
+
"@mikro-orm/knex": "6.5.4",
|
|
59
|
+
"@mikro-orm/migrations": "6.5.4",
|
|
60
|
+
"@mikro-orm/postgresql": "6.5.4",
|
|
61
61
|
"@swc/core": "1.5.7",
|
|
62
62
|
"@types/lodash": "^4.17.15",
|
|
63
63
|
"@types/node": "^20.0.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@types/react-dom": "^18.2.25",
|
|
66
66
|
"awilix": "^8.0.1",
|
|
67
67
|
"lodash": "^4.17.21",
|
|
68
|
-
"pg": "^8.
|
|
68
|
+
"pg": "^8.16.3",
|
|
69
69
|
"react": "^18.2.0",
|
|
70
70
|
"react-dom": "^18.2.0",
|
|
71
71
|
"react-router-dom": "6.20.1",
|
|
@@ -76,20 +76,20 @@
|
|
|
76
76
|
"yalc": "^1.0.0-pre.53"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"@medusajs/admin-sdk": "2.10.4-preview-
|
|
80
|
-
"@medusajs/cli": "2.10.4-preview-
|
|
81
|
-
"@medusajs/framework": "2.10.4-preview-
|
|
82
|
-
"@medusajs/icons": "2.10.4-preview-
|
|
83
|
-
"@medusajs/test-utils": "2.10.4-preview-
|
|
84
|
-
"@medusajs/ui": "4.0.24-preview-
|
|
85
|
-
"@mikro-orm/cli": "6.4
|
|
86
|
-
"@mikro-orm/core": "6.4
|
|
87
|
-
"@mikro-orm/knex": "6.4
|
|
88
|
-
"@mikro-orm/migrations": "6.4
|
|
89
|
-
"@mikro-orm/postgresql": "6.4
|
|
79
|
+
"@medusajs/admin-sdk": "2.10.4-preview-20250920000323",
|
|
80
|
+
"@medusajs/cli": "2.10.4-preview-20250920000323",
|
|
81
|
+
"@medusajs/framework": "2.10.4-preview-20250920000323",
|
|
82
|
+
"@medusajs/icons": "2.10.4-preview-20250920000323",
|
|
83
|
+
"@medusajs/test-utils": "2.10.4-preview-20250920000323",
|
|
84
|
+
"@medusajs/ui": "4.0.24-preview-20250920000323",
|
|
85
|
+
"@mikro-orm/cli": "6.5.4",
|
|
86
|
+
"@mikro-orm/core": "6.5.4",
|
|
87
|
+
"@mikro-orm/knex": "6.5.4",
|
|
88
|
+
"@mikro-orm/migrations": "6.5.4",
|
|
89
|
+
"@mikro-orm/postgresql": "6.5.4",
|
|
90
90
|
"awilix": "^8.0.1",
|
|
91
91
|
"lodash": "^4.17.21",
|
|
92
|
-
"pg": "^8.
|
|
92
|
+
"pg": "^8.16.3",
|
|
93
93
|
"react-router-dom": "6.20.1"
|
|
94
94
|
},
|
|
95
95
|
"engines": {
|