@medusajs/draft-order 2.10.2-preview-20250912090157 → 2.10.2-preview-20250912120159
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 +116 -116
- package/.medusa/server/src/admin/index.mjs +116 -116
- package/package.json +16 -16
|
@@ -11432,6 +11432,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11432
11432
|
}
|
|
11433
11433
|
return Array.from(promotionIds);
|
|
11434
11434
|
}
|
|
11435
|
+
const SalesChannel = () => {
|
|
11436
|
+
const { id } = reactRouterDom.useParams();
|
|
11437
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11438
|
+
id,
|
|
11439
|
+
{
|
|
11440
|
+
fields: "+sales_channel_id"
|
|
11441
|
+
},
|
|
11442
|
+
{
|
|
11443
|
+
enabled: !!id
|
|
11444
|
+
}
|
|
11445
|
+
);
|
|
11446
|
+
if (isError) {
|
|
11447
|
+
throw error;
|
|
11448
|
+
}
|
|
11449
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11450
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11451
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11452
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11453
|
+
/* @__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" }) })
|
|
11454
|
+
] }),
|
|
11455
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11456
|
+
] });
|
|
11457
|
+
};
|
|
11458
|
+
const SalesChannelForm = ({ order }) => {
|
|
11459
|
+
const form = reactHookForm.useForm({
|
|
11460
|
+
defaultValues: {
|
|
11461
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11462
|
+
},
|
|
11463
|
+
resolver: zod.zodResolver(schema$3)
|
|
11464
|
+
});
|
|
11465
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11466
|
+
const { handleSuccess } = useRouteModal();
|
|
11467
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11468
|
+
await mutateAsync(
|
|
11469
|
+
{
|
|
11470
|
+
sales_channel_id: data.sales_channel_id
|
|
11471
|
+
},
|
|
11472
|
+
{
|
|
11473
|
+
onSuccess: () => {
|
|
11474
|
+
ui.toast.success("Sales channel updated");
|
|
11475
|
+
handleSuccess();
|
|
11476
|
+
},
|
|
11477
|
+
onError: (error) => {
|
|
11478
|
+
ui.toast.error(error.message);
|
|
11479
|
+
}
|
|
11480
|
+
}
|
|
11481
|
+
);
|
|
11482
|
+
});
|
|
11483
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11484
|
+
KeyboundForm,
|
|
11485
|
+
{
|
|
11486
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11487
|
+
onSubmit,
|
|
11488
|
+
children: [
|
|
11489
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11490
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11491
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11492
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11493
|
+
] }) })
|
|
11494
|
+
]
|
|
11495
|
+
}
|
|
11496
|
+
) });
|
|
11497
|
+
};
|
|
11498
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11499
|
+
const salesChannels = useComboboxData({
|
|
11500
|
+
queryFn: async (params) => {
|
|
11501
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11502
|
+
},
|
|
11503
|
+
queryKey: ["sales-channels"],
|
|
11504
|
+
getOptions: (data) => {
|
|
11505
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11506
|
+
label: salesChannel.name,
|
|
11507
|
+
value: salesChannel.id
|
|
11508
|
+
}));
|
|
11509
|
+
},
|
|
11510
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11511
|
+
});
|
|
11512
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11513
|
+
Form$2.Field,
|
|
11514
|
+
{
|
|
11515
|
+
control,
|
|
11516
|
+
name: "sales_channel_id",
|
|
11517
|
+
render: ({ field }) => {
|
|
11518
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11519
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11520
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11521
|
+
Combobox,
|
|
11522
|
+
{
|
|
11523
|
+
options: salesChannels.options,
|
|
11524
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11525
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11526
|
+
searchValue: salesChannels.searchValue,
|
|
11527
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11528
|
+
placeholder: "Select sales channel",
|
|
11529
|
+
...field
|
|
11530
|
+
}
|
|
11531
|
+
) }),
|
|
11532
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11533
|
+
] });
|
|
11534
|
+
}
|
|
11535
|
+
}
|
|
11536
|
+
);
|
|
11537
|
+
};
|
|
11538
|
+
const schema$3 = objectType({
|
|
11539
|
+
sales_channel_id: stringType().min(1)
|
|
11540
|
+
});
|
|
11435
11541
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11436
11542
|
const Shipping = () => {
|
|
11437
11543
|
var _a;
|
|
@@ -12271,7 +12377,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12271
12377
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12272
12378
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12273
12379
|
},
|
|
12274
|
-
resolver: zod.zodResolver(schema$
|
|
12380
|
+
resolver: zod.zodResolver(schema$2)
|
|
12275
12381
|
});
|
|
12276
12382
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12277
12383
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12441,7 +12547,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12441
12547
|
}
|
|
12442
12548
|
) });
|
|
12443
12549
|
};
|
|
12444
|
-
const schema$
|
|
12550
|
+
const schema$2 = addressSchema;
|
|
12445
12551
|
const TransferOwnership = () => {
|
|
12446
12552
|
const { id } = reactRouterDom.useParams();
|
|
12447
12553
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12465,7 +12571,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12465
12571
|
defaultValues: {
|
|
12466
12572
|
customer_id: order.customer_id || ""
|
|
12467
12573
|
},
|
|
12468
|
-
resolver: zod.zodResolver(schema$
|
|
12574
|
+
resolver: zod.zodResolver(schema$1)
|
|
12469
12575
|
});
|
|
12470
12576
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12471
12577
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12915,7 +13021,7 @@ const Illustration = () => {
|
|
|
12915
13021
|
}
|
|
12916
13022
|
);
|
|
12917
13023
|
};
|
|
12918
|
-
const schema$
|
|
13024
|
+
const schema$1 = objectType({
|
|
12919
13025
|
customer_id: stringType().min(1)
|
|
12920
13026
|
});
|
|
12921
13027
|
const CustomItems = () => {
|
|
@@ -12926,7 +13032,7 @@ const CustomItems = () => {
|
|
|
12926
13032
|
};
|
|
12927
13033
|
const CustomItemsForm = () => {
|
|
12928
13034
|
const form = reactHookForm.useForm({
|
|
12929
|
-
resolver: zod.zodResolver(schema
|
|
13035
|
+
resolver: zod.zodResolver(schema)
|
|
12930
13036
|
});
|
|
12931
13037
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
12932
13038
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
@@ -12936,114 +13042,8 @@ const CustomItemsForm = () => {
|
|
|
12936
13042
|
] }) })
|
|
12937
13043
|
] }) });
|
|
12938
13044
|
};
|
|
12939
|
-
const schema$1 = objectType({
|
|
12940
|
-
email: stringType().email()
|
|
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
13045
|
const schema = objectType({
|
|
13046
|
-
|
|
13046
|
+
email: stringType().email()
|
|
13047
13047
|
});
|
|
13048
13048
|
const widgetModule = { widgets: [] };
|
|
13049
13049
|
const routeModule = {
|
|
@@ -13085,6 +13085,10 @@ const routeModule = {
|
|
|
13085
13085
|
Component: Promotions,
|
|
13086
13086
|
path: "/draft-orders/:id/promotions"
|
|
13087
13087
|
},
|
|
13088
|
+
{
|
|
13089
|
+
Component: SalesChannel,
|
|
13090
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13091
|
+
},
|
|
13088
13092
|
{
|
|
13089
13093
|
Component: Shipping,
|
|
13090
13094
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13100,10 +13104,6 @@ const routeModule = {
|
|
|
13100
13104
|
{
|
|
13101
13105
|
Component: CustomItems,
|
|
13102
13106
|
path: "/draft-orders/:id/custom-items"
|
|
13103
|
-
},
|
|
13104
|
-
{
|
|
13105
|
-
Component: SalesChannel,
|
|
13106
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13107
13107
|
}
|
|
13108
13108
|
]
|
|
13109
13109
|
}
|
|
@@ -11426,6 +11426,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11426
11426
|
}
|
|
11427
11427
|
return Array.from(promotionIds);
|
|
11428
11428
|
}
|
|
11429
|
+
const SalesChannel = () => {
|
|
11430
|
+
const { id } = useParams();
|
|
11431
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11432
|
+
id,
|
|
11433
|
+
{
|
|
11434
|
+
fields: "+sales_channel_id"
|
|
11435
|
+
},
|
|
11436
|
+
{
|
|
11437
|
+
enabled: !!id
|
|
11438
|
+
}
|
|
11439
|
+
);
|
|
11440
|
+
if (isError) {
|
|
11441
|
+
throw error;
|
|
11442
|
+
}
|
|
11443
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11444
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11445
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11446
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11447
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11448
|
+
] }),
|
|
11449
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11450
|
+
] });
|
|
11451
|
+
};
|
|
11452
|
+
const SalesChannelForm = ({ order }) => {
|
|
11453
|
+
const form = useForm({
|
|
11454
|
+
defaultValues: {
|
|
11455
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11456
|
+
},
|
|
11457
|
+
resolver: zodResolver(schema$3)
|
|
11458
|
+
});
|
|
11459
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11460
|
+
const { handleSuccess } = useRouteModal();
|
|
11461
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11462
|
+
await mutateAsync(
|
|
11463
|
+
{
|
|
11464
|
+
sales_channel_id: data.sales_channel_id
|
|
11465
|
+
},
|
|
11466
|
+
{
|
|
11467
|
+
onSuccess: () => {
|
|
11468
|
+
toast.success("Sales channel updated");
|
|
11469
|
+
handleSuccess();
|
|
11470
|
+
},
|
|
11471
|
+
onError: (error) => {
|
|
11472
|
+
toast.error(error.message);
|
|
11473
|
+
}
|
|
11474
|
+
}
|
|
11475
|
+
);
|
|
11476
|
+
});
|
|
11477
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11478
|
+
KeyboundForm,
|
|
11479
|
+
{
|
|
11480
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11481
|
+
onSubmit,
|
|
11482
|
+
children: [
|
|
11483
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11484
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11485
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11486
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11487
|
+
] }) })
|
|
11488
|
+
]
|
|
11489
|
+
}
|
|
11490
|
+
) });
|
|
11491
|
+
};
|
|
11492
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11493
|
+
const salesChannels = useComboboxData({
|
|
11494
|
+
queryFn: async (params) => {
|
|
11495
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11496
|
+
},
|
|
11497
|
+
queryKey: ["sales-channels"],
|
|
11498
|
+
getOptions: (data) => {
|
|
11499
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11500
|
+
label: salesChannel.name,
|
|
11501
|
+
value: salesChannel.id
|
|
11502
|
+
}));
|
|
11503
|
+
},
|
|
11504
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11505
|
+
});
|
|
11506
|
+
return /* @__PURE__ */ jsx(
|
|
11507
|
+
Form$2.Field,
|
|
11508
|
+
{
|
|
11509
|
+
control,
|
|
11510
|
+
name: "sales_channel_id",
|
|
11511
|
+
render: ({ field }) => {
|
|
11512
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11513
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11514
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11515
|
+
Combobox,
|
|
11516
|
+
{
|
|
11517
|
+
options: salesChannels.options,
|
|
11518
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11519
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11520
|
+
searchValue: salesChannels.searchValue,
|
|
11521
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11522
|
+
placeholder: "Select sales channel",
|
|
11523
|
+
...field
|
|
11524
|
+
}
|
|
11525
|
+
) }),
|
|
11526
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11527
|
+
] });
|
|
11528
|
+
}
|
|
11529
|
+
}
|
|
11530
|
+
);
|
|
11531
|
+
};
|
|
11532
|
+
const schema$3 = objectType({
|
|
11533
|
+
sales_channel_id: stringType().min(1)
|
|
11534
|
+
});
|
|
11429
11535
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11430
11536
|
const Shipping = () => {
|
|
11431
11537
|
var _a;
|
|
@@ -12265,7 +12371,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12265
12371
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12266
12372
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12267
12373
|
},
|
|
12268
|
-
resolver: zodResolver(schema$
|
|
12374
|
+
resolver: zodResolver(schema$2)
|
|
12269
12375
|
});
|
|
12270
12376
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12271
12377
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12435,7 +12541,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12435
12541
|
}
|
|
12436
12542
|
) });
|
|
12437
12543
|
};
|
|
12438
|
-
const schema$
|
|
12544
|
+
const schema$2 = addressSchema;
|
|
12439
12545
|
const TransferOwnership = () => {
|
|
12440
12546
|
const { id } = useParams();
|
|
12441
12547
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12459,7 +12565,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12459
12565
|
defaultValues: {
|
|
12460
12566
|
customer_id: order.customer_id || ""
|
|
12461
12567
|
},
|
|
12462
|
-
resolver: zodResolver(schema$
|
|
12568
|
+
resolver: zodResolver(schema$1)
|
|
12463
12569
|
});
|
|
12464
12570
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12465
12571
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12909,7 +13015,7 @@ const Illustration = () => {
|
|
|
12909
13015
|
}
|
|
12910
13016
|
);
|
|
12911
13017
|
};
|
|
12912
|
-
const schema$
|
|
13018
|
+
const schema$1 = objectType({
|
|
12913
13019
|
customer_id: stringType().min(1)
|
|
12914
13020
|
});
|
|
12915
13021
|
const CustomItems = () => {
|
|
@@ -12920,7 +13026,7 @@ const CustomItems = () => {
|
|
|
12920
13026
|
};
|
|
12921
13027
|
const CustomItemsForm = () => {
|
|
12922
13028
|
const form = useForm({
|
|
12923
|
-
resolver: zodResolver(schema
|
|
13029
|
+
resolver: zodResolver(schema)
|
|
12924
13030
|
});
|
|
12925
13031
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
12926
13032
|
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
@@ -12930,114 +13036,8 @@ const CustomItemsForm = () => {
|
|
|
12930
13036
|
] }) })
|
|
12931
13037
|
] }) });
|
|
12932
13038
|
};
|
|
12933
|
-
const schema$1 = objectType({
|
|
12934
|
-
email: stringType().email()
|
|
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
13039
|
const schema = objectType({
|
|
13040
|
-
|
|
13040
|
+
email: stringType().email()
|
|
13041
13041
|
});
|
|
13042
13042
|
const widgetModule = { widgets: [] };
|
|
13043
13043
|
const routeModule = {
|
|
@@ -13079,6 +13079,10 @@ const routeModule = {
|
|
|
13079
13079
|
Component: Promotions,
|
|
13080
13080
|
path: "/draft-orders/:id/promotions"
|
|
13081
13081
|
},
|
|
13082
|
+
{
|
|
13083
|
+
Component: SalesChannel,
|
|
13084
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13085
|
+
},
|
|
13082
13086
|
{
|
|
13083
13087
|
Component: Shipping,
|
|
13084
13088
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13094,10 +13098,6 @@ const routeModule = {
|
|
|
13094
13098
|
{
|
|
13095
13099
|
Component: CustomItems,
|
|
13096
13100
|
path: "/draft-orders/:id/custom-items"
|
|
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.2-preview-
|
|
3
|
+
"version": "2.10.2-preview-20250912120159",
|
|
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.2-preview-
|
|
39
|
+
"@medusajs/js-sdk": "2.10.2-preview-20250912120159",
|
|
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,14 +45,14 @@
|
|
|
45
45
|
"react-hook-form": "7.49.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@medusajs/admin-sdk": "2.10.2-preview-
|
|
49
|
-
"@medusajs/cli": "2.10.2-preview-
|
|
50
|
-
"@medusajs/framework": "2.10.2-preview-
|
|
51
|
-
"@medusajs/icons": "2.10.2-preview-
|
|
52
|
-
"@medusajs/test-utils": "2.10.2-preview-
|
|
53
|
-
"@medusajs/types": "2.10.2-preview-
|
|
54
|
-
"@medusajs/ui": "4.0.22-preview-
|
|
55
|
-
"@medusajs/ui-preset": "2.10.2-preview-
|
|
48
|
+
"@medusajs/admin-sdk": "2.10.2-preview-20250912120159",
|
|
49
|
+
"@medusajs/cli": "2.10.2-preview-20250912120159",
|
|
50
|
+
"@medusajs/framework": "2.10.2-preview-20250912120159",
|
|
51
|
+
"@medusajs/icons": "2.10.2-preview-20250912120159",
|
|
52
|
+
"@medusajs/test-utils": "2.10.2-preview-20250912120159",
|
|
53
|
+
"@medusajs/types": "2.10.2-preview-20250912120159",
|
|
54
|
+
"@medusajs/ui": "4.0.22-preview-20250912120159",
|
|
55
|
+
"@medusajs/ui-preset": "2.10.2-preview-20250912120159",
|
|
56
56
|
"@mikro-orm/cli": "6.4.3",
|
|
57
57
|
"@mikro-orm/core": "6.4.3",
|
|
58
58
|
"@mikro-orm/knex": "6.4.3",
|
|
@@ -76,12 +76,12 @@
|
|
|
76
76
|
"yalc": "^1.0.0-pre.53"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"@medusajs/admin-sdk": "2.10.2-preview-
|
|
80
|
-
"@medusajs/cli": "2.10.2-preview-
|
|
81
|
-
"@medusajs/framework": "2.10.2-preview-
|
|
82
|
-
"@medusajs/icons": "2.10.2-preview-
|
|
83
|
-
"@medusajs/test-utils": "2.10.2-preview-
|
|
84
|
-
"@medusajs/ui": "4.0.22-preview-
|
|
79
|
+
"@medusajs/admin-sdk": "2.10.2-preview-20250912120159",
|
|
80
|
+
"@medusajs/cli": "2.10.2-preview-20250912120159",
|
|
81
|
+
"@medusajs/framework": "2.10.2-preview-20250912120159",
|
|
82
|
+
"@medusajs/icons": "2.10.2-preview-20250912120159",
|
|
83
|
+
"@medusajs/test-utils": "2.10.2-preview-20250912120159",
|
|
84
|
+
"@medusajs/ui": "4.0.22-preview-20250912120159",
|
|
85
85
|
"@mikro-orm/cli": "6.4.3",
|
|
86
86
|
"@mikro-orm/core": "6.4.3",
|
|
87
87
|
"@mikro-orm/knex": "6.4.3",
|