@medusajs/draft-order 2.11.4-preview-20251107032027 → 2.11.4-preview-20251107090135
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
|
@@ -11448,6 +11448,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11448
11448
|
}
|
|
11449
11449
|
return Array.from(promotionIds);
|
|
11450
11450
|
}
|
|
11451
|
+
const SalesChannel = () => {
|
|
11452
|
+
const { id } = reactRouterDom.useParams();
|
|
11453
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11454
|
+
id,
|
|
11455
|
+
{
|
|
11456
|
+
fields: "+sales_channel_id"
|
|
11457
|
+
},
|
|
11458
|
+
{
|
|
11459
|
+
enabled: !!id
|
|
11460
|
+
}
|
|
11461
|
+
);
|
|
11462
|
+
if (isError) {
|
|
11463
|
+
throw error;
|
|
11464
|
+
}
|
|
11465
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11466
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11467
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11468
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11469
|
+
/* @__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" }) })
|
|
11470
|
+
] }),
|
|
11471
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11472
|
+
] });
|
|
11473
|
+
};
|
|
11474
|
+
const SalesChannelForm = ({ order }) => {
|
|
11475
|
+
const form = reactHookForm.useForm({
|
|
11476
|
+
defaultValues: {
|
|
11477
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11478
|
+
},
|
|
11479
|
+
resolver: zod.zodResolver(schema$2)
|
|
11480
|
+
});
|
|
11481
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11482
|
+
const { handleSuccess } = useRouteModal();
|
|
11483
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11484
|
+
await mutateAsync(
|
|
11485
|
+
{
|
|
11486
|
+
sales_channel_id: data.sales_channel_id
|
|
11487
|
+
},
|
|
11488
|
+
{
|
|
11489
|
+
onSuccess: () => {
|
|
11490
|
+
ui.toast.success("Sales channel updated");
|
|
11491
|
+
handleSuccess();
|
|
11492
|
+
},
|
|
11493
|
+
onError: (error) => {
|
|
11494
|
+
ui.toast.error(error.message);
|
|
11495
|
+
}
|
|
11496
|
+
}
|
|
11497
|
+
);
|
|
11498
|
+
});
|
|
11499
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11500
|
+
KeyboundForm,
|
|
11501
|
+
{
|
|
11502
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11503
|
+
onSubmit,
|
|
11504
|
+
children: [
|
|
11505
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11506
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11507
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11508
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11509
|
+
] }) })
|
|
11510
|
+
]
|
|
11511
|
+
}
|
|
11512
|
+
) });
|
|
11513
|
+
};
|
|
11514
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11515
|
+
const salesChannels = useComboboxData({
|
|
11516
|
+
queryFn: async (params) => {
|
|
11517
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11518
|
+
},
|
|
11519
|
+
queryKey: ["sales-channels"],
|
|
11520
|
+
getOptions: (data) => {
|
|
11521
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11522
|
+
label: salesChannel.name,
|
|
11523
|
+
value: salesChannel.id
|
|
11524
|
+
}));
|
|
11525
|
+
},
|
|
11526
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11527
|
+
});
|
|
11528
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11529
|
+
Form$2.Field,
|
|
11530
|
+
{
|
|
11531
|
+
control,
|
|
11532
|
+
name: "sales_channel_id",
|
|
11533
|
+
render: ({ field }) => {
|
|
11534
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11535
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11536
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11537
|
+
Combobox,
|
|
11538
|
+
{
|
|
11539
|
+
options: salesChannels.options,
|
|
11540
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11541
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11542
|
+
searchValue: salesChannels.searchValue,
|
|
11543
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11544
|
+
placeholder: "Select sales channel",
|
|
11545
|
+
...field
|
|
11546
|
+
}
|
|
11547
|
+
) }),
|
|
11548
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11549
|
+
] });
|
|
11550
|
+
}
|
|
11551
|
+
}
|
|
11552
|
+
);
|
|
11553
|
+
};
|
|
11554
|
+
const schema$2 = objectType({
|
|
11555
|
+
sales_channel_id: stringType().min(1)
|
|
11556
|
+
});
|
|
11451
11557
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11452
11558
|
const Shipping = () => {
|
|
11453
11559
|
var _a;
|
|
@@ -12287,7 +12393,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12287
12393
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12288
12394
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12289
12395
|
},
|
|
12290
|
-
resolver: zod.zodResolver(schema$
|
|
12396
|
+
resolver: zod.zodResolver(schema$1)
|
|
12291
12397
|
});
|
|
12292
12398
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12293
12399
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12457,7 +12563,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12457
12563
|
}
|
|
12458
12564
|
) });
|
|
12459
12565
|
};
|
|
12460
|
-
const schema$
|
|
12566
|
+
const schema$1 = addressSchema;
|
|
12461
12567
|
const TransferOwnership = () => {
|
|
12462
12568
|
const { id } = reactRouterDom.useParams();
|
|
12463
12569
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12481,7 +12587,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12481
12587
|
defaultValues: {
|
|
12482
12588
|
customer_id: order.customer_id || ""
|
|
12483
12589
|
},
|
|
12484
|
-
resolver: zod.zodResolver(schema
|
|
12590
|
+
resolver: zod.zodResolver(schema)
|
|
12485
12591
|
});
|
|
12486
12592
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12487
12593
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12931,114 +13037,8 @@ const Illustration = () => {
|
|
|
12931
13037
|
}
|
|
12932
13038
|
);
|
|
12933
13039
|
};
|
|
12934
|
-
const schema$1 = objectType({
|
|
12935
|
-
customer_id: stringType().min(1)
|
|
12936
|
-
});
|
|
12937
|
-
const SalesChannel = () => {
|
|
12938
|
-
const { id } = reactRouterDom.useParams();
|
|
12939
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12940
|
-
id,
|
|
12941
|
-
{
|
|
12942
|
-
fields: "+sales_channel_id"
|
|
12943
|
-
},
|
|
12944
|
-
{
|
|
12945
|
-
enabled: !!id
|
|
12946
|
-
}
|
|
12947
|
-
);
|
|
12948
|
-
if (isError) {
|
|
12949
|
-
throw error;
|
|
12950
|
-
}
|
|
12951
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12952
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12953
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12954
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12955
|
-
/* @__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" }) })
|
|
12956
|
-
] }),
|
|
12957
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12958
|
-
] });
|
|
12959
|
-
};
|
|
12960
|
-
const SalesChannelForm = ({ order }) => {
|
|
12961
|
-
const form = reactHookForm.useForm({
|
|
12962
|
-
defaultValues: {
|
|
12963
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12964
|
-
},
|
|
12965
|
-
resolver: zod.zodResolver(schema)
|
|
12966
|
-
});
|
|
12967
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12968
|
-
const { handleSuccess } = useRouteModal();
|
|
12969
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12970
|
-
await mutateAsync(
|
|
12971
|
-
{
|
|
12972
|
-
sales_channel_id: data.sales_channel_id
|
|
12973
|
-
},
|
|
12974
|
-
{
|
|
12975
|
-
onSuccess: () => {
|
|
12976
|
-
ui.toast.success("Sales channel updated");
|
|
12977
|
-
handleSuccess();
|
|
12978
|
-
},
|
|
12979
|
-
onError: (error) => {
|
|
12980
|
-
ui.toast.error(error.message);
|
|
12981
|
-
}
|
|
12982
|
-
}
|
|
12983
|
-
);
|
|
12984
|
-
});
|
|
12985
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12986
|
-
KeyboundForm,
|
|
12987
|
-
{
|
|
12988
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12989
|
-
onSubmit,
|
|
12990
|
-
children: [
|
|
12991
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12992
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12993
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12994
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12995
|
-
] }) })
|
|
12996
|
-
]
|
|
12997
|
-
}
|
|
12998
|
-
) });
|
|
12999
|
-
};
|
|
13000
|
-
const SalesChannelField = ({ control, order }) => {
|
|
13001
|
-
const salesChannels = useComboboxData({
|
|
13002
|
-
queryFn: async (params) => {
|
|
13003
|
-
return await sdk.admin.salesChannel.list(params);
|
|
13004
|
-
},
|
|
13005
|
-
queryKey: ["sales-channels"],
|
|
13006
|
-
getOptions: (data) => {
|
|
13007
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
13008
|
-
label: salesChannel.name,
|
|
13009
|
-
value: salesChannel.id
|
|
13010
|
-
}));
|
|
13011
|
-
},
|
|
13012
|
-
defaultValue: order.sales_channel_id || void 0
|
|
13013
|
-
});
|
|
13014
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13015
|
-
Form$2.Field,
|
|
13016
|
-
{
|
|
13017
|
-
control,
|
|
13018
|
-
name: "sales_channel_id",
|
|
13019
|
-
render: ({ field }) => {
|
|
13020
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13021
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13022
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13023
|
-
Combobox,
|
|
13024
|
-
{
|
|
13025
|
-
options: salesChannels.options,
|
|
13026
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
13027
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13028
|
-
searchValue: salesChannels.searchValue,
|
|
13029
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13030
|
-
placeholder: "Select sales channel",
|
|
13031
|
-
...field
|
|
13032
|
-
}
|
|
13033
|
-
) }),
|
|
13034
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13035
|
-
] });
|
|
13036
|
-
}
|
|
13037
|
-
}
|
|
13038
|
-
);
|
|
13039
|
-
};
|
|
13040
13040
|
const schema = objectType({
|
|
13041
|
-
|
|
13041
|
+
customer_id: stringType().min(1)
|
|
13042
13042
|
});
|
|
13043
13043
|
const widgetModule = { widgets: [] };
|
|
13044
13044
|
const routeModule = {
|
|
@@ -13084,6 +13084,10 @@ const routeModule = {
|
|
|
13084
13084
|
Component: Promotions,
|
|
13085
13085
|
path: "/draft-orders/:id/promotions"
|
|
13086
13086
|
},
|
|
13087
|
+
{
|
|
13088
|
+
Component: SalesChannel,
|
|
13089
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13090
|
+
},
|
|
13087
13091
|
{
|
|
13088
13092
|
Component: Shipping,
|
|
13089
13093
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13095,10 +13099,6 @@ const routeModule = {
|
|
|
13095
13099
|
{
|
|
13096
13100
|
Component: TransferOwnership,
|
|
13097
13101
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13098
|
-
},
|
|
13099
|
-
{
|
|
13100
|
-
Component: SalesChannel,
|
|
13101
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13102
13102
|
}
|
|
13103
13103
|
]
|
|
13104
13104
|
}
|
|
@@ -11441,6 +11441,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11441
11441
|
}
|
|
11442
11442
|
return Array.from(promotionIds);
|
|
11443
11443
|
}
|
|
11444
|
+
const SalesChannel = () => {
|
|
11445
|
+
const { id } = useParams();
|
|
11446
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11447
|
+
id,
|
|
11448
|
+
{
|
|
11449
|
+
fields: "+sales_channel_id"
|
|
11450
|
+
},
|
|
11451
|
+
{
|
|
11452
|
+
enabled: !!id
|
|
11453
|
+
}
|
|
11454
|
+
);
|
|
11455
|
+
if (isError) {
|
|
11456
|
+
throw error;
|
|
11457
|
+
}
|
|
11458
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11459
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11460
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11461
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11462
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11463
|
+
] }),
|
|
11464
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11465
|
+
] });
|
|
11466
|
+
};
|
|
11467
|
+
const SalesChannelForm = ({ order }) => {
|
|
11468
|
+
const form = useForm({
|
|
11469
|
+
defaultValues: {
|
|
11470
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11471
|
+
},
|
|
11472
|
+
resolver: zodResolver(schema$2)
|
|
11473
|
+
});
|
|
11474
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11475
|
+
const { handleSuccess } = useRouteModal();
|
|
11476
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11477
|
+
await mutateAsync(
|
|
11478
|
+
{
|
|
11479
|
+
sales_channel_id: data.sales_channel_id
|
|
11480
|
+
},
|
|
11481
|
+
{
|
|
11482
|
+
onSuccess: () => {
|
|
11483
|
+
toast.success("Sales channel updated");
|
|
11484
|
+
handleSuccess();
|
|
11485
|
+
},
|
|
11486
|
+
onError: (error) => {
|
|
11487
|
+
toast.error(error.message);
|
|
11488
|
+
}
|
|
11489
|
+
}
|
|
11490
|
+
);
|
|
11491
|
+
});
|
|
11492
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11493
|
+
KeyboundForm,
|
|
11494
|
+
{
|
|
11495
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11496
|
+
onSubmit,
|
|
11497
|
+
children: [
|
|
11498
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11499
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11500
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11501
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11502
|
+
] }) })
|
|
11503
|
+
]
|
|
11504
|
+
}
|
|
11505
|
+
) });
|
|
11506
|
+
};
|
|
11507
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11508
|
+
const salesChannels = useComboboxData({
|
|
11509
|
+
queryFn: async (params) => {
|
|
11510
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11511
|
+
},
|
|
11512
|
+
queryKey: ["sales-channels"],
|
|
11513
|
+
getOptions: (data) => {
|
|
11514
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11515
|
+
label: salesChannel.name,
|
|
11516
|
+
value: salesChannel.id
|
|
11517
|
+
}));
|
|
11518
|
+
},
|
|
11519
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11520
|
+
});
|
|
11521
|
+
return /* @__PURE__ */ jsx(
|
|
11522
|
+
Form$2.Field,
|
|
11523
|
+
{
|
|
11524
|
+
control,
|
|
11525
|
+
name: "sales_channel_id",
|
|
11526
|
+
render: ({ field }) => {
|
|
11527
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11528
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11529
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11530
|
+
Combobox,
|
|
11531
|
+
{
|
|
11532
|
+
options: salesChannels.options,
|
|
11533
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11534
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11535
|
+
searchValue: salesChannels.searchValue,
|
|
11536
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11537
|
+
placeholder: "Select sales channel",
|
|
11538
|
+
...field
|
|
11539
|
+
}
|
|
11540
|
+
) }),
|
|
11541
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11542
|
+
] });
|
|
11543
|
+
}
|
|
11544
|
+
}
|
|
11545
|
+
);
|
|
11546
|
+
};
|
|
11547
|
+
const schema$2 = objectType({
|
|
11548
|
+
sales_channel_id: stringType().min(1)
|
|
11549
|
+
});
|
|
11444
11550
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11445
11551
|
const Shipping = () => {
|
|
11446
11552
|
var _a;
|
|
@@ -12280,7 +12386,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12280
12386
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12281
12387
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12282
12388
|
},
|
|
12283
|
-
resolver: zodResolver(schema$
|
|
12389
|
+
resolver: zodResolver(schema$1)
|
|
12284
12390
|
});
|
|
12285
12391
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12286
12392
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12450,7 +12556,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12450
12556
|
}
|
|
12451
12557
|
) });
|
|
12452
12558
|
};
|
|
12453
|
-
const schema$
|
|
12559
|
+
const schema$1 = addressSchema;
|
|
12454
12560
|
const TransferOwnership = () => {
|
|
12455
12561
|
const { id } = useParams();
|
|
12456
12562
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12474,7 +12580,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12474
12580
|
defaultValues: {
|
|
12475
12581
|
customer_id: order.customer_id || ""
|
|
12476
12582
|
},
|
|
12477
|
-
resolver: zodResolver(schema
|
|
12583
|
+
resolver: zodResolver(schema)
|
|
12478
12584
|
});
|
|
12479
12585
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12480
12586
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12924,114 +13030,8 @@ const Illustration = () => {
|
|
|
12924
13030
|
}
|
|
12925
13031
|
);
|
|
12926
13032
|
};
|
|
12927
|
-
const schema$1 = objectType({
|
|
12928
|
-
customer_id: stringType().min(1)
|
|
12929
|
-
});
|
|
12930
|
-
const SalesChannel = () => {
|
|
12931
|
-
const { id } = useParams();
|
|
12932
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12933
|
-
id,
|
|
12934
|
-
{
|
|
12935
|
-
fields: "+sales_channel_id"
|
|
12936
|
-
},
|
|
12937
|
-
{
|
|
12938
|
-
enabled: !!id
|
|
12939
|
-
}
|
|
12940
|
-
);
|
|
12941
|
-
if (isError) {
|
|
12942
|
-
throw error;
|
|
12943
|
-
}
|
|
12944
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12945
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12946
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12947
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12948
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12949
|
-
] }),
|
|
12950
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12951
|
-
] });
|
|
12952
|
-
};
|
|
12953
|
-
const SalesChannelForm = ({ order }) => {
|
|
12954
|
-
const form = useForm({
|
|
12955
|
-
defaultValues: {
|
|
12956
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12957
|
-
},
|
|
12958
|
-
resolver: zodResolver(schema)
|
|
12959
|
-
});
|
|
12960
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12961
|
-
const { handleSuccess } = useRouteModal();
|
|
12962
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12963
|
-
await mutateAsync(
|
|
12964
|
-
{
|
|
12965
|
-
sales_channel_id: data.sales_channel_id
|
|
12966
|
-
},
|
|
12967
|
-
{
|
|
12968
|
-
onSuccess: () => {
|
|
12969
|
-
toast.success("Sales channel updated");
|
|
12970
|
-
handleSuccess();
|
|
12971
|
-
},
|
|
12972
|
-
onError: (error) => {
|
|
12973
|
-
toast.error(error.message);
|
|
12974
|
-
}
|
|
12975
|
-
}
|
|
12976
|
-
);
|
|
12977
|
-
});
|
|
12978
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12979
|
-
KeyboundForm,
|
|
12980
|
-
{
|
|
12981
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12982
|
-
onSubmit,
|
|
12983
|
-
children: [
|
|
12984
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12985
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12986
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12987
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12988
|
-
] }) })
|
|
12989
|
-
]
|
|
12990
|
-
}
|
|
12991
|
-
) });
|
|
12992
|
-
};
|
|
12993
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12994
|
-
const salesChannels = useComboboxData({
|
|
12995
|
-
queryFn: async (params) => {
|
|
12996
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12997
|
-
},
|
|
12998
|
-
queryKey: ["sales-channels"],
|
|
12999
|
-
getOptions: (data) => {
|
|
13000
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
13001
|
-
label: salesChannel.name,
|
|
13002
|
-
value: salesChannel.id
|
|
13003
|
-
}));
|
|
13004
|
-
},
|
|
13005
|
-
defaultValue: order.sales_channel_id || void 0
|
|
13006
|
-
});
|
|
13007
|
-
return /* @__PURE__ */ jsx(
|
|
13008
|
-
Form$2.Field,
|
|
13009
|
-
{
|
|
13010
|
-
control,
|
|
13011
|
-
name: "sales_channel_id",
|
|
13012
|
-
render: ({ field }) => {
|
|
13013
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13014
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13015
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
13016
|
-
Combobox,
|
|
13017
|
-
{
|
|
13018
|
-
options: salesChannels.options,
|
|
13019
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
13020
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13021
|
-
searchValue: salesChannels.searchValue,
|
|
13022
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13023
|
-
placeholder: "Select sales channel",
|
|
13024
|
-
...field
|
|
13025
|
-
}
|
|
13026
|
-
) }),
|
|
13027
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13028
|
-
] });
|
|
13029
|
-
}
|
|
13030
|
-
}
|
|
13031
|
-
);
|
|
13032
|
-
};
|
|
13033
13033
|
const schema = objectType({
|
|
13034
|
-
|
|
13034
|
+
customer_id: stringType().min(1)
|
|
13035
13035
|
});
|
|
13036
13036
|
const widgetModule = { widgets: [] };
|
|
13037
13037
|
const routeModule = {
|
|
@@ -13077,6 +13077,10 @@ const routeModule = {
|
|
|
13077
13077
|
Component: Promotions,
|
|
13078
13078
|
path: "/draft-orders/:id/promotions"
|
|
13079
13079
|
},
|
|
13080
|
+
{
|
|
13081
|
+
Component: SalesChannel,
|
|
13082
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13083
|
+
},
|
|
13080
13084
|
{
|
|
13081
13085
|
Component: Shipping,
|
|
13082
13086
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13088,10 +13092,6 @@ const routeModule = {
|
|
|
13088
13092
|
{
|
|
13089
13093
|
Component: TransferOwnership,
|
|
13090
13094
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13091
|
-
},
|
|
13092
|
-
{
|
|
13093
|
-
Component: SalesChannel,
|
|
13094
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13095
13095
|
}
|
|
13096
13096
|
]
|
|
13097
13097
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.11.4-preview-
|
|
3
|
+
"version": "2.11.4-preview-20251107090135",
|
|
4
4
|
"description": "A starter for Medusa plugins.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@ariakit/react": "^0.4.15",
|
|
38
38
|
"@babel/runtime": "^7.26.10",
|
|
39
39
|
"@hookform/resolvers": "3.4.2",
|
|
40
|
-
"@medusajs/js-sdk": "2.11.4-preview-
|
|
40
|
+
"@medusajs/js-sdk": "2.11.4-preview-20251107090135",
|
|
41
41
|
"@tanstack/react-query": "5.64.2",
|
|
42
42
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
43
43
|
"date-fns": "^3.6.0",
|
|
@@ -48,22 +48,22 @@
|
|
|
48
48
|
"react-hook-form": "7.49.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@medusajs/admin-sdk": "2.11.4-preview-
|
|
52
|
-
"@medusajs/cli": "2.11.4-preview-
|
|
53
|
-
"@medusajs/framework": "2.11.4-preview-
|
|
54
|
-
"@medusajs/icons": "2.11.4-preview-
|
|
55
|
-
"@medusajs/test-utils": "2.11.4-preview-
|
|
56
|
-
"@medusajs/types": "2.11.4-preview-
|
|
57
|
-
"@medusajs/ui": "4.0.28-preview-
|
|
58
|
-
"@medusajs/ui-preset": "2.11.4-preview-
|
|
51
|
+
"@medusajs/admin-sdk": "2.11.4-preview-20251107090135",
|
|
52
|
+
"@medusajs/cli": "2.11.4-preview-20251107090135",
|
|
53
|
+
"@medusajs/framework": "2.11.4-preview-20251107090135",
|
|
54
|
+
"@medusajs/icons": "2.11.4-preview-20251107090135",
|
|
55
|
+
"@medusajs/test-utils": "2.11.4-preview-20251107090135",
|
|
56
|
+
"@medusajs/types": "2.11.4-preview-20251107090135",
|
|
57
|
+
"@medusajs/ui": "4.0.28-preview-20251107090135",
|
|
58
|
+
"@medusajs/ui-preset": "2.11.4-preview-20251107090135"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@medusajs/admin-sdk": "2.11.4-preview-
|
|
62
|
-
"@medusajs/cli": "2.11.4-preview-
|
|
63
|
-
"@medusajs/framework": "2.11.4-preview-
|
|
64
|
-
"@medusajs/icons": "2.11.4-preview-
|
|
65
|
-
"@medusajs/test-utils": "2.11.4-preview-
|
|
66
|
-
"@medusajs/ui": "4.0.28-preview-
|
|
61
|
+
"@medusajs/admin-sdk": "2.11.4-preview-20251107090135",
|
|
62
|
+
"@medusajs/cli": "2.11.4-preview-20251107090135",
|
|
63
|
+
"@medusajs/framework": "2.11.4-preview-20251107090135",
|
|
64
|
+
"@medusajs/icons": "2.11.4-preview-20251107090135",
|
|
65
|
+
"@medusajs/test-utils": "2.11.4-preview-20251107090135",
|
|
66
|
+
"@medusajs/ui": "4.0.28-preview-20251107090135",
|
|
67
67
|
"react": "^18.3.1",
|
|
68
68
|
"react-dom": "^18.3.1",
|
|
69
69
|
"react-router-dom": "6.20.1"
|