@medusajs/draft-order 2.11.4-preview-20251113120143 → 2.11.4-preview-20251113180136
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 +137 -137
- package/.medusa/server/src/admin/index.mjs +137 -137
- package/package.json +16 -16
|
@@ -9762,27 +9762,6 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9762
9762
|
) });
|
|
9763
9763
|
};
|
|
9764
9764
|
const schema$5 = addressSchema;
|
|
9765
|
-
const CustomItems = () => {
|
|
9766
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9767
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9768
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9769
|
-
] });
|
|
9770
|
-
};
|
|
9771
|
-
const CustomItemsForm = () => {
|
|
9772
|
-
const form = reactHookForm.useForm({
|
|
9773
|
-
resolver: zod.zodResolver(schema$4)
|
|
9774
|
-
});
|
|
9775
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9776
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9777
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9778
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9779
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9780
|
-
] }) })
|
|
9781
|
-
] }) });
|
|
9782
|
-
};
|
|
9783
|
-
const schema$4 = objectType({
|
|
9784
|
-
email: stringType().email()
|
|
9785
|
-
});
|
|
9786
9765
|
const Email = () => {
|
|
9787
9766
|
const { id } = reactRouterDom.useParams();
|
|
9788
9767
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9805,7 +9784,7 @@ const EmailForm = ({ order }) => {
|
|
|
9805
9784
|
defaultValues: {
|
|
9806
9785
|
email: order.email ?? ""
|
|
9807
9786
|
},
|
|
9808
|
-
resolver: zod.zodResolver(schema$
|
|
9787
|
+
resolver: zod.zodResolver(schema$4)
|
|
9809
9788
|
});
|
|
9810
9789
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9811
9790
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9848,7 +9827,7 @@ const EmailForm = ({ order }) => {
|
|
|
9848
9827
|
}
|
|
9849
9828
|
) });
|
|
9850
9829
|
};
|
|
9851
|
-
const schema$
|
|
9830
|
+
const schema$4 = objectType({
|
|
9852
9831
|
email: stringType().email()
|
|
9853
9832
|
});
|
|
9854
9833
|
const NumberInput = React.forwardRef(
|
|
@@ -11452,6 +11431,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11452
11431
|
}
|
|
11453
11432
|
return Array.from(promotionIds);
|
|
11454
11433
|
}
|
|
11434
|
+
const SalesChannel = () => {
|
|
11435
|
+
const { id } = reactRouterDom.useParams();
|
|
11436
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11437
|
+
id,
|
|
11438
|
+
{
|
|
11439
|
+
fields: "+sales_channel_id"
|
|
11440
|
+
},
|
|
11441
|
+
{
|
|
11442
|
+
enabled: !!id
|
|
11443
|
+
}
|
|
11444
|
+
);
|
|
11445
|
+
if (isError) {
|
|
11446
|
+
throw error;
|
|
11447
|
+
}
|
|
11448
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11449
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11450
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11451
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11452
|
+
/* @__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" }) })
|
|
11453
|
+
] }),
|
|
11454
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11455
|
+
] });
|
|
11456
|
+
};
|
|
11457
|
+
const SalesChannelForm = ({ order }) => {
|
|
11458
|
+
const form = reactHookForm.useForm({
|
|
11459
|
+
defaultValues: {
|
|
11460
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11461
|
+
},
|
|
11462
|
+
resolver: zod.zodResolver(schema$3)
|
|
11463
|
+
});
|
|
11464
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11465
|
+
const { handleSuccess } = useRouteModal();
|
|
11466
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11467
|
+
await mutateAsync(
|
|
11468
|
+
{
|
|
11469
|
+
sales_channel_id: data.sales_channel_id
|
|
11470
|
+
},
|
|
11471
|
+
{
|
|
11472
|
+
onSuccess: () => {
|
|
11473
|
+
ui.toast.success("Sales channel updated");
|
|
11474
|
+
handleSuccess();
|
|
11475
|
+
},
|
|
11476
|
+
onError: (error) => {
|
|
11477
|
+
ui.toast.error(error.message);
|
|
11478
|
+
}
|
|
11479
|
+
}
|
|
11480
|
+
);
|
|
11481
|
+
});
|
|
11482
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11483
|
+
KeyboundForm,
|
|
11484
|
+
{
|
|
11485
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11486
|
+
onSubmit,
|
|
11487
|
+
children: [
|
|
11488
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11489
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11490
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11491
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11492
|
+
] }) })
|
|
11493
|
+
]
|
|
11494
|
+
}
|
|
11495
|
+
) });
|
|
11496
|
+
};
|
|
11497
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11498
|
+
const salesChannels = useComboboxData({
|
|
11499
|
+
queryFn: async (params) => {
|
|
11500
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11501
|
+
},
|
|
11502
|
+
queryKey: ["sales-channels"],
|
|
11503
|
+
getOptions: (data) => {
|
|
11504
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11505
|
+
label: salesChannel.name,
|
|
11506
|
+
value: salesChannel.id
|
|
11507
|
+
}));
|
|
11508
|
+
},
|
|
11509
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11510
|
+
});
|
|
11511
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11512
|
+
Form$2.Field,
|
|
11513
|
+
{
|
|
11514
|
+
control,
|
|
11515
|
+
name: "sales_channel_id",
|
|
11516
|
+
render: ({ field }) => {
|
|
11517
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11518
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11519
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11520
|
+
Combobox,
|
|
11521
|
+
{
|
|
11522
|
+
options: salesChannels.options,
|
|
11523
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11524
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11525
|
+
searchValue: salesChannels.searchValue,
|
|
11526
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11527
|
+
placeholder: "Select sales channel",
|
|
11528
|
+
...field
|
|
11529
|
+
}
|
|
11530
|
+
) }),
|
|
11531
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11532
|
+
] });
|
|
11533
|
+
}
|
|
11534
|
+
}
|
|
11535
|
+
);
|
|
11536
|
+
};
|
|
11537
|
+
const schema$3 = objectType({
|
|
11538
|
+
sales_channel_id: stringType().min(1)
|
|
11539
|
+
});
|
|
11455
11540
|
const ShippingAddress = () => {
|
|
11456
11541
|
const { id } = reactRouterDom.useParams();
|
|
11457
11542
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -12131,6 +12216,27 @@ const Illustration = () => {
|
|
|
12131
12216
|
const schema$1 = objectType({
|
|
12132
12217
|
customer_id: stringType().min(1)
|
|
12133
12218
|
});
|
|
12219
|
+
const CustomItems = () => {
|
|
12220
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12221
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
12222
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
12223
|
+
] });
|
|
12224
|
+
};
|
|
12225
|
+
const CustomItemsForm = () => {
|
|
12226
|
+
const form = reactHookForm.useForm({
|
|
12227
|
+
resolver: zod.zodResolver(schema)
|
|
12228
|
+
});
|
|
12229
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
12230
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
12231
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12232
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12233
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
12234
|
+
] }) })
|
|
12235
|
+
] }) });
|
|
12236
|
+
};
|
|
12237
|
+
const schema = objectType({
|
|
12238
|
+
email: stringType().email()
|
|
12239
|
+
});
|
|
12134
12240
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
12135
12241
|
const Shipping = () => {
|
|
12136
12242
|
var _a;
|
|
@@ -12938,112 +13044,6 @@ const CustomAmountField = ({
|
|
|
12938
13044
|
}
|
|
12939
13045
|
);
|
|
12940
13046
|
};
|
|
12941
|
-
const SalesChannel = () => {
|
|
12942
|
-
const { id } = reactRouterDom.useParams();
|
|
12943
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12944
|
-
id,
|
|
12945
|
-
{
|
|
12946
|
-
fields: "+sales_channel_id"
|
|
12947
|
-
},
|
|
12948
|
-
{
|
|
12949
|
-
enabled: !!id
|
|
12950
|
-
}
|
|
12951
|
-
);
|
|
12952
|
-
if (isError) {
|
|
12953
|
-
throw error;
|
|
12954
|
-
}
|
|
12955
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12956
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12957
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12958
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12959
|
-
/* @__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" }) })
|
|
12960
|
-
] }),
|
|
12961
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12962
|
-
] });
|
|
12963
|
-
};
|
|
12964
|
-
const SalesChannelForm = ({ order }) => {
|
|
12965
|
-
const form = reactHookForm.useForm({
|
|
12966
|
-
defaultValues: {
|
|
12967
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12968
|
-
},
|
|
12969
|
-
resolver: zod.zodResolver(schema)
|
|
12970
|
-
});
|
|
12971
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12972
|
-
const { handleSuccess } = useRouteModal();
|
|
12973
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12974
|
-
await mutateAsync(
|
|
12975
|
-
{
|
|
12976
|
-
sales_channel_id: data.sales_channel_id
|
|
12977
|
-
},
|
|
12978
|
-
{
|
|
12979
|
-
onSuccess: () => {
|
|
12980
|
-
ui.toast.success("Sales channel updated");
|
|
12981
|
-
handleSuccess();
|
|
12982
|
-
},
|
|
12983
|
-
onError: (error) => {
|
|
12984
|
-
ui.toast.error(error.message);
|
|
12985
|
-
}
|
|
12986
|
-
}
|
|
12987
|
-
);
|
|
12988
|
-
});
|
|
12989
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12990
|
-
KeyboundForm,
|
|
12991
|
-
{
|
|
12992
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12993
|
-
onSubmit,
|
|
12994
|
-
children: [
|
|
12995
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12996
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12997
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12998
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12999
|
-
] }) })
|
|
13000
|
-
]
|
|
13001
|
-
}
|
|
13002
|
-
) });
|
|
13003
|
-
};
|
|
13004
|
-
const SalesChannelField = ({ control, order }) => {
|
|
13005
|
-
const salesChannels = useComboboxData({
|
|
13006
|
-
queryFn: async (params) => {
|
|
13007
|
-
return await sdk.admin.salesChannel.list(params);
|
|
13008
|
-
},
|
|
13009
|
-
queryKey: ["sales-channels"],
|
|
13010
|
-
getOptions: (data) => {
|
|
13011
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
13012
|
-
label: salesChannel.name,
|
|
13013
|
-
value: salesChannel.id
|
|
13014
|
-
}));
|
|
13015
|
-
},
|
|
13016
|
-
defaultValue: order.sales_channel_id || void 0
|
|
13017
|
-
});
|
|
13018
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13019
|
-
Form$2.Field,
|
|
13020
|
-
{
|
|
13021
|
-
control,
|
|
13022
|
-
name: "sales_channel_id",
|
|
13023
|
-
render: ({ field }) => {
|
|
13024
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13025
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13026
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13027
|
-
Combobox,
|
|
13028
|
-
{
|
|
13029
|
-
options: salesChannels.options,
|
|
13030
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
13031
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13032
|
-
searchValue: salesChannels.searchValue,
|
|
13033
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13034
|
-
placeholder: "Select sales channel",
|
|
13035
|
-
...field
|
|
13036
|
-
}
|
|
13037
|
-
) }),
|
|
13038
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13039
|
-
] });
|
|
13040
|
-
}
|
|
13041
|
-
}
|
|
13042
|
-
);
|
|
13043
|
-
};
|
|
13044
|
-
const schema = objectType({
|
|
13045
|
-
sales_channel_id: stringType().min(1)
|
|
13046
|
-
});
|
|
13047
13047
|
const widgetModule = { widgets: [] };
|
|
13048
13048
|
const routeModule = {
|
|
13049
13049
|
routes: [
|
|
@@ -13068,10 +13068,6 @@ const routeModule = {
|
|
|
13068
13068
|
Component: BillingAddress,
|
|
13069
13069
|
path: "/draft-orders/:id/billing-address"
|
|
13070
13070
|
},
|
|
13071
|
-
{
|
|
13072
|
-
Component: CustomItems,
|
|
13073
|
-
path: "/draft-orders/:id/custom-items"
|
|
13074
|
-
},
|
|
13075
13071
|
{
|
|
13076
13072
|
Component: Email,
|
|
13077
13073
|
path: "/draft-orders/:id/email"
|
|
@@ -13088,6 +13084,10 @@ const routeModule = {
|
|
|
13088
13084
|
Component: Promotions,
|
|
13089
13085
|
path: "/draft-orders/:id/promotions"
|
|
13090
13086
|
},
|
|
13087
|
+
{
|
|
13088
|
+
Component: SalesChannel,
|
|
13089
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13090
|
+
},
|
|
13091
13091
|
{
|
|
13092
13092
|
Component: ShippingAddress,
|
|
13093
13093
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -13097,12 +13097,12 @@ const routeModule = {
|
|
|
13097
13097
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13098
13098
|
},
|
|
13099
13099
|
{
|
|
13100
|
-
Component:
|
|
13101
|
-
path: "/draft-orders/:id/
|
|
13100
|
+
Component: CustomItems,
|
|
13101
|
+
path: "/draft-orders/:id/custom-items"
|
|
13102
13102
|
},
|
|
13103
13103
|
{
|
|
13104
|
-
Component:
|
|
13105
|
-
path: "/draft-orders/:id/
|
|
13104
|
+
Component: Shipping,
|
|
13105
|
+
path: "/draft-orders/:id/shipping"
|
|
13106
13106
|
}
|
|
13107
13107
|
]
|
|
13108
13108
|
}
|
|
@@ -9755,27 +9755,6 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9755
9755
|
) });
|
|
9756
9756
|
};
|
|
9757
9757
|
const schema$5 = addressSchema;
|
|
9758
|
-
const CustomItems = () => {
|
|
9759
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9760
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9761
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9762
|
-
] });
|
|
9763
|
-
};
|
|
9764
|
-
const CustomItemsForm = () => {
|
|
9765
|
-
const form = useForm({
|
|
9766
|
-
resolver: zodResolver(schema$4)
|
|
9767
|
-
});
|
|
9768
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9769
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9770
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9771
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9772
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9773
|
-
] }) })
|
|
9774
|
-
] }) });
|
|
9775
|
-
};
|
|
9776
|
-
const schema$4 = objectType({
|
|
9777
|
-
email: stringType().email()
|
|
9778
|
-
});
|
|
9779
9758
|
const Email = () => {
|
|
9780
9759
|
const { id } = useParams();
|
|
9781
9760
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9798,7 +9777,7 @@ const EmailForm = ({ order }) => {
|
|
|
9798
9777
|
defaultValues: {
|
|
9799
9778
|
email: order.email ?? ""
|
|
9800
9779
|
},
|
|
9801
|
-
resolver: zodResolver(schema$
|
|
9780
|
+
resolver: zodResolver(schema$4)
|
|
9802
9781
|
});
|
|
9803
9782
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9804
9783
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9841,7 +9820,7 @@ const EmailForm = ({ order }) => {
|
|
|
9841
9820
|
}
|
|
9842
9821
|
) });
|
|
9843
9822
|
};
|
|
9844
|
-
const schema$
|
|
9823
|
+
const schema$4 = objectType({
|
|
9845
9824
|
email: stringType().email()
|
|
9846
9825
|
});
|
|
9847
9826
|
const NumberInput = forwardRef(
|
|
@@ -11445,6 +11424,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11445
11424
|
}
|
|
11446
11425
|
return Array.from(promotionIds);
|
|
11447
11426
|
}
|
|
11427
|
+
const SalesChannel = () => {
|
|
11428
|
+
const { id } = useParams();
|
|
11429
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11430
|
+
id,
|
|
11431
|
+
{
|
|
11432
|
+
fields: "+sales_channel_id"
|
|
11433
|
+
},
|
|
11434
|
+
{
|
|
11435
|
+
enabled: !!id
|
|
11436
|
+
}
|
|
11437
|
+
);
|
|
11438
|
+
if (isError) {
|
|
11439
|
+
throw error;
|
|
11440
|
+
}
|
|
11441
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11442
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11443
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11444
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11445
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11446
|
+
] }),
|
|
11447
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11448
|
+
] });
|
|
11449
|
+
};
|
|
11450
|
+
const SalesChannelForm = ({ order }) => {
|
|
11451
|
+
const form = useForm({
|
|
11452
|
+
defaultValues: {
|
|
11453
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11454
|
+
},
|
|
11455
|
+
resolver: zodResolver(schema$3)
|
|
11456
|
+
});
|
|
11457
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11458
|
+
const { handleSuccess } = useRouteModal();
|
|
11459
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11460
|
+
await mutateAsync(
|
|
11461
|
+
{
|
|
11462
|
+
sales_channel_id: data.sales_channel_id
|
|
11463
|
+
},
|
|
11464
|
+
{
|
|
11465
|
+
onSuccess: () => {
|
|
11466
|
+
toast.success("Sales channel updated");
|
|
11467
|
+
handleSuccess();
|
|
11468
|
+
},
|
|
11469
|
+
onError: (error) => {
|
|
11470
|
+
toast.error(error.message);
|
|
11471
|
+
}
|
|
11472
|
+
}
|
|
11473
|
+
);
|
|
11474
|
+
});
|
|
11475
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11476
|
+
KeyboundForm,
|
|
11477
|
+
{
|
|
11478
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11479
|
+
onSubmit,
|
|
11480
|
+
children: [
|
|
11481
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11482
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11483
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11484
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11485
|
+
] }) })
|
|
11486
|
+
]
|
|
11487
|
+
}
|
|
11488
|
+
) });
|
|
11489
|
+
};
|
|
11490
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11491
|
+
const salesChannels = useComboboxData({
|
|
11492
|
+
queryFn: async (params) => {
|
|
11493
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11494
|
+
},
|
|
11495
|
+
queryKey: ["sales-channels"],
|
|
11496
|
+
getOptions: (data) => {
|
|
11497
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11498
|
+
label: salesChannel.name,
|
|
11499
|
+
value: salesChannel.id
|
|
11500
|
+
}));
|
|
11501
|
+
},
|
|
11502
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11503
|
+
});
|
|
11504
|
+
return /* @__PURE__ */ jsx(
|
|
11505
|
+
Form$2.Field,
|
|
11506
|
+
{
|
|
11507
|
+
control,
|
|
11508
|
+
name: "sales_channel_id",
|
|
11509
|
+
render: ({ field }) => {
|
|
11510
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11511
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11512
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11513
|
+
Combobox,
|
|
11514
|
+
{
|
|
11515
|
+
options: salesChannels.options,
|
|
11516
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11517
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11518
|
+
searchValue: salesChannels.searchValue,
|
|
11519
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11520
|
+
placeholder: "Select sales channel",
|
|
11521
|
+
...field
|
|
11522
|
+
}
|
|
11523
|
+
) }),
|
|
11524
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11525
|
+
] });
|
|
11526
|
+
}
|
|
11527
|
+
}
|
|
11528
|
+
);
|
|
11529
|
+
};
|
|
11530
|
+
const schema$3 = objectType({
|
|
11531
|
+
sales_channel_id: stringType().min(1)
|
|
11532
|
+
});
|
|
11448
11533
|
const ShippingAddress = () => {
|
|
11449
11534
|
const { id } = useParams();
|
|
11450
11535
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -12124,6 +12209,27 @@ const Illustration = () => {
|
|
|
12124
12209
|
const schema$1 = objectType({
|
|
12125
12210
|
customer_id: stringType().min(1)
|
|
12126
12211
|
});
|
|
12212
|
+
const CustomItems = () => {
|
|
12213
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12214
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
12215
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
12216
|
+
] });
|
|
12217
|
+
};
|
|
12218
|
+
const CustomItemsForm = () => {
|
|
12219
|
+
const form = useForm({
|
|
12220
|
+
resolver: zodResolver(schema)
|
|
12221
|
+
});
|
|
12222
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
12223
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
12224
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12225
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12226
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
12227
|
+
] }) })
|
|
12228
|
+
] }) });
|
|
12229
|
+
};
|
|
12230
|
+
const schema = objectType({
|
|
12231
|
+
email: stringType().email()
|
|
12232
|
+
});
|
|
12127
12233
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
12128
12234
|
const Shipping = () => {
|
|
12129
12235
|
var _a;
|
|
@@ -12931,112 +13037,6 @@ const CustomAmountField = ({
|
|
|
12931
13037
|
}
|
|
12932
13038
|
);
|
|
12933
13039
|
};
|
|
12934
|
-
const SalesChannel = () => {
|
|
12935
|
-
const { id } = useParams();
|
|
12936
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12937
|
-
id,
|
|
12938
|
-
{
|
|
12939
|
-
fields: "+sales_channel_id"
|
|
12940
|
-
},
|
|
12941
|
-
{
|
|
12942
|
-
enabled: !!id
|
|
12943
|
-
}
|
|
12944
|
-
);
|
|
12945
|
-
if (isError) {
|
|
12946
|
-
throw error;
|
|
12947
|
-
}
|
|
12948
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12949
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12950
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12951
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12952
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12953
|
-
] }),
|
|
12954
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12955
|
-
] });
|
|
12956
|
-
};
|
|
12957
|
-
const SalesChannelForm = ({ order }) => {
|
|
12958
|
-
const form = useForm({
|
|
12959
|
-
defaultValues: {
|
|
12960
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12961
|
-
},
|
|
12962
|
-
resolver: zodResolver(schema)
|
|
12963
|
-
});
|
|
12964
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12965
|
-
const { handleSuccess } = useRouteModal();
|
|
12966
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12967
|
-
await mutateAsync(
|
|
12968
|
-
{
|
|
12969
|
-
sales_channel_id: data.sales_channel_id
|
|
12970
|
-
},
|
|
12971
|
-
{
|
|
12972
|
-
onSuccess: () => {
|
|
12973
|
-
toast.success("Sales channel updated");
|
|
12974
|
-
handleSuccess();
|
|
12975
|
-
},
|
|
12976
|
-
onError: (error) => {
|
|
12977
|
-
toast.error(error.message);
|
|
12978
|
-
}
|
|
12979
|
-
}
|
|
12980
|
-
);
|
|
12981
|
-
});
|
|
12982
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12983
|
-
KeyboundForm,
|
|
12984
|
-
{
|
|
12985
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12986
|
-
onSubmit,
|
|
12987
|
-
children: [
|
|
12988
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12989
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12990
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12991
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12992
|
-
] }) })
|
|
12993
|
-
]
|
|
12994
|
-
}
|
|
12995
|
-
) });
|
|
12996
|
-
};
|
|
12997
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12998
|
-
const salesChannels = useComboboxData({
|
|
12999
|
-
queryFn: async (params) => {
|
|
13000
|
-
return await sdk.admin.salesChannel.list(params);
|
|
13001
|
-
},
|
|
13002
|
-
queryKey: ["sales-channels"],
|
|
13003
|
-
getOptions: (data) => {
|
|
13004
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
13005
|
-
label: salesChannel.name,
|
|
13006
|
-
value: salesChannel.id
|
|
13007
|
-
}));
|
|
13008
|
-
},
|
|
13009
|
-
defaultValue: order.sales_channel_id || void 0
|
|
13010
|
-
});
|
|
13011
|
-
return /* @__PURE__ */ jsx(
|
|
13012
|
-
Form$2.Field,
|
|
13013
|
-
{
|
|
13014
|
-
control,
|
|
13015
|
-
name: "sales_channel_id",
|
|
13016
|
-
render: ({ field }) => {
|
|
13017
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13018
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13019
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
13020
|
-
Combobox,
|
|
13021
|
-
{
|
|
13022
|
-
options: salesChannels.options,
|
|
13023
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
13024
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13025
|
-
searchValue: salesChannels.searchValue,
|
|
13026
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13027
|
-
placeholder: "Select sales channel",
|
|
13028
|
-
...field
|
|
13029
|
-
}
|
|
13030
|
-
) }),
|
|
13031
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13032
|
-
] });
|
|
13033
|
-
}
|
|
13034
|
-
}
|
|
13035
|
-
);
|
|
13036
|
-
};
|
|
13037
|
-
const schema = objectType({
|
|
13038
|
-
sales_channel_id: stringType().min(1)
|
|
13039
|
-
});
|
|
13040
13040
|
const widgetModule = { widgets: [] };
|
|
13041
13041
|
const routeModule = {
|
|
13042
13042
|
routes: [
|
|
@@ -13061,10 +13061,6 @@ const routeModule = {
|
|
|
13061
13061
|
Component: BillingAddress,
|
|
13062
13062
|
path: "/draft-orders/:id/billing-address"
|
|
13063
13063
|
},
|
|
13064
|
-
{
|
|
13065
|
-
Component: CustomItems,
|
|
13066
|
-
path: "/draft-orders/:id/custom-items"
|
|
13067
|
-
},
|
|
13068
13064
|
{
|
|
13069
13065
|
Component: Email,
|
|
13070
13066
|
path: "/draft-orders/:id/email"
|
|
@@ -13081,6 +13077,10 @@ const routeModule = {
|
|
|
13081
13077
|
Component: Promotions,
|
|
13082
13078
|
path: "/draft-orders/:id/promotions"
|
|
13083
13079
|
},
|
|
13080
|
+
{
|
|
13081
|
+
Component: SalesChannel,
|
|
13082
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13083
|
+
},
|
|
13084
13084
|
{
|
|
13085
13085
|
Component: ShippingAddress,
|
|
13086
13086
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -13090,12 +13090,12 @@ const routeModule = {
|
|
|
13090
13090
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13091
13091
|
},
|
|
13092
13092
|
{
|
|
13093
|
-
Component:
|
|
13094
|
-
path: "/draft-orders/:id/
|
|
13093
|
+
Component: CustomItems,
|
|
13094
|
+
path: "/draft-orders/:id/custom-items"
|
|
13095
13095
|
},
|
|
13096
13096
|
{
|
|
13097
|
-
Component:
|
|
13098
|
-
path: "/draft-orders/:id/
|
|
13097
|
+
Component: Shipping,
|
|
13098
|
+
path: "/draft-orders/:id/shipping"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|
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-20251113180136",
|
|
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-20251113180136",
|
|
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-20251113180136",
|
|
52
|
+
"@medusajs/cli": "2.11.4-preview-20251113180136",
|
|
53
|
+
"@medusajs/framework": "2.11.4-preview-20251113180136",
|
|
54
|
+
"@medusajs/icons": "2.11.4-preview-20251113180136",
|
|
55
|
+
"@medusajs/test-utils": "2.11.4-preview-20251113180136",
|
|
56
|
+
"@medusajs/types": "2.11.4-preview-20251113180136",
|
|
57
|
+
"@medusajs/ui": "4.0.28-preview-20251113180136",
|
|
58
|
+
"@medusajs/ui-preset": "2.11.4-preview-20251113180136"
|
|
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-20251113180136",
|
|
62
|
+
"@medusajs/cli": "2.11.4-preview-20251113180136",
|
|
63
|
+
"@medusajs/framework": "2.11.4-preview-20251113180136",
|
|
64
|
+
"@medusajs/icons": "2.11.4-preview-20251113180136",
|
|
65
|
+
"@medusajs/test-utils": "2.11.4-preview-20251113180136",
|
|
66
|
+
"@medusajs/ui": "4.0.28-preview-20251113180136",
|
|
67
67
|
"react": "^18.3.1",
|
|
68
68
|
"react-dom": "^18.3.1",
|
|
69
69
|
"react-router-dom": "6.20.1"
|