@medusajs/draft-order 2.22.2-snapshot-20261026132527 → 2.22.2
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 +23 -22
|
@@ -7630,112 +7630,6 @@ function getHasUneditableRows(metadata) {
|
|
|
7630
7630
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
7631
7631
|
);
|
|
7632
7632
|
}
|
|
7633
|
-
const SalesChannel = () => {
|
|
7634
|
-
const { id } = reactRouterDom.useParams();
|
|
7635
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
7636
|
-
id,
|
|
7637
|
-
{
|
|
7638
|
-
fields: "+sales_channel_id"
|
|
7639
|
-
},
|
|
7640
|
-
{
|
|
7641
|
-
enabled: !!id
|
|
7642
|
-
}
|
|
7643
|
-
);
|
|
7644
|
-
if (isError) {
|
|
7645
|
-
throw error;
|
|
7646
|
-
}
|
|
7647
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
7648
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
7649
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
7650
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
7651
|
-
/* @__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" }) })
|
|
7652
|
-
] }),
|
|
7653
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
7654
|
-
] });
|
|
7655
|
-
};
|
|
7656
|
-
const SalesChannelForm = ({ order }) => {
|
|
7657
|
-
const form = reactHookForm.useForm({
|
|
7658
|
-
defaultValues: {
|
|
7659
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
7660
|
-
},
|
|
7661
|
-
resolver: zod$1.zodResolver(schema$2)
|
|
7662
|
-
});
|
|
7663
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7664
|
-
const { handleSuccess } = useRouteModal();
|
|
7665
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
7666
|
-
await mutateAsync(
|
|
7667
|
-
{
|
|
7668
|
-
sales_channel_id: data.sales_channel_id
|
|
7669
|
-
},
|
|
7670
|
-
{
|
|
7671
|
-
onSuccess: () => {
|
|
7672
|
-
ui.toast.success("Sales channel updated");
|
|
7673
|
-
handleSuccess();
|
|
7674
|
-
},
|
|
7675
|
-
onError: (error) => {
|
|
7676
|
-
ui.toast.error(error.message);
|
|
7677
|
-
}
|
|
7678
|
-
}
|
|
7679
|
-
);
|
|
7680
|
-
});
|
|
7681
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7682
|
-
KeyboundForm,
|
|
7683
|
-
{
|
|
7684
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
7685
|
-
onSubmit,
|
|
7686
|
-
children: [
|
|
7687
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
7688
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7689
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7690
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
7691
|
-
] }) })
|
|
7692
|
-
]
|
|
7693
|
-
}
|
|
7694
|
-
) });
|
|
7695
|
-
};
|
|
7696
|
-
const SalesChannelField = ({ control, order }) => {
|
|
7697
|
-
const salesChannels = useComboboxData({
|
|
7698
|
-
queryFn: async (params) => {
|
|
7699
|
-
return await sdk.admin.salesChannel.list(params);
|
|
7700
|
-
},
|
|
7701
|
-
queryKey: ["sales-channels"],
|
|
7702
|
-
getOptions: (data) => {
|
|
7703
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
7704
|
-
label: salesChannel.name,
|
|
7705
|
-
value: salesChannel.id
|
|
7706
|
-
}));
|
|
7707
|
-
},
|
|
7708
|
-
defaultValue: order.sales_channel_id || void 0
|
|
7709
|
-
});
|
|
7710
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7711
|
-
Form$2.Field,
|
|
7712
|
-
{
|
|
7713
|
-
control,
|
|
7714
|
-
name: "sales_channel_id",
|
|
7715
|
-
render: ({ field }) => {
|
|
7716
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7717
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
7718
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7719
|
-
Combobox,
|
|
7720
|
-
{
|
|
7721
|
-
options: salesChannels.options,
|
|
7722
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
7723
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
7724
|
-
searchValue: salesChannels.searchValue,
|
|
7725
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
7726
|
-
placeholder: "Select sales channel",
|
|
7727
|
-
...field
|
|
7728
|
-
}
|
|
7729
|
-
) }),
|
|
7730
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7731
|
-
] });
|
|
7732
|
-
}
|
|
7733
|
-
}
|
|
7734
|
-
);
|
|
7735
|
-
};
|
|
7736
|
-
const schema$2 = zod.z.object({
|
|
7737
|
-
sales_channel_id: zod.z.string().min(1)
|
|
7738
|
-
});
|
|
7739
7633
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
7740
7634
|
const promotionsQueryKeys = {
|
|
7741
7635
|
list: (query2) => [
|
|
@@ -8836,7 +8730,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
8836
8730
|
postal_code: order.shipping_address?.postal_code ?? "",
|
|
8837
8731
|
phone: order.shipping_address?.phone ?? ""
|
|
8838
8732
|
},
|
|
8839
|
-
resolver: zod$1.zodResolver(schema$
|
|
8733
|
+
resolver: zod$1.zodResolver(schema$2)
|
|
8840
8734
|
});
|
|
8841
8735
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8842
8736
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9006,7 +8900,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
9006
8900
|
}
|
|
9007
8901
|
) });
|
|
9008
8902
|
};
|
|
9009
|
-
const schema$
|
|
8903
|
+
const schema$2 = addressSchema;
|
|
9010
8904
|
const TransferOwnership = () => {
|
|
9011
8905
|
const { id } = reactRouterDom.useParams();
|
|
9012
8906
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -9029,7 +8923,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
9029
8923
|
defaultValues: {
|
|
9030
8924
|
customer_id: order.customer_id || ""
|
|
9031
8925
|
},
|
|
9032
|
-
resolver: zod$1.zodResolver(schema)
|
|
8926
|
+
resolver: zod$1.zodResolver(schema$1)
|
|
9033
8927
|
});
|
|
9034
8928
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9035
8929
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9481,9 +9375,115 @@ const Illustration = () => {
|
|
|
9481
9375
|
}
|
|
9482
9376
|
);
|
|
9483
9377
|
};
|
|
9484
|
-
const schema = zod.z.object({
|
|
9378
|
+
const schema$1 = zod.z.object({
|
|
9485
9379
|
customer_id: zod.z.string().min(1)
|
|
9486
9380
|
});
|
|
9381
|
+
const SalesChannel = () => {
|
|
9382
|
+
const { id } = reactRouterDom.useParams();
|
|
9383
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
9384
|
+
id,
|
|
9385
|
+
{
|
|
9386
|
+
fields: "+sales_channel_id"
|
|
9387
|
+
},
|
|
9388
|
+
{
|
|
9389
|
+
enabled: !!id
|
|
9390
|
+
}
|
|
9391
|
+
);
|
|
9392
|
+
if (isError) {
|
|
9393
|
+
throw error;
|
|
9394
|
+
}
|
|
9395
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
9396
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9397
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9398
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
9399
|
+
/* @__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" }) })
|
|
9400
|
+
] }),
|
|
9401
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
9402
|
+
] });
|
|
9403
|
+
};
|
|
9404
|
+
const SalesChannelForm = ({ order }) => {
|
|
9405
|
+
const form = reactHookForm.useForm({
|
|
9406
|
+
defaultValues: {
|
|
9407
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
9408
|
+
},
|
|
9409
|
+
resolver: zod$1.zodResolver(schema)
|
|
9410
|
+
});
|
|
9411
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9412
|
+
const { handleSuccess } = useRouteModal();
|
|
9413
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9414
|
+
await mutateAsync(
|
|
9415
|
+
{
|
|
9416
|
+
sales_channel_id: data.sales_channel_id
|
|
9417
|
+
},
|
|
9418
|
+
{
|
|
9419
|
+
onSuccess: () => {
|
|
9420
|
+
ui.toast.success("Sales channel updated");
|
|
9421
|
+
handleSuccess();
|
|
9422
|
+
},
|
|
9423
|
+
onError: (error) => {
|
|
9424
|
+
ui.toast.error(error.message);
|
|
9425
|
+
}
|
|
9426
|
+
}
|
|
9427
|
+
);
|
|
9428
|
+
});
|
|
9429
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9430
|
+
KeyboundForm,
|
|
9431
|
+
{
|
|
9432
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9433
|
+
onSubmit,
|
|
9434
|
+
children: [
|
|
9435
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
9436
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9437
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9438
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9439
|
+
] }) })
|
|
9440
|
+
]
|
|
9441
|
+
}
|
|
9442
|
+
) });
|
|
9443
|
+
};
|
|
9444
|
+
const SalesChannelField = ({ control, order }) => {
|
|
9445
|
+
const salesChannels = useComboboxData({
|
|
9446
|
+
queryFn: async (params) => {
|
|
9447
|
+
return await sdk.admin.salesChannel.list(params);
|
|
9448
|
+
},
|
|
9449
|
+
queryKey: ["sales-channels"],
|
|
9450
|
+
getOptions: (data) => {
|
|
9451
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
9452
|
+
label: salesChannel.name,
|
|
9453
|
+
value: salesChannel.id
|
|
9454
|
+
}));
|
|
9455
|
+
},
|
|
9456
|
+
defaultValue: order.sales_channel_id || void 0
|
|
9457
|
+
});
|
|
9458
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9459
|
+
Form$2.Field,
|
|
9460
|
+
{
|
|
9461
|
+
control,
|
|
9462
|
+
name: "sales_channel_id",
|
|
9463
|
+
render: ({ field }) => {
|
|
9464
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9465
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
9466
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9467
|
+
Combobox,
|
|
9468
|
+
{
|
|
9469
|
+
options: salesChannels.options,
|
|
9470
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
9471
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
9472
|
+
searchValue: salesChannels.searchValue,
|
|
9473
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
9474
|
+
placeholder: "Select sales channel",
|
|
9475
|
+
...field
|
|
9476
|
+
}
|
|
9477
|
+
) }),
|
|
9478
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9479
|
+
] });
|
|
9480
|
+
}
|
|
9481
|
+
}
|
|
9482
|
+
);
|
|
9483
|
+
};
|
|
9484
|
+
const schema = zod.z.object({
|
|
9485
|
+
sales_channel_id: zod.z.string().min(1)
|
|
9486
|
+
});
|
|
9487
9487
|
const widgetModule = { widgets: [] };
|
|
9488
9488
|
const routeModule = {
|
|
9489
9489
|
routes: [
|
|
@@ -9524,10 +9524,6 @@ const routeModule = {
|
|
|
9524
9524
|
Component: Metadata,
|
|
9525
9525
|
path: "/draft-orders/:id/metadata"
|
|
9526
9526
|
},
|
|
9527
|
-
{
|
|
9528
|
-
Component: SalesChannel,
|
|
9529
|
-
path: "/draft-orders/:id/sales-channel"
|
|
9530
|
-
},
|
|
9531
9527
|
{
|
|
9532
9528
|
Component: Promotions,
|
|
9533
9529
|
path: "/draft-orders/:id/promotions"
|
|
@@ -9543,6 +9539,10 @@ const routeModule = {
|
|
|
9543
9539
|
{
|
|
9544
9540
|
Component: TransferOwnership,
|
|
9545
9541
|
path: "/draft-orders/:id/transfer-ownership"
|
|
9542
|
+
},
|
|
9543
|
+
{
|
|
9544
|
+
Component: SalesChannel,
|
|
9545
|
+
path: "/draft-orders/:id/sales-channel"
|
|
9546
9546
|
}
|
|
9547
9547
|
]
|
|
9548
9548
|
}
|
|
@@ -7623,112 +7623,6 @@ function getHasUneditableRows(metadata) {
|
|
|
7623
7623
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
7624
7624
|
);
|
|
7625
7625
|
}
|
|
7626
|
-
const SalesChannel = () => {
|
|
7627
|
-
const { id } = useParams();
|
|
7628
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
7629
|
-
id,
|
|
7630
|
-
{
|
|
7631
|
-
fields: "+sales_channel_id"
|
|
7632
|
-
},
|
|
7633
|
-
{
|
|
7634
|
-
enabled: !!id
|
|
7635
|
-
}
|
|
7636
|
-
);
|
|
7637
|
-
if (isError) {
|
|
7638
|
-
throw error;
|
|
7639
|
-
}
|
|
7640
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
7641
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
7642
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
7643
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
7644
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
7645
|
-
] }),
|
|
7646
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
7647
|
-
] });
|
|
7648
|
-
};
|
|
7649
|
-
const SalesChannelForm = ({ order }) => {
|
|
7650
|
-
const form = useForm({
|
|
7651
|
-
defaultValues: {
|
|
7652
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
7653
|
-
},
|
|
7654
|
-
resolver: zodResolver(schema$2)
|
|
7655
|
-
});
|
|
7656
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7657
|
-
const { handleSuccess } = useRouteModal();
|
|
7658
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
7659
|
-
await mutateAsync(
|
|
7660
|
-
{
|
|
7661
|
-
sales_channel_id: data.sales_channel_id
|
|
7662
|
-
},
|
|
7663
|
-
{
|
|
7664
|
-
onSuccess: () => {
|
|
7665
|
-
toast.success("Sales channel updated");
|
|
7666
|
-
handleSuccess();
|
|
7667
|
-
},
|
|
7668
|
-
onError: (error) => {
|
|
7669
|
-
toast.error(error.message);
|
|
7670
|
-
}
|
|
7671
|
-
}
|
|
7672
|
-
);
|
|
7673
|
-
});
|
|
7674
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
7675
|
-
KeyboundForm,
|
|
7676
|
-
{
|
|
7677
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
7678
|
-
onSubmit,
|
|
7679
|
-
children: [
|
|
7680
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
7681
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7682
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7683
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
7684
|
-
] }) })
|
|
7685
|
-
]
|
|
7686
|
-
}
|
|
7687
|
-
) });
|
|
7688
|
-
};
|
|
7689
|
-
const SalesChannelField = ({ control, order }) => {
|
|
7690
|
-
const salesChannels = useComboboxData({
|
|
7691
|
-
queryFn: async (params) => {
|
|
7692
|
-
return await sdk.admin.salesChannel.list(params);
|
|
7693
|
-
},
|
|
7694
|
-
queryKey: ["sales-channels"],
|
|
7695
|
-
getOptions: (data) => {
|
|
7696
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
7697
|
-
label: salesChannel.name,
|
|
7698
|
-
value: salesChannel.id
|
|
7699
|
-
}));
|
|
7700
|
-
},
|
|
7701
|
-
defaultValue: order.sales_channel_id || void 0
|
|
7702
|
-
});
|
|
7703
|
-
return /* @__PURE__ */ jsx(
|
|
7704
|
-
Form$2.Field,
|
|
7705
|
-
{
|
|
7706
|
-
control,
|
|
7707
|
-
name: "sales_channel_id",
|
|
7708
|
-
render: ({ field }) => {
|
|
7709
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
7710
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
7711
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
7712
|
-
Combobox,
|
|
7713
|
-
{
|
|
7714
|
-
options: salesChannels.options,
|
|
7715
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
7716
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
7717
|
-
searchValue: salesChannels.searchValue,
|
|
7718
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
7719
|
-
placeholder: "Select sales channel",
|
|
7720
|
-
...field
|
|
7721
|
-
}
|
|
7722
|
-
) }),
|
|
7723
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
7724
|
-
] });
|
|
7725
|
-
}
|
|
7726
|
-
}
|
|
7727
|
-
);
|
|
7728
|
-
};
|
|
7729
|
-
const schema$2 = z.object({
|
|
7730
|
-
sales_channel_id: z.string().min(1)
|
|
7731
|
-
});
|
|
7732
7626
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
7733
7627
|
const promotionsQueryKeys = {
|
|
7734
7628
|
list: (query2) => [
|
|
@@ -8829,7 +8723,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
8829
8723
|
postal_code: order.shipping_address?.postal_code ?? "",
|
|
8830
8724
|
phone: order.shipping_address?.phone ?? ""
|
|
8831
8725
|
},
|
|
8832
|
-
resolver: zodResolver(schema$
|
|
8726
|
+
resolver: zodResolver(schema$2)
|
|
8833
8727
|
});
|
|
8834
8728
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8835
8729
|
const { handleSuccess } = useRouteModal();
|
|
@@ -8999,7 +8893,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
8999
8893
|
}
|
|
9000
8894
|
) });
|
|
9001
8895
|
};
|
|
9002
|
-
const schema$
|
|
8896
|
+
const schema$2 = addressSchema;
|
|
9003
8897
|
const TransferOwnership = () => {
|
|
9004
8898
|
const { id } = useParams();
|
|
9005
8899
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -9022,7 +8916,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
9022
8916
|
defaultValues: {
|
|
9023
8917
|
customer_id: order.customer_id || ""
|
|
9024
8918
|
},
|
|
9025
|
-
resolver: zodResolver(schema)
|
|
8919
|
+
resolver: zodResolver(schema$1)
|
|
9026
8920
|
});
|
|
9027
8921
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9028
8922
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9474,9 +9368,115 @@ const Illustration = () => {
|
|
|
9474
9368
|
}
|
|
9475
9369
|
);
|
|
9476
9370
|
};
|
|
9477
|
-
const schema = z.object({
|
|
9371
|
+
const schema$1 = z.object({
|
|
9478
9372
|
customer_id: z.string().min(1)
|
|
9479
9373
|
});
|
|
9374
|
+
const SalesChannel = () => {
|
|
9375
|
+
const { id } = useParams();
|
|
9376
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
9377
|
+
id,
|
|
9378
|
+
{
|
|
9379
|
+
fields: "+sales_channel_id"
|
|
9380
|
+
},
|
|
9381
|
+
{
|
|
9382
|
+
enabled: !!id
|
|
9383
|
+
}
|
|
9384
|
+
);
|
|
9385
|
+
if (isError) {
|
|
9386
|
+
throw error;
|
|
9387
|
+
}
|
|
9388
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
9389
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9390
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9391
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
9392
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
9393
|
+
] }),
|
|
9394
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
9395
|
+
] });
|
|
9396
|
+
};
|
|
9397
|
+
const SalesChannelForm = ({ order }) => {
|
|
9398
|
+
const form = useForm({
|
|
9399
|
+
defaultValues: {
|
|
9400
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
9401
|
+
},
|
|
9402
|
+
resolver: zodResolver(schema)
|
|
9403
|
+
});
|
|
9404
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9405
|
+
const { handleSuccess } = useRouteModal();
|
|
9406
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9407
|
+
await mutateAsync(
|
|
9408
|
+
{
|
|
9409
|
+
sales_channel_id: data.sales_channel_id
|
|
9410
|
+
},
|
|
9411
|
+
{
|
|
9412
|
+
onSuccess: () => {
|
|
9413
|
+
toast.success("Sales channel updated");
|
|
9414
|
+
handleSuccess();
|
|
9415
|
+
},
|
|
9416
|
+
onError: (error) => {
|
|
9417
|
+
toast.error(error.message);
|
|
9418
|
+
}
|
|
9419
|
+
}
|
|
9420
|
+
);
|
|
9421
|
+
});
|
|
9422
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9423
|
+
KeyboundForm,
|
|
9424
|
+
{
|
|
9425
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9426
|
+
onSubmit,
|
|
9427
|
+
children: [
|
|
9428
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
9429
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9430
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9431
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9432
|
+
] }) })
|
|
9433
|
+
]
|
|
9434
|
+
}
|
|
9435
|
+
) });
|
|
9436
|
+
};
|
|
9437
|
+
const SalesChannelField = ({ control, order }) => {
|
|
9438
|
+
const salesChannels = useComboboxData({
|
|
9439
|
+
queryFn: async (params) => {
|
|
9440
|
+
return await sdk.admin.salesChannel.list(params);
|
|
9441
|
+
},
|
|
9442
|
+
queryKey: ["sales-channels"],
|
|
9443
|
+
getOptions: (data) => {
|
|
9444
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
9445
|
+
label: salesChannel.name,
|
|
9446
|
+
value: salesChannel.id
|
|
9447
|
+
}));
|
|
9448
|
+
},
|
|
9449
|
+
defaultValue: order.sales_channel_id || void 0
|
|
9450
|
+
});
|
|
9451
|
+
return /* @__PURE__ */ jsx(
|
|
9452
|
+
Form$2.Field,
|
|
9453
|
+
{
|
|
9454
|
+
control,
|
|
9455
|
+
name: "sales_channel_id",
|
|
9456
|
+
render: ({ field }) => {
|
|
9457
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9458
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
9459
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
9460
|
+
Combobox,
|
|
9461
|
+
{
|
|
9462
|
+
options: salesChannels.options,
|
|
9463
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
9464
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
9465
|
+
searchValue: salesChannels.searchValue,
|
|
9466
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
9467
|
+
placeholder: "Select sales channel",
|
|
9468
|
+
...field
|
|
9469
|
+
}
|
|
9470
|
+
) }),
|
|
9471
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9472
|
+
] });
|
|
9473
|
+
}
|
|
9474
|
+
}
|
|
9475
|
+
);
|
|
9476
|
+
};
|
|
9477
|
+
const schema = z.object({
|
|
9478
|
+
sales_channel_id: z.string().min(1)
|
|
9479
|
+
});
|
|
9480
9480
|
const widgetModule = { widgets: [] };
|
|
9481
9481
|
const routeModule = {
|
|
9482
9482
|
routes: [
|
|
@@ -9517,10 +9517,6 @@ const routeModule = {
|
|
|
9517
9517
|
Component: Metadata,
|
|
9518
9518
|
path: "/draft-orders/:id/metadata"
|
|
9519
9519
|
},
|
|
9520
|
-
{
|
|
9521
|
-
Component: SalesChannel,
|
|
9522
|
-
path: "/draft-orders/:id/sales-channel"
|
|
9523
|
-
},
|
|
9524
9520
|
{
|
|
9525
9521
|
Component: Promotions,
|
|
9526
9522
|
path: "/draft-orders/:id/promotions"
|
|
@@ -9536,6 +9532,10 @@ const routeModule = {
|
|
|
9536
9532
|
{
|
|
9537
9533
|
Component: TransferOwnership,
|
|
9538
9534
|
path: "/draft-orders/:id/transfer-ownership"
|
|
9535
|
+
},
|
|
9536
|
+
{
|
|
9537
|
+
Component: SalesChannel,
|
|
9538
|
+
path: "/draft-orders/:id/sales-channel"
|
|
9539
9539
|
}
|
|
9540
9540
|
]
|
|
9541
9541
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.22.2
|
|
3
|
+
"version": "2.22.2",
|
|
4
4
|
"description": "A draft order plugin for Medusa.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,38 +48,39 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@ariakit/react": "^0.4.15",
|
|
51
|
-
"@babel/runtime": "^7.
|
|
52
|
-
"@hookform/resolvers": "
|
|
53
|
-
"@medusajs/js-sdk": "2.22.2
|
|
51
|
+
"@babel/runtime": "^7.29.10",
|
|
52
|
+
"@hookform/resolvers": "6.0.0",
|
|
53
|
+
"@medusajs/js-sdk": "2.22.2",
|
|
54
54
|
"@tanstack/react-query": "5.64.2",
|
|
55
55
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
56
|
-
"date-fns": "^
|
|
56
|
+
"date-fns": "^4.4.0",
|
|
57
57
|
"lodash.debounce": "^4.0.8",
|
|
58
58
|
"lodash.isequal": "^4.5.0",
|
|
59
|
-
"match-sorter": "^
|
|
59
|
+
"match-sorter": "^8.3.0",
|
|
60
60
|
"radix-ui": "1.1.2",
|
|
61
61
|
"react-hook-form": "7.83.0",
|
|
62
62
|
"zod": "4.6.6"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@medusajs/admin-sdk": "2.22.2
|
|
66
|
-
"@medusajs/cli": "2.22.2
|
|
67
|
-
"@medusajs/dashboard": "2.22.2
|
|
68
|
-
"@medusajs/framework": "2.22.2
|
|
69
|
-
"@medusajs/icons": "2.22.2
|
|
70
|
-
"@medusajs/test-utils": "2.22.2
|
|
71
|
-
"@medusajs/types": "2.22.2
|
|
72
|
-
"@medusajs/ui": "4.2.9
|
|
73
|
-
"@medusajs/ui-preset": "2.22.2
|
|
65
|
+
"@medusajs/admin-sdk": "2.22.2",
|
|
66
|
+
"@medusajs/cli": "2.22.2",
|
|
67
|
+
"@medusajs/dashboard": "2.22.2",
|
|
68
|
+
"@medusajs/framework": "2.22.2",
|
|
69
|
+
"@medusajs/icons": "2.22.2",
|
|
70
|
+
"@medusajs/test-utils": "2.22.2",
|
|
71
|
+
"@medusajs/types": "2.22.2",
|
|
72
|
+
"@medusajs/ui": "4.2.9",
|
|
73
|
+
"@medusajs/ui-preset": "2.22.2",
|
|
74
|
+
"cross-env": "^10.1.0"
|
|
74
75
|
},
|
|
75
76
|
"peerDependencies": {
|
|
76
|
-
"@medusajs/admin-sdk": "2.22.2
|
|
77
|
-
"@medusajs/cli": "2.22.2
|
|
78
|
-
"@medusajs/dashboard": "2.22.2
|
|
79
|
-
"@medusajs/framework": "2.22.2
|
|
80
|
-
"@medusajs/icons": "2.22.2
|
|
81
|
-
"@medusajs/test-utils": "2.22.2
|
|
82
|
-
"@medusajs/ui": "4.2.9
|
|
77
|
+
"@medusajs/admin-sdk": "2.22.2",
|
|
78
|
+
"@medusajs/cli": "2.22.2",
|
|
79
|
+
"@medusajs/dashboard": "2.22.2",
|
|
80
|
+
"@medusajs/framework": "2.22.2",
|
|
81
|
+
"@medusajs/icons": "2.22.2",
|
|
82
|
+
"@medusajs/test-utils": "2.22.2",
|
|
83
|
+
"@medusajs/ui": "4.2.9",
|
|
83
84
|
"react": "^18.3.1",
|
|
84
85
|
"react-dom": "^18.3.1",
|
|
85
86
|
"react-router-dom": "^6.30.4 || ^7.0.0"
|