@medusajs/draft-order 2.21.2-snapshot-20260928075521 → 2.21.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 +112 -112
- package/.medusa/server/src/admin/index.mjs +112 -112
- package/package.json +18 -18
|
@@ -8897,6 +8897,112 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
8897
8897
|
) });
|
|
8898
8898
|
};
|
|
8899
8899
|
const schema$2 = addressSchema;
|
|
8900
|
+
const SalesChannel = () => {
|
|
8901
|
+
const { id } = reactRouterDom.useParams();
|
|
8902
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
8903
|
+
id,
|
|
8904
|
+
{
|
|
8905
|
+
fields: "+sales_channel_id"
|
|
8906
|
+
},
|
|
8907
|
+
{
|
|
8908
|
+
enabled: !!id
|
|
8909
|
+
}
|
|
8910
|
+
);
|
|
8911
|
+
if (isError) {
|
|
8912
|
+
throw error;
|
|
8913
|
+
}
|
|
8914
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
8915
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
8916
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
8917
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
8918
|
+
/* @__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" }) })
|
|
8919
|
+
] }),
|
|
8920
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
8921
|
+
] });
|
|
8922
|
+
};
|
|
8923
|
+
const SalesChannelForm = ({ order }) => {
|
|
8924
|
+
const form = reactHookForm.useForm({
|
|
8925
|
+
defaultValues: {
|
|
8926
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
8927
|
+
},
|
|
8928
|
+
resolver: zod$1.zodResolver(schema$1)
|
|
8929
|
+
});
|
|
8930
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8931
|
+
const { handleSuccess } = useRouteModal();
|
|
8932
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
8933
|
+
await mutateAsync(
|
|
8934
|
+
{
|
|
8935
|
+
sales_channel_id: data.sales_channel_id
|
|
8936
|
+
},
|
|
8937
|
+
{
|
|
8938
|
+
onSuccess: () => {
|
|
8939
|
+
ui.toast.success("Sales channel updated");
|
|
8940
|
+
handleSuccess();
|
|
8941
|
+
},
|
|
8942
|
+
onError: (error) => {
|
|
8943
|
+
ui.toast.error(error.message);
|
|
8944
|
+
}
|
|
8945
|
+
}
|
|
8946
|
+
);
|
|
8947
|
+
});
|
|
8948
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8949
|
+
KeyboundForm,
|
|
8950
|
+
{
|
|
8951
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
8952
|
+
onSubmit,
|
|
8953
|
+
children: [
|
|
8954
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
8955
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
8956
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
8957
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
8958
|
+
] }) })
|
|
8959
|
+
]
|
|
8960
|
+
}
|
|
8961
|
+
) });
|
|
8962
|
+
};
|
|
8963
|
+
const SalesChannelField = ({ control, order }) => {
|
|
8964
|
+
const salesChannels = useComboboxData({
|
|
8965
|
+
queryFn: async (params) => {
|
|
8966
|
+
return await sdk.admin.salesChannel.list(params);
|
|
8967
|
+
},
|
|
8968
|
+
queryKey: ["sales-channels"],
|
|
8969
|
+
getOptions: (data) => {
|
|
8970
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
8971
|
+
label: salesChannel.name,
|
|
8972
|
+
value: salesChannel.id
|
|
8973
|
+
}));
|
|
8974
|
+
},
|
|
8975
|
+
defaultValue: order.sales_channel_id || void 0
|
|
8976
|
+
});
|
|
8977
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8978
|
+
Form$2.Field,
|
|
8979
|
+
{
|
|
8980
|
+
control,
|
|
8981
|
+
name: "sales_channel_id",
|
|
8982
|
+
render: ({ field }) => {
|
|
8983
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8984
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
8985
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8986
|
+
Combobox,
|
|
8987
|
+
{
|
|
8988
|
+
options: salesChannels.options,
|
|
8989
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
8990
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
8991
|
+
searchValue: salesChannels.searchValue,
|
|
8992
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
8993
|
+
placeholder: "Select sales channel",
|
|
8994
|
+
...field
|
|
8995
|
+
}
|
|
8996
|
+
) }),
|
|
8997
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8998
|
+
] });
|
|
8999
|
+
}
|
|
9000
|
+
}
|
|
9001
|
+
);
|
|
9002
|
+
};
|
|
9003
|
+
const schema$1 = zod.z.object({
|
|
9004
|
+
sales_channel_id: zod.z.string().min(1)
|
|
9005
|
+
});
|
|
8900
9006
|
const TransferOwnership = () => {
|
|
8901
9007
|
const { id } = reactRouterDom.useParams();
|
|
8902
9008
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -8919,7 +9025,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
8919
9025
|
defaultValues: {
|
|
8920
9026
|
customer_id: order.customer_id || ""
|
|
8921
9027
|
},
|
|
8922
|
-
resolver: zod$1.zodResolver(schema
|
|
9028
|
+
resolver: zod$1.zodResolver(schema)
|
|
8923
9029
|
});
|
|
8924
9030
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8925
9031
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9369,114 +9475,8 @@ const Illustration = () => {
|
|
|
9369
9475
|
}
|
|
9370
9476
|
);
|
|
9371
9477
|
};
|
|
9372
|
-
const schema$1 = zod.z.object({
|
|
9373
|
-
customer_id: zod.z.string().min(1)
|
|
9374
|
-
});
|
|
9375
|
-
const SalesChannel = () => {
|
|
9376
|
-
const { id } = reactRouterDom.useParams();
|
|
9377
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
9378
|
-
id,
|
|
9379
|
-
{
|
|
9380
|
-
fields: "+sales_channel_id"
|
|
9381
|
-
},
|
|
9382
|
-
{
|
|
9383
|
-
enabled: !!id
|
|
9384
|
-
}
|
|
9385
|
-
);
|
|
9386
|
-
if (isError) {
|
|
9387
|
-
throw error;
|
|
9388
|
-
}
|
|
9389
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
9390
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9391
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9392
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
9393
|
-
/* @__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" }) })
|
|
9394
|
-
] }),
|
|
9395
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
9396
|
-
] });
|
|
9397
|
-
};
|
|
9398
|
-
const SalesChannelForm = ({ order }) => {
|
|
9399
|
-
const form = reactHookForm.useForm({
|
|
9400
|
-
defaultValues: {
|
|
9401
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
9402
|
-
},
|
|
9403
|
-
resolver: zod$1.zodResolver(schema)
|
|
9404
|
-
});
|
|
9405
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9406
|
-
const { handleSuccess } = useRouteModal();
|
|
9407
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9408
|
-
await mutateAsync(
|
|
9409
|
-
{
|
|
9410
|
-
sales_channel_id: data.sales_channel_id
|
|
9411
|
-
},
|
|
9412
|
-
{
|
|
9413
|
-
onSuccess: () => {
|
|
9414
|
-
ui.toast.success("Sales channel updated");
|
|
9415
|
-
handleSuccess();
|
|
9416
|
-
},
|
|
9417
|
-
onError: (error) => {
|
|
9418
|
-
ui.toast.error(error.message);
|
|
9419
|
-
}
|
|
9420
|
-
}
|
|
9421
|
-
);
|
|
9422
|
-
});
|
|
9423
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9424
|
-
KeyboundForm,
|
|
9425
|
-
{
|
|
9426
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9427
|
-
onSubmit,
|
|
9428
|
-
children: [
|
|
9429
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
9430
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9431
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9432
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9433
|
-
] }) })
|
|
9434
|
-
]
|
|
9435
|
-
}
|
|
9436
|
-
) });
|
|
9437
|
-
};
|
|
9438
|
-
const SalesChannelField = ({ control, order }) => {
|
|
9439
|
-
const salesChannels = useComboboxData({
|
|
9440
|
-
queryFn: async (params) => {
|
|
9441
|
-
return await sdk.admin.salesChannel.list(params);
|
|
9442
|
-
},
|
|
9443
|
-
queryKey: ["sales-channels"],
|
|
9444
|
-
getOptions: (data) => {
|
|
9445
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
9446
|
-
label: salesChannel.name,
|
|
9447
|
-
value: salesChannel.id
|
|
9448
|
-
}));
|
|
9449
|
-
},
|
|
9450
|
-
defaultValue: order.sales_channel_id || void 0
|
|
9451
|
-
});
|
|
9452
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9453
|
-
Form$2.Field,
|
|
9454
|
-
{
|
|
9455
|
-
control,
|
|
9456
|
-
name: "sales_channel_id",
|
|
9457
|
-
render: ({ field }) => {
|
|
9458
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9459
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
9460
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9461
|
-
Combobox,
|
|
9462
|
-
{
|
|
9463
|
-
options: salesChannels.options,
|
|
9464
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
9465
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
9466
|
-
searchValue: salesChannels.searchValue,
|
|
9467
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
9468
|
-
placeholder: "Select sales channel",
|
|
9469
|
-
...field
|
|
9470
|
-
}
|
|
9471
|
-
) }),
|
|
9472
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9473
|
-
] });
|
|
9474
|
-
}
|
|
9475
|
-
}
|
|
9476
|
-
);
|
|
9477
|
-
};
|
|
9478
9478
|
const schema = zod.z.object({
|
|
9479
|
-
|
|
9479
|
+
customer_id: zod.z.string().min(1)
|
|
9480
9480
|
});
|
|
9481
9481
|
const widgetModule = { widgets: [] };
|
|
9482
9482
|
const routeModule = {
|
|
@@ -9530,13 +9530,13 @@ const routeModule = {
|
|
|
9530
9530
|
Component: ShippingAddress,
|
|
9531
9531
|
path: "/draft-orders/:id/shipping-address"
|
|
9532
9532
|
},
|
|
9533
|
-
{
|
|
9534
|
-
Component: TransferOwnership,
|
|
9535
|
-
path: "/draft-orders/:id/transfer-ownership"
|
|
9536
|
-
},
|
|
9537
9533
|
{
|
|
9538
9534
|
Component: SalesChannel,
|
|
9539
9535
|
path: "/draft-orders/:id/sales-channel"
|
|
9536
|
+
},
|
|
9537
|
+
{
|
|
9538
|
+
Component: TransferOwnership,
|
|
9539
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
9540
9540
|
}
|
|
9541
9541
|
]
|
|
9542
9542
|
}
|
|
@@ -8890,6 +8890,112 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
8890
8890
|
) });
|
|
8891
8891
|
};
|
|
8892
8892
|
const schema$2 = addressSchema;
|
|
8893
|
+
const SalesChannel = () => {
|
|
8894
|
+
const { id } = useParams();
|
|
8895
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
8896
|
+
id,
|
|
8897
|
+
{
|
|
8898
|
+
fields: "+sales_channel_id"
|
|
8899
|
+
},
|
|
8900
|
+
{
|
|
8901
|
+
enabled: !!id
|
|
8902
|
+
}
|
|
8903
|
+
);
|
|
8904
|
+
if (isError) {
|
|
8905
|
+
throw error;
|
|
8906
|
+
}
|
|
8907
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
8908
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
8909
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
8910
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
8911
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
8912
|
+
] }),
|
|
8913
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
8914
|
+
] });
|
|
8915
|
+
};
|
|
8916
|
+
const SalesChannelForm = ({ order }) => {
|
|
8917
|
+
const form = useForm({
|
|
8918
|
+
defaultValues: {
|
|
8919
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
8920
|
+
},
|
|
8921
|
+
resolver: zodResolver(schema$1)
|
|
8922
|
+
});
|
|
8923
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8924
|
+
const { handleSuccess } = useRouteModal();
|
|
8925
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
8926
|
+
await mutateAsync(
|
|
8927
|
+
{
|
|
8928
|
+
sales_channel_id: data.sales_channel_id
|
|
8929
|
+
},
|
|
8930
|
+
{
|
|
8931
|
+
onSuccess: () => {
|
|
8932
|
+
toast.success("Sales channel updated");
|
|
8933
|
+
handleSuccess();
|
|
8934
|
+
},
|
|
8935
|
+
onError: (error) => {
|
|
8936
|
+
toast.error(error.message);
|
|
8937
|
+
}
|
|
8938
|
+
}
|
|
8939
|
+
);
|
|
8940
|
+
});
|
|
8941
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
8942
|
+
KeyboundForm,
|
|
8943
|
+
{
|
|
8944
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
8945
|
+
onSubmit,
|
|
8946
|
+
children: [
|
|
8947
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
8948
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
8949
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
8950
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
8951
|
+
] }) })
|
|
8952
|
+
]
|
|
8953
|
+
}
|
|
8954
|
+
) });
|
|
8955
|
+
};
|
|
8956
|
+
const SalesChannelField = ({ control, order }) => {
|
|
8957
|
+
const salesChannels = useComboboxData({
|
|
8958
|
+
queryFn: async (params) => {
|
|
8959
|
+
return await sdk.admin.salesChannel.list(params);
|
|
8960
|
+
},
|
|
8961
|
+
queryKey: ["sales-channels"],
|
|
8962
|
+
getOptions: (data) => {
|
|
8963
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
8964
|
+
label: salesChannel.name,
|
|
8965
|
+
value: salesChannel.id
|
|
8966
|
+
}));
|
|
8967
|
+
},
|
|
8968
|
+
defaultValue: order.sales_channel_id || void 0
|
|
8969
|
+
});
|
|
8970
|
+
return /* @__PURE__ */ jsx(
|
|
8971
|
+
Form$2.Field,
|
|
8972
|
+
{
|
|
8973
|
+
control,
|
|
8974
|
+
name: "sales_channel_id",
|
|
8975
|
+
render: ({ field }) => {
|
|
8976
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
8977
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
8978
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
8979
|
+
Combobox,
|
|
8980
|
+
{
|
|
8981
|
+
options: salesChannels.options,
|
|
8982
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
8983
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
8984
|
+
searchValue: salesChannels.searchValue,
|
|
8985
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
8986
|
+
placeholder: "Select sales channel",
|
|
8987
|
+
...field
|
|
8988
|
+
}
|
|
8989
|
+
) }),
|
|
8990
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
8991
|
+
] });
|
|
8992
|
+
}
|
|
8993
|
+
}
|
|
8994
|
+
);
|
|
8995
|
+
};
|
|
8996
|
+
const schema$1 = z.object({
|
|
8997
|
+
sales_channel_id: z.string().min(1)
|
|
8998
|
+
});
|
|
8893
8999
|
const TransferOwnership = () => {
|
|
8894
9000
|
const { id } = useParams();
|
|
8895
9001
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -8912,7 +9018,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
8912
9018
|
defaultValues: {
|
|
8913
9019
|
customer_id: order.customer_id || ""
|
|
8914
9020
|
},
|
|
8915
|
-
resolver: zodResolver(schema
|
|
9021
|
+
resolver: zodResolver(schema)
|
|
8916
9022
|
});
|
|
8917
9023
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8918
9024
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9362,114 +9468,8 @@ const Illustration = () => {
|
|
|
9362
9468
|
}
|
|
9363
9469
|
);
|
|
9364
9470
|
};
|
|
9365
|
-
const schema$1 = z.object({
|
|
9366
|
-
customer_id: z.string().min(1)
|
|
9367
|
-
});
|
|
9368
|
-
const SalesChannel = () => {
|
|
9369
|
-
const { id } = useParams();
|
|
9370
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
9371
|
-
id,
|
|
9372
|
-
{
|
|
9373
|
-
fields: "+sales_channel_id"
|
|
9374
|
-
},
|
|
9375
|
-
{
|
|
9376
|
-
enabled: !!id
|
|
9377
|
-
}
|
|
9378
|
-
);
|
|
9379
|
-
if (isError) {
|
|
9380
|
-
throw error;
|
|
9381
|
-
}
|
|
9382
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
9383
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9384
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9385
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
9386
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
9387
|
-
] }),
|
|
9388
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
9389
|
-
] });
|
|
9390
|
-
};
|
|
9391
|
-
const SalesChannelForm = ({ order }) => {
|
|
9392
|
-
const form = useForm({
|
|
9393
|
-
defaultValues: {
|
|
9394
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
9395
|
-
},
|
|
9396
|
-
resolver: zodResolver(schema)
|
|
9397
|
-
});
|
|
9398
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9399
|
-
const { handleSuccess } = useRouteModal();
|
|
9400
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9401
|
-
await mutateAsync(
|
|
9402
|
-
{
|
|
9403
|
-
sales_channel_id: data.sales_channel_id
|
|
9404
|
-
},
|
|
9405
|
-
{
|
|
9406
|
-
onSuccess: () => {
|
|
9407
|
-
toast.success("Sales channel updated");
|
|
9408
|
-
handleSuccess();
|
|
9409
|
-
},
|
|
9410
|
-
onError: (error) => {
|
|
9411
|
-
toast.error(error.message);
|
|
9412
|
-
}
|
|
9413
|
-
}
|
|
9414
|
-
);
|
|
9415
|
-
});
|
|
9416
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9417
|
-
KeyboundForm,
|
|
9418
|
-
{
|
|
9419
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9420
|
-
onSubmit,
|
|
9421
|
-
children: [
|
|
9422
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
9423
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9424
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9425
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9426
|
-
] }) })
|
|
9427
|
-
]
|
|
9428
|
-
}
|
|
9429
|
-
) });
|
|
9430
|
-
};
|
|
9431
|
-
const SalesChannelField = ({ control, order }) => {
|
|
9432
|
-
const salesChannels = useComboboxData({
|
|
9433
|
-
queryFn: async (params) => {
|
|
9434
|
-
return await sdk.admin.salesChannel.list(params);
|
|
9435
|
-
},
|
|
9436
|
-
queryKey: ["sales-channels"],
|
|
9437
|
-
getOptions: (data) => {
|
|
9438
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
9439
|
-
label: salesChannel.name,
|
|
9440
|
-
value: salesChannel.id
|
|
9441
|
-
}));
|
|
9442
|
-
},
|
|
9443
|
-
defaultValue: order.sales_channel_id || void 0
|
|
9444
|
-
});
|
|
9445
|
-
return /* @__PURE__ */ jsx(
|
|
9446
|
-
Form$2.Field,
|
|
9447
|
-
{
|
|
9448
|
-
control,
|
|
9449
|
-
name: "sales_channel_id",
|
|
9450
|
-
render: ({ field }) => {
|
|
9451
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9452
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
9453
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
9454
|
-
Combobox,
|
|
9455
|
-
{
|
|
9456
|
-
options: salesChannels.options,
|
|
9457
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
9458
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
9459
|
-
searchValue: salesChannels.searchValue,
|
|
9460
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
9461
|
-
placeholder: "Select sales channel",
|
|
9462
|
-
...field
|
|
9463
|
-
}
|
|
9464
|
-
) }),
|
|
9465
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9466
|
-
] });
|
|
9467
|
-
}
|
|
9468
|
-
}
|
|
9469
|
-
);
|
|
9470
|
-
};
|
|
9471
9471
|
const schema = z.object({
|
|
9472
|
-
|
|
9472
|
+
customer_id: z.string().min(1)
|
|
9473
9473
|
});
|
|
9474
9474
|
const widgetModule = { widgets: [] };
|
|
9475
9475
|
const routeModule = {
|
|
@@ -9523,13 +9523,13 @@ const routeModule = {
|
|
|
9523
9523
|
Component: ShippingAddress,
|
|
9524
9524
|
path: "/draft-orders/:id/shipping-address"
|
|
9525
9525
|
},
|
|
9526
|
-
{
|
|
9527
|
-
Component: TransferOwnership,
|
|
9528
|
-
path: "/draft-orders/:id/transfer-ownership"
|
|
9529
|
-
},
|
|
9530
9526
|
{
|
|
9531
9527
|
Component: SalesChannel,
|
|
9532
9528
|
path: "/draft-orders/:id/sales-channel"
|
|
9529
|
+
},
|
|
9530
|
+
{
|
|
9531
|
+
Component: TransferOwnership,
|
|
9532
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
9533
9533
|
}
|
|
9534
9534
|
]
|
|
9535
9535
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.21.2
|
|
3
|
+
"version": "2.21.2",
|
|
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.2
|
|
49
|
+
"@medusajs/js-sdk": "2.21.2",
|
|
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.2
|
|
62
|
-
"@medusajs/cli": "2.21.2
|
|
63
|
-
"@medusajs/dashboard": "2.21.2
|
|
64
|
-
"@medusajs/framework": "2.21.2
|
|
65
|
-
"@medusajs/icons": "2.21.2
|
|
66
|
-
"@medusajs/test-utils": "2.21.2
|
|
67
|
-
"@medusajs/types": "2.21.2
|
|
68
|
-
"@medusajs/ui": "4.2.6
|
|
69
|
-
"@medusajs/ui-preset": "2.21.2
|
|
61
|
+
"@medusajs/admin-sdk": "2.21.2",
|
|
62
|
+
"@medusajs/cli": "2.21.2",
|
|
63
|
+
"@medusajs/dashboard": "2.21.2",
|
|
64
|
+
"@medusajs/framework": "2.21.2",
|
|
65
|
+
"@medusajs/icons": "2.21.2",
|
|
66
|
+
"@medusajs/test-utils": "2.21.2",
|
|
67
|
+
"@medusajs/types": "2.21.2",
|
|
68
|
+
"@medusajs/ui": "4.2.6",
|
|
69
|
+
"@medusajs/ui-preset": "2.21.2"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@medusajs/admin-sdk": "2.21.2
|
|
73
|
-
"@medusajs/cli": "2.21.2
|
|
74
|
-
"@medusajs/dashboard": "2.21.2
|
|
75
|
-
"@medusajs/framework": "2.21.2
|
|
76
|
-
"@medusajs/icons": "2.21.2
|
|
77
|
-
"@medusajs/test-utils": "2.21.2
|
|
78
|
-
"@medusajs/ui": "4.2.6
|
|
72
|
+
"@medusajs/admin-sdk": "2.21.2",
|
|
73
|
+
"@medusajs/cli": "2.21.2",
|
|
74
|
+
"@medusajs/dashboard": "2.21.2",
|
|
75
|
+
"@medusajs/framework": "2.21.2",
|
|
76
|
+
"@medusajs/icons": "2.21.2",
|
|
77
|
+
"@medusajs/test-utils": "2.21.2",
|
|
78
|
+
"@medusajs/ui": "4.2.6",
|
|
79
79
|
"react": "^18.3.1",
|
|
80
80
|
"react-dom": "^18.3.1",
|
|
81
81
|
"react-router-dom": "^6.30.4 || ^7.0.0"
|