@medusajs/draft-order 2.21.1-preview-20260922093132 → 2.21.1
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 +110 -110
- package/.medusa/server/src/admin/index.mjs +110 -110
- package/package.json +18 -18
|
@@ -7626,112 +7626,6 @@ function getHasUneditableRows(metadata) {
|
|
|
7626
7626
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
7627
7627
|
);
|
|
7628
7628
|
}
|
|
7629
|
-
const SalesChannel = () => {
|
|
7630
|
-
const { id } = reactRouterDom.useParams();
|
|
7631
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
7632
|
-
id,
|
|
7633
|
-
{
|
|
7634
|
-
fields: "+sales_channel_id"
|
|
7635
|
-
},
|
|
7636
|
-
{
|
|
7637
|
-
enabled: !!id
|
|
7638
|
-
}
|
|
7639
|
-
);
|
|
7640
|
-
if (isError) {
|
|
7641
|
-
throw error;
|
|
7642
|
-
}
|
|
7643
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
7644
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
7645
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
7646
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
7647
|
-
/* @__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" }) })
|
|
7648
|
-
] }),
|
|
7649
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
7650
|
-
] });
|
|
7651
|
-
};
|
|
7652
|
-
const SalesChannelForm = ({ order }) => {
|
|
7653
|
-
const form = reactHookForm.useForm({
|
|
7654
|
-
defaultValues: {
|
|
7655
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
7656
|
-
},
|
|
7657
|
-
resolver: zod$1.zodResolver(schema$2)
|
|
7658
|
-
});
|
|
7659
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7660
|
-
const { handleSuccess } = useRouteModal();
|
|
7661
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
7662
|
-
await mutateAsync(
|
|
7663
|
-
{
|
|
7664
|
-
sales_channel_id: data.sales_channel_id
|
|
7665
|
-
},
|
|
7666
|
-
{
|
|
7667
|
-
onSuccess: () => {
|
|
7668
|
-
ui.toast.success("Sales channel updated");
|
|
7669
|
-
handleSuccess();
|
|
7670
|
-
},
|
|
7671
|
-
onError: (error) => {
|
|
7672
|
-
ui.toast.error(error.message);
|
|
7673
|
-
}
|
|
7674
|
-
}
|
|
7675
|
-
);
|
|
7676
|
-
});
|
|
7677
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7678
|
-
KeyboundForm,
|
|
7679
|
-
{
|
|
7680
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
7681
|
-
onSubmit,
|
|
7682
|
-
children: [
|
|
7683
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
7684
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7685
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7686
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
7687
|
-
] }) })
|
|
7688
|
-
]
|
|
7689
|
-
}
|
|
7690
|
-
) });
|
|
7691
|
-
};
|
|
7692
|
-
const SalesChannelField = ({ control, order }) => {
|
|
7693
|
-
const salesChannels = useComboboxData({
|
|
7694
|
-
queryFn: async (params) => {
|
|
7695
|
-
return await sdk.admin.salesChannel.list(params);
|
|
7696
|
-
},
|
|
7697
|
-
queryKey: ["sales-channels"],
|
|
7698
|
-
getOptions: (data) => {
|
|
7699
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
7700
|
-
label: salesChannel.name,
|
|
7701
|
-
value: salesChannel.id
|
|
7702
|
-
}));
|
|
7703
|
-
},
|
|
7704
|
-
defaultValue: order.sales_channel_id || void 0
|
|
7705
|
-
});
|
|
7706
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7707
|
-
Form$2.Field,
|
|
7708
|
-
{
|
|
7709
|
-
control,
|
|
7710
|
-
name: "sales_channel_id",
|
|
7711
|
-
render: ({ field }) => {
|
|
7712
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7713
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
7714
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7715
|
-
Combobox,
|
|
7716
|
-
{
|
|
7717
|
-
options: salesChannels.options,
|
|
7718
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
7719
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
7720
|
-
searchValue: salesChannels.searchValue,
|
|
7721
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
7722
|
-
placeholder: "Select sales channel",
|
|
7723
|
-
...field
|
|
7724
|
-
}
|
|
7725
|
-
) }),
|
|
7726
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7727
|
-
] });
|
|
7728
|
-
}
|
|
7729
|
-
}
|
|
7730
|
-
);
|
|
7731
|
-
};
|
|
7732
|
-
const schema$2 = zod.z.object({
|
|
7733
|
-
sales_channel_id: zod.z.string().min(1)
|
|
7734
|
-
});
|
|
7735
7629
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
7736
7630
|
const promotionsQueryKeys = {
|
|
7737
7631
|
list: (query2) => [
|
|
@@ -8007,6 +7901,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
8007
7901
|
}
|
|
8008
7902
|
return Array.from(promotionIds);
|
|
8009
7903
|
}
|
|
7904
|
+
const SalesChannel = () => {
|
|
7905
|
+
const { id } = reactRouterDom.useParams();
|
|
7906
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
7907
|
+
id,
|
|
7908
|
+
{
|
|
7909
|
+
fields: "+sales_channel_id"
|
|
7910
|
+
},
|
|
7911
|
+
{
|
|
7912
|
+
enabled: !!id
|
|
7913
|
+
}
|
|
7914
|
+
);
|
|
7915
|
+
if (isError) {
|
|
7916
|
+
throw error;
|
|
7917
|
+
}
|
|
7918
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
7919
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
7920
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
7921
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
7922
|
+
/* @__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" }) })
|
|
7923
|
+
] }),
|
|
7924
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
7925
|
+
] });
|
|
7926
|
+
};
|
|
7927
|
+
const SalesChannelForm = ({ order }) => {
|
|
7928
|
+
const form = reactHookForm.useForm({
|
|
7929
|
+
defaultValues: {
|
|
7930
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
7931
|
+
},
|
|
7932
|
+
resolver: zod$1.zodResolver(schema$2)
|
|
7933
|
+
});
|
|
7934
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7935
|
+
const { handleSuccess } = useRouteModal();
|
|
7936
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
7937
|
+
await mutateAsync(
|
|
7938
|
+
{
|
|
7939
|
+
sales_channel_id: data.sales_channel_id
|
|
7940
|
+
},
|
|
7941
|
+
{
|
|
7942
|
+
onSuccess: () => {
|
|
7943
|
+
ui.toast.success("Sales channel updated");
|
|
7944
|
+
handleSuccess();
|
|
7945
|
+
},
|
|
7946
|
+
onError: (error) => {
|
|
7947
|
+
ui.toast.error(error.message);
|
|
7948
|
+
}
|
|
7949
|
+
}
|
|
7950
|
+
);
|
|
7951
|
+
});
|
|
7952
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7953
|
+
KeyboundForm,
|
|
7954
|
+
{
|
|
7955
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
7956
|
+
onSubmit,
|
|
7957
|
+
children: [
|
|
7958
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
7959
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7960
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7961
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
7962
|
+
] }) })
|
|
7963
|
+
]
|
|
7964
|
+
}
|
|
7965
|
+
) });
|
|
7966
|
+
};
|
|
7967
|
+
const SalesChannelField = ({ control, order }) => {
|
|
7968
|
+
const salesChannels = useComboboxData({
|
|
7969
|
+
queryFn: async (params) => {
|
|
7970
|
+
return await sdk.admin.salesChannel.list(params);
|
|
7971
|
+
},
|
|
7972
|
+
queryKey: ["sales-channels"],
|
|
7973
|
+
getOptions: (data) => {
|
|
7974
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
7975
|
+
label: salesChannel.name,
|
|
7976
|
+
value: salesChannel.id
|
|
7977
|
+
}));
|
|
7978
|
+
},
|
|
7979
|
+
defaultValue: order.sales_channel_id || void 0
|
|
7980
|
+
});
|
|
7981
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7982
|
+
Form$2.Field,
|
|
7983
|
+
{
|
|
7984
|
+
control,
|
|
7985
|
+
name: "sales_channel_id",
|
|
7986
|
+
render: ({ field }) => {
|
|
7987
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7988
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
7989
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7990
|
+
Combobox,
|
|
7991
|
+
{
|
|
7992
|
+
options: salesChannels.options,
|
|
7993
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
7994
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
7995
|
+
searchValue: salesChannels.searchValue,
|
|
7996
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
7997
|
+
placeholder: "Select sales channel",
|
|
7998
|
+
...field
|
|
7999
|
+
}
|
|
8000
|
+
) }),
|
|
8001
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8002
|
+
] });
|
|
8003
|
+
}
|
|
8004
|
+
}
|
|
8005
|
+
);
|
|
8006
|
+
};
|
|
8007
|
+
const schema$2 = zod.z.object({
|
|
8008
|
+
sales_channel_id: zod.z.string().min(1)
|
|
8009
|
+
});
|
|
8010
8010
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
8011
8011
|
const Shipping = () => {
|
|
8012
8012
|
const { id } = reactRouterDom.useParams();
|
|
@@ -9518,14 +9518,14 @@ const routeModule = {
|
|
|
9518
9518
|
Component: Metadata,
|
|
9519
9519
|
path: "/draft-orders/:id/metadata"
|
|
9520
9520
|
},
|
|
9521
|
-
{
|
|
9522
|
-
Component: SalesChannel,
|
|
9523
|
-
path: "/draft-orders/:id/sales-channel"
|
|
9524
|
-
},
|
|
9525
9521
|
{
|
|
9526
9522
|
Component: Promotions,
|
|
9527
9523
|
path: "/draft-orders/:id/promotions"
|
|
9528
9524
|
},
|
|
9525
|
+
{
|
|
9526
|
+
Component: SalesChannel,
|
|
9527
|
+
path: "/draft-orders/:id/sales-channel"
|
|
9528
|
+
},
|
|
9529
9529
|
{
|
|
9530
9530
|
Component: Shipping,
|
|
9531
9531
|
path: "/draft-orders/:id/shipping"
|
|
@@ -7619,112 +7619,6 @@ function getHasUneditableRows(metadata) {
|
|
|
7619
7619
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
7620
7620
|
);
|
|
7621
7621
|
}
|
|
7622
|
-
const SalesChannel = () => {
|
|
7623
|
-
const { id } = useParams();
|
|
7624
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
7625
|
-
id,
|
|
7626
|
-
{
|
|
7627
|
-
fields: "+sales_channel_id"
|
|
7628
|
-
},
|
|
7629
|
-
{
|
|
7630
|
-
enabled: !!id
|
|
7631
|
-
}
|
|
7632
|
-
);
|
|
7633
|
-
if (isError) {
|
|
7634
|
-
throw error;
|
|
7635
|
-
}
|
|
7636
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
7637
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
7638
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
7639
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
7640
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
7641
|
-
] }),
|
|
7642
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
7643
|
-
] });
|
|
7644
|
-
};
|
|
7645
|
-
const SalesChannelForm = ({ order }) => {
|
|
7646
|
-
const form = useForm({
|
|
7647
|
-
defaultValues: {
|
|
7648
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
7649
|
-
},
|
|
7650
|
-
resolver: zodResolver(schema$2)
|
|
7651
|
-
});
|
|
7652
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7653
|
-
const { handleSuccess } = useRouteModal();
|
|
7654
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
7655
|
-
await mutateAsync(
|
|
7656
|
-
{
|
|
7657
|
-
sales_channel_id: data.sales_channel_id
|
|
7658
|
-
},
|
|
7659
|
-
{
|
|
7660
|
-
onSuccess: () => {
|
|
7661
|
-
toast.success("Sales channel updated");
|
|
7662
|
-
handleSuccess();
|
|
7663
|
-
},
|
|
7664
|
-
onError: (error) => {
|
|
7665
|
-
toast.error(error.message);
|
|
7666
|
-
}
|
|
7667
|
-
}
|
|
7668
|
-
);
|
|
7669
|
-
});
|
|
7670
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
7671
|
-
KeyboundForm,
|
|
7672
|
-
{
|
|
7673
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
7674
|
-
onSubmit,
|
|
7675
|
-
children: [
|
|
7676
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
7677
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7678
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7679
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
7680
|
-
] }) })
|
|
7681
|
-
]
|
|
7682
|
-
}
|
|
7683
|
-
) });
|
|
7684
|
-
};
|
|
7685
|
-
const SalesChannelField = ({ control, order }) => {
|
|
7686
|
-
const salesChannels = useComboboxData({
|
|
7687
|
-
queryFn: async (params) => {
|
|
7688
|
-
return await sdk.admin.salesChannel.list(params);
|
|
7689
|
-
},
|
|
7690
|
-
queryKey: ["sales-channels"],
|
|
7691
|
-
getOptions: (data) => {
|
|
7692
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
7693
|
-
label: salesChannel.name,
|
|
7694
|
-
value: salesChannel.id
|
|
7695
|
-
}));
|
|
7696
|
-
},
|
|
7697
|
-
defaultValue: order.sales_channel_id || void 0
|
|
7698
|
-
});
|
|
7699
|
-
return /* @__PURE__ */ jsx(
|
|
7700
|
-
Form$2.Field,
|
|
7701
|
-
{
|
|
7702
|
-
control,
|
|
7703
|
-
name: "sales_channel_id",
|
|
7704
|
-
render: ({ field }) => {
|
|
7705
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
7706
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
7707
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
7708
|
-
Combobox,
|
|
7709
|
-
{
|
|
7710
|
-
options: salesChannels.options,
|
|
7711
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
7712
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
7713
|
-
searchValue: salesChannels.searchValue,
|
|
7714
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
7715
|
-
placeholder: "Select sales channel",
|
|
7716
|
-
...field
|
|
7717
|
-
}
|
|
7718
|
-
) }),
|
|
7719
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
7720
|
-
] });
|
|
7721
|
-
}
|
|
7722
|
-
}
|
|
7723
|
-
);
|
|
7724
|
-
};
|
|
7725
|
-
const schema$2 = z.object({
|
|
7726
|
-
sales_channel_id: z.string().min(1)
|
|
7727
|
-
});
|
|
7728
7622
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
7729
7623
|
const promotionsQueryKeys = {
|
|
7730
7624
|
list: (query2) => [
|
|
@@ -8000,6 +7894,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
8000
7894
|
}
|
|
8001
7895
|
return Array.from(promotionIds);
|
|
8002
7896
|
}
|
|
7897
|
+
const SalesChannel = () => {
|
|
7898
|
+
const { id } = useParams();
|
|
7899
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
7900
|
+
id,
|
|
7901
|
+
{
|
|
7902
|
+
fields: "+sales_channel_id"
|
|
7903
|
+
},
|
|
7904
|
+
{
|
|
7905
|
+
enabled: !!id
|
|
7906
|
+
}
|
|
7907
|
+
);
|
|
7908
|
+
if (isError) {
|
|
7909
|
+
throw error;
|
|
7910
|
+
}
|
|
7911
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
7912
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
7913
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
7914
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
7915
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
7916
|
+
] }),
|
|
7917
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
7918
|
+
] });
|
|
7919
|
+
};
|
|
7920
|
+
const SalesChannelForm = ({ order }) => {
|
|
7921
|
+
const form = useForm({
|
|
7922
|
+
defaultValues: {
|
|
7923
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
7924
|
+
},
|
|
7925
|
+
resolver: zodResolver(schema$2)
|
|
7926
|
+
});
|
|
7927
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7928
|
+
const { handleSuccess } = useRouteModal();
|
|
7929
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
7930
|
+
await mutateAsync(
|
|
7931
|
+
{
|
|
7932
|
+
sales_channel_id: data.sales_channel_id
|
|
7933
|
+
},
|
|
7934
|
+
{
|
|
7935
|
+
onSuccess: () => {
|
|
7936
|
+
toast.success("Sales channel updated");
|
|
7937
|
+
handleSuccess();
|
|
7938
|
+
},
|
|
7939
|
+
onError: (error) => {
|
|
7940
|
+
toast.error(error.message);
|
|
7941
|
+
}
|
|
7942
|
+
}
|
|
7943
|
+
);
|
|
7944
|
+
});
|
|
7945
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
7946
|
+
KeyboundForm,
|
|
7947
|
+
{
|
|
7948
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
7949
|
+
onSubmit,
|
|
7950
|
+
children: [
|
|
7951
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
7952
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7953
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7954
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
7955
|
+
] }) })
|
|
7956
|
+
]
|
|
7957
|
+
}
|
|
7958
|
+
) });
|
|
7959
|
+
};
|
|
7960
|
+
const SalesChannelField = ({ control, order }) => {
|
|
7961
|
+
const salesChannels = useComboboxData({
|
|
7962
|
+
queryFn: async (params) => {
|
|
7963
|
+
return await sdk.admin.salesChannel.list(params);
|
|
7964
|
+
},
|
|
7965
|
+
queryKey: ["sales-channels"],
|
|
7966
|
+
getOptions: (data) => {
|
|
7967
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
7968
|
+
label: salesChannel.name,
|
|
7969
|
+
value: salesChannel.id
|
|
7970
|
+
}));
|
|
7971
|
+
},
|
|
7972
|
+
defaultValue: order.sales_channel_id || void 0
|
|
7973
|
+
});
|
|
7974
|
+
return /* @__PURE__ */ jsx(
|
|
7975
|
+
Form$2.Field,
|
|
7976
|
+
{
|
|
7977
|
+
control,
|
|
7978
|
+
name: "sales_channel_id",
|
|
7979
|
+
render: ({ field }) => {
|
|
7980
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
7981
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
7982
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
7983
|
+
Combobox,
|
|
7984
|
+
{
|
|
7985
|
+
options: salesChannels.options,
|
|
7986
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
7987
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
7988
|
+
searchValue: salesChannels.searchValue,
|
|
7989
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
7990
|
+
placeholder: "Select sales channel",
|
|
7991
|
+
...field
|
|
7992
|
+
}
|
|
7993
|
+
) }),
|
|
7994
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
7995
|
+
] });
|
|
7996
|
+
}
|
|
7997
|
+
}
|
|
7998
|
+
);
|
|
7999
|
+
};
|
|
8000
|
+
const schema$2 = z.object({
|
|
8001
|
+
sales_channel_id: z.string().min(1)
|
|
8002
|
+
});
|
|
8003
8003
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
8004
8004
|
const Shipping = () => {
|
|
8005
8005
|
const { id } = useParams();
|
|
@@ -9511,14 +9511,14 @@ const routeModule = {
|
|
|
9511
9511
|
Component: Metadata,
|
|
9512
9512
|
path: "/draft-orders/:id/metadata"
|
|
9513
9513
|
},
|
|
9514
|
-
{
|
|
9515
|
-
Component: SalesChannel,
|
|
9516
|
-
path: "/draft-orders/:id/sales-channel"
|
|
9517
|
-
},
|
|
9518
9514
|
{
|
|
9519
9515
|
Component: Promotions,
|
|
9520
9516
|
path: "/draft-orders/:id/promotions"
|
|
9521
9517
|
},
|
|
9518
|
+
{
|
|
9519
|
+
Component: SalesChannel,
|
|
9520
|
+
path: "/draft-orders/:id/sales-channel"
|
|
9521
|
+
},
|
|
9522
9522
|
{
|
|
9523
9523
|
Component: Shipping,
|
|
9524
9524
|
path: "/draft-orders/:id/shipping"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.21.1
|
|
3
|
+
"version": "2.21.1",
|
|
4
4
|
"description": "A draft order plugin for Medusa.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@ariakit/react": "^0.4.15",
|
|
47
47
|
"@babel/runtime": "^7.26.10",
|
|
48
48
|
"@hookform/resolvers": "5.5.7",
|
|
49
|
-
"@medusajs/js-sdk": "2.21.1
|
|
49
|
+
"@medusajs/js-sdk": "2.21.1",
|
|
50
50
|
"@tanstack/react-query": "5.64.2",
|
|
51
51
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
52
52
|
"date-fns": "^3.6.0",
|
|
@@ -58,24 +58,24 @@
|
|
|
58
58
|
"zod": "4.2.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@medusajs/admin-sdk": "2.21.1
|
|
62
|
-
"@medusajs/cli": "2.21.1
|
|
63
|
-
"@medusajs/dashboard": "2.21.1
|
|
64
|
-
"@medusajs/framework": "2.21.1
|
|
65
|
-
"@medusajs/icons": "2.21.1
|
|
66
|
-
"@medusajs/test-utils": "2.21.1
|
|
67
|
-
"@medusajs/types": "2.21.1
|
|
68
|
-
"@medusajs/ui": "4.2.5
|
|
69
|
-
"@medusajs/ui-preset": "2.21.1
|
|
61
|
+
"@medusajs/admin-sdk": "2.21.1",
|
|
62
|
+
"@medusajs/cli": "2.21.1",
|
|
63
|
+
"@medusajs/dashboard": "2.21.1",
|
|
64
|
+
"@medusajs/framework": "2.21.1",
|
|
65
|
+
"@medusajs/icons": "2.21.1",
|
|
66
|
+
"@medusajs/test-utils": "2.21.1",
|
|
67
|
+
"@medusajs/types": "2.21.1",
|
|
68
|
+
"@medusajs/ui": "4.2.5",
|
|
69
|
+
"@medusajs/ui-preset": "2.21.1"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@medusajs/admin-sdk": "2.21.1
|
|
73
|
-
"@medusajs/cli": "2.21.1
|
|
74
|
-
"@medusajs/dashboard": "2.21.1
|
|
75
|
-
"@medusajs/framework": "2.21.1
|
|
76
|
-
"@medusajs/icons": "2.21.1
|
|
77
|
-
"@medusajs/test-utils": "2.21.1
|
|
78
|
-
"@medusajs/ui": "4.2.5
|
|
72
|
+
"@medusajs/admin-sdk": "2.21.1",
|
|
73
|
+
"@medusajs/cli": "2.21.1",
|
|
74
|
+
"@medusajs/dashboard": "2.21.1",
|
|
75
|
+
"@medusajs/framework": "2.21.1",
|
|
76
|
+
"@medusajs/icons": "2.21.1",
|
|
77
|
+
"@medusajs/test-utils": "2.21.1",
|
|
78
|
+
"@medusajs/ui": "4.2.5",
|
|
79
79
|
"react": "^18.3.1",
|
|
80
80
|
"react-dom": "^18.3.1",
|
|
81
81
|
"react-router-dom": "^6.30.4 || ^7.0.0"
|