@medusajs/draft-order 2.10.2-preview-20250910030955 → 2.10.2-preview-20250910090158

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.
@@ -9763,27 +9763,6 @@ const BillingAddressForm = ({ order }) => {
9763
9763
  ) });
9764
9764
  };
9765
9765
  const schema$5 = addressSchema;
9766
- const CustomItems = () => {
9767
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9768
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9769
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9770
- ] });
9771
- };
9772
- const CustomItemsForm = () => {
9773
- const form = reactHookForm.useForm({
9774
- resolver: zod.zodResolver(schema$4)
9775
- });
9776
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9777
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9778
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9779
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9780
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9781
- ] }) })
9782
- ] }) });
9783
- };
9784
- const schema$4 = objectType({
9785
- email: stringType().email()
9786
- });
9787
9766
  const Email = () => {
9788
9767
  const { id } = reactRouterDom.useParams();
9789
9768
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9806,7 +9785,7 @@ const EmailForm = ({ order }) => {
9806
9785
  defaultValues: {
9807
9786
  email: order.email ?? ""
9808
9787
  },
9809
- resolver: zod.zodResolver(schema$3)
9788
+ resolver: zod.zodResolver(schema$4)
9810
9789
  });
9811
9790
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9812
9791
  const { handleSuccess } = useRouteModal();
@@ -9849,6 +9828,27 @@ const EmailForm = ({ order }) => {
9849
9828
  }
9850
9829
  ) });
9851
9830
  };
9831
+ const schema$4 = objectType({
9832
+ email: stringType().email()
9833
+ });
9834
+ const CustomItems = () => {
9835
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9836
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9837
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9838
+ ] });
9839
+ };
9840
+ const CustomItemsForm = () => {
9841
+ const form = reactHookForm.useForm({
9842
+ resolver: zod.zodResolver(schema$3)
9843
+ });
9844
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9845
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9846
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9847
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9848
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9849
+ ] }) })
9850
+ ] }) });
9851
+ };
9852
9852
  const schema$3 = objectType({
9853
9853
  email: stringType().email()
9854
9854
  });
@@ -11453,112 +11453,6 @@ function getPromotionIds(items, shippingMethods) {
11453
11453
  }
11454
11454
  return Array.from(promotionIds);
11455
11455
  }
11456
- const SalesChannel = () => {
11457
- const { id } = reactRouterDom.useParams();
11458
- const { draft_order, isPending, isError, error } = useDraftOrder(
11459
- id,
11460
- {
11461
- fields: "+sales_channel_id"
11462
- },
11463
- {
11464
- enabled: !!id
11465
- }
11466
- );
11467
- if (isError) {
11468
- throw error;
11469
- }
11470
- const ISrEADY = !!draft_order && !isPending;
11471
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11472
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11473
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11474
- /* @__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" }) })
11475
- ] }),
11476
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11477
- ] });
11478
- };
11479
- const SalesChannelForm = ({ order }) => {
11480
- const form = reactHookForm.useForm({
11481
- defaultValues: {
11482
- sales_channel_id: order.sales_channel_id || ""
11483
- },
11484
- resolver: zod.zodResolver(schema$2)
11485
- });
11486
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11487
- const { handleSuccess } = useRouteModal();
11488
- const onSubmit = form.handleSubmit(async (data) => {
11489
- await mutateAsync(
11490
- {
11491
- sales_channel_id: data.sales_channel_id
11492
- },
11493
- {
11494
- onSuccess: () => {
11495
- ui.toast.success("Sales channel updated");
11496
- handleSuccess();
11497
- },
11498
- onError: (error) => {
11499
- ui.toast.error(error.message);
11500
- }
11501
- }
11502
- );
11503
- });
11504
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11505
- KeyboundForm,
11506
- {
11507
- className: "flex flex-1 flex-col overflow-hidden",
11508
- onSubmit,
11509
- children: [
11510
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11511
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11512
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11513
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11514
- ] }) })
11515
- ]
11516
- }
11517
- ) });
11518
- };
11519
- const SalesChannelField = ({ control, order }) => {
11520
- const salesChannels = useComboboxData({
11521
- queryFn: async (params) => {
11522
- return await sdk.admin.salesChannel.list(params);
11523
- },
11524
- queryKey: ["sales-channels"],
11525
- getOptions: (data) => {
11526
- return data.sales_channels.map((salesChannel) => ({
11527
- label: salesChannel.name,
11528
- value: salesChannel.id
11529
- }));
11530
- },
11531
- defaultValue: order.sales_channel_id || void 0
11532
- });
11533
- return /* @__PURE__ */ jsxRuntime.jsx(
11534
- Form$2.Field,
11535
- {
11536
- control,
11537
- name: "sales_channel_id",
11538
- render: ({ field }) => {
11539
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11540
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11541
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11542
- Combobox,
11543
- {
11544
- options: salesChannels.options,
11545
- fetchNextPage: salesChannels.fetchNextPage,
11546
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11547
- searchValue: salesChannels.searchValue,
11548
- onSearchValueChange: salesChannels.onSearchValueChange,
11549
- placeholder: "Select sales channel",
11550
- ...field
11551
- }
11552
- ) }),
11553
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11554
- ] });
11555
- }
11556
- }
11557
- );
11558
- };
11559
- const schema$2 = objectType({
11560
- sales_channel_id: stringType().min(1)
11561
- });
11562
11456
  const ShippingAddress = () => {
11563
11457
  const { id } = reactRouterDom.useParams();
11564
11458
  const { order, isPending, isError, error } = useOrder(id, {
@@ -11591,7 +11485,7 @@ const ShippingAddressForm = ({ order }) => {
11591
11485
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11592
11486
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11593
11487
  },
11594
- resolver: zod.zodResolver(schema$1)
11488
+ resolver: zod.zodResolver(schema$2)
11595
11489
  });
11596
11490
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11597
11491
  const { handleSuccess } = useRouteModal();
@@ -11761,7 +11655,7 @@ const ShippingAddressForm = ({ order }) => {
11761
11655
  }
11762
11656
  ) });
11763
11657
  };
11764
- const schema$1 = addressSchema;
11658
+ const schema$2 = addressSchema;
11765
11659
  const TransferOwnership = () => {
11766
11660
  const { id } = reactRouterDom.useParams();
11767
11661
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -11785,7 +11679,7 @@ const TransferOwnershipForm = ({ order }) => {
11785
11679
  defaultValues: {
11786
11680
  customer_id: order.customer_id || ""
11787
11681
  },
11788
- resolver: zod.zodResolver(schema)
11682
+ resolver: zod.zodResolver(schema$1)
11789
11683
  });
11790
11684
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11791
11685
  const { handleSuccess } = useRouteModal();
@@ -12235,9 +12129,115 @@ const Illustration = () => {
12235
12129
  }
12236
12130
  );
12237
12131
  };
12238
- const schema = objectType({
12132
+ const schema$1 = objectType({
12239
12133
  customer_id: stringType().min(1)
12240
12134
  });
12135
+ const SalesChannel = () => {
12136
+ const { id } = reactRouterDom.useParams();
12137
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12138
+ id,
12139
+ {
12140
+ fields: "+sales_channel_id"
12141
+ },
12142
+ {
12143
+ enabled: !!id
12144
+ }
12145
+ );
12146
+ if (isError) {
12147
+ throw error;
12148
+ }
12149
+ const ISrEADY = !!draft_order && !isPending;
12150
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12151
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12152
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12153
+ /* @__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" }) })
12154
+ ] }),
12155
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12156
+ ] });
12157
+ };
12158
+ const SalesChannelForm = ({ order }) => {
12159
+ const form = reactHookForm.useForm({
12160
+ defaultValues: {
12161
+ sales_channel_id: order.sales_channel_id || ""
12162
+ },
12163
+ resolver: zod.zodResolver(schema)
12164
+ });
12165
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12166
+ const { handleSuccess } = useRouteModal();
12167
+ const onSubmit = form.handleSubmit(async (data) => {
12168
+ await mutateAsync(
12169
+ {
12170
+ sales_channel_id: data.sales_channel_id
12171
+ },
12172
+ {
12173
+ onSuccess: () => {
12174
+ ui.toast.success("Sales channel updated");
12175
+ handleSuccess();
12176
+ },
12177
+ onError: (error) => {
12178
+ ui.toast.error(error.message);
12179
+ }
12180
+ }
12181
+ );
12182
+ });
12183
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12184
+ KeyboundForm,
12185
+ {
12186
+ className: "flex flex-1 flex-col overflow-hidden",
12187
+ onSubmit,
12188
+ children: [
12189
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12190
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12191
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12192
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12193
+ ] }) })
12194
+ ]
12195
+ }
12196
+ ) });
12197
+ };
12198
+ const SalesChannelField = ({ control, order }) => {
12199
+ const salesChannels = useComboboxData({
12200
+ queryFn: async (params) => {
12201
+ return await sdk.admin.salesChannel.list(params);
12202
+ },
12203
+ queryKey: ["sales-channels"],
12204
+ getOptions: (data) => {
12205
+ return data.sales_channels.map((salesChannel) => ({
12206
+ label: salesChannel.name,
12207
+ value: salesChannel.id
12208
+ }));
12209
+ },
12210
+ defaultValue: order.sales_channel_id || void 0
12211
+ });
12212
+ return /* @__PURE__ */ jsxRuntime.jsx(
12213
+ Form$2.Field,
12214
+ {
12215
+ control,
12216
+ name: "sales_channel_id",
12217
+ render: ({ field }) => {
12218
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12219
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12220
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12221
+ Combobox,
12222
+ {
12223
+ options: salesChannels.options,
12224
+ fetchNextPage: salesChannels.fetchNextPage,
12225
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12226
+ searchValue: salesChannels.searchValue,
12227
+ onSearchValueChange: salesChannels.onSearchValueChange,
12228
+ placeholder: "Select sales channel",
12229
+ ...field
12230
+ }
12231
+ ) }),
12232
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12233
+ ] });
12234
+ }
12235
+ }
12236
+ );
12237
+ };
12238
+ const schema = objectType({
12239
+ sales_channel_id: stringType().min(1)
12240
+ });
12241
12241
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
12242
12242
  const Shipping = () => {
12243
12243
  var _a;
@@ -13069,14 +13069,14 @@ const routeModule = {
13069
13069
  Component: BillingAddress,
13070
13070
  path: "/draft-orders/:id/billing-address"
13071
13071
  },
13072
- {
13073
- Component: CustomItems,
13074
- path: "/draft-orders/:id/custom-items"
13075
- },
13076
13072
  {
13077
13073
  Component: Email,
13078
13074
  path: "/draft-orders/:id/email"
13079
13075
  },
13076
+ {
13077
+ Component: CustomItems,
13078
+ path: "/draft-orders/:id/custom-items"
13079
+ },
13080
13080
  {
13081
13081
  Component: Items,
13082
13082
  path: "/draft-orders/:id/items"
@@ -13089,10 +13089,6 @@ const routeModule = {
13089
13089
  Component: Promotions,
13090
13090
  path: "/draft-orders/:id/promotions"
13091
13091
  },
13092
- {
13093
- Component: SalesChannel,
13094
- path: "/draft-orders/:id/sales-channel"
13095
- },
13096
13092
  {
13097
13093
  Component: ShippingAddress,
13098
13094
  path: "/draft-orders/:id/shipping-address"
@@ -13101,6 +13097,10 @@ const routeModule = {
13101
13097
  Component: TransferOwnership,
13102
13098
  path: "/draft-orders/:id/transfer-ownership"
13103
13099
  },
13100
+ {
13101
+ Component: SalesChannel,
13102
+ path: "/draft-orders/:id/sales-channel"
13103
+ },
13104
13104
  {
13105
13105
  Component: Shipping,
13106
13106
  path: "/draft-orders/:id/shipping"
@@ -9757,27 +9757,6 @@ const BillingAddressForm = ({ order }) => {
9757
9757
  ) });
9758
9758
  };
9759
9759
  const schema$5 = addressSchema;
9760
- const CustomItems = () => {
9761
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9762
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9763
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9764
- ] });
9765
- };
9766
- const CustomItemsForm = () => {
9767
- const form = useForm({
9768
- resolver: zodResolver(schema$4)
9769
- });
9770
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9771
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9772
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9773
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9774
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9775
- ] }) })
9776
- ] }) });
9777
- };
9778
- const schema$4 = objectType({
9779
- email: stringType().email()
9780
- });
9781
9760
  const Email = () => {
9782
9761
  const { id } = useParams();
9783
9762
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9800,7 +9779,7 @@ const EmailForm = ({ order }) => {
9800
9779
  defaultValues: {
9801
9780
  email: order.email ?? ""
9802
9781
  },
9803
- resolver: zodResolver(schema$3)
9782
+ resolver: zodResolver(schema$4)
9804
9783
  });
9805
9784
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9806
9785
  const { handleSuccess } = useRouteModal();
@@ -9843,6 +9822,27 @@ const EmailForm = ({ order }) => {
9843
9822
  }
9844
9823
  ) });
9845
9824
  };
9825
+ const schema$4 = objectType({
9826
+ email: stringType().email()
9827
+ });
9828
+ const CustomItems = () => {
9829
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9830
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9831
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9832
+ ] });
9833
+ };
9834
+ const CustomItemsForm = () => {
9835
+ const form = useForm({
9836
+ resolver: zodResolver(schema$3)
9837
+ });
9838
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9839
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9840
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9841
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9842
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9843
+ ] }) })
9844
+ ] }) });
9845
+ };
9846
9846
  const schema$3 = objectType({
9847
9847
  email: stringType().email()
9848
9848
  });
@@ -11447,112 +11447,6 @@ function getPromotionIds(items, shippingMethods) {
11447
11447
  }
11448
11448
  return Array.from(promotionIds);
11449
11449
  }
11450
- const SalesChannel = () => {
11451
- const { id } = useParams();
11452
- const { draft_order, isPending, isError, error } = useDraftOrder(
11453
- id,
11454
- {
11455
- fields: "+sales_channel_id"
11456
- },
11457
- {
11458
- enabled: !!id
11459
- }
11460
- );
11461
- if (isError) {
11462
- throw error;
11463
- }
11464
- const ISrEADY = !!draft_order && !isPending;
11465
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11466
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11467
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11468
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11469
- ] }),
11470
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11471
- ] });
11472
- };
11473
- const SalesChannelForm = ({ order }) => {
11474
- const form = useForm({
11475
- defaultValues: {
11476
- sales_channel_id: order.sales_channel_id || ""
11477
- },
11478
- resolver: zodResolver(schema$2)
11479
- });
11480
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11481
- const { handleSuccess } = useRouteModal();
11482
- const onSubmit = form.handleSubmit(async (data) => {
11483
- await mutateAsync(
11484
- {
11485
- sales_channel_id: data.sales_channel_id
11486
- },
11487
- {
11488
- onSuccess: () => {
11489
- toast.success("Sales channel updated");
11490
- handleSuccess();
11491
- },
11492
- onError: (error) => {
11493
- toast.error(error.message);
11494
- }
11495
- }
11496
- );
11497
- });
11498
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11499
- KeyboundForm,
11500
- {
11501
- className: "flex flex-1 flex-col overflow-hidden",
11502
- onSubmit,
11503
- children: [
11504
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11505
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11506
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11507
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11508
- ] }) })
11509
- ]
11510
- }
11511
- ) });
11512
- };
11513
- const SalesChannelField = ({ control, order }) => {
11514
- const salesChannels = useComboboxData({
11515
- queryFn: async (params) => {
11516
- return await sdk.admin.salesChannel.list(params);
11517
- },
11518
- queryKey: ["sales-channels"],
11519
- getOptions: (data) => {
11520
- return data.sales_channels.map((salesChannel) => ({
11521
- label: salesChannel.name,
11522
- value: salesChannel.id
11523
- }));
11524
- },
11525
- defaultValue: order.sales_channel_id || void 0
11526
- });
11527
- return /* @__PURE__ */ jsx(
11528
- Form$2.Field,
11529
- {
11530
- control,
11531
- name: "sales_channel_id",
11532
- render: ({ field }) => {
11533
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11534
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11535
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11536
- Combobox,
11537
- {
11538
- options: salesChannels.options,
11539
- fetchNextPage: salesChannels.fetchNextPage,
11540
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11541
- searchValue: salesChannels.searchValue,
11542
- onSearchValueChange: salesChannels.onSearchValueChange,
11543
- placeholder: "Select sales channel",
11544
- ...field
11545
- }
11546
- ) }),
11547
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11548
- ] });
11549
- }
11550
- }
11551
- );
11552
- };
11553
- const schema$2 = objectType({
11554
- sales_channel_id: stringType().min(1)
11555
- });
11556
11450
  const ShippingAddress = () => {
11557
11451
  const { id } = useParams();
11558
11452
  const { order, isPending, isError, error } = useOrder(id, {
@@ -11585,7 +11479,7 @@ const ShippingAddressForm = ({ order }) => {
11585
11479
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11586
11480
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11587
11481
  },
11588
- resolver: zodResolver(schema$1)
11482
+ resolver: zodResolver(schema$2)
11589
11483
  });
11590
11484
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11591
11485
  const { handleSuccess } = useRouteModal();
@@ -11755,7 +11649,7 @@ const ShippingAddressForm = ({ order }) => {
11755
11649
  }
11756
11650
  ) });
11757
11651
  };
11758
- const schema$1 = addressSchema;
11652
+ const schema$2 = addressSchema;
11759
11653
  const TransferOwnership = () => {
11760
11654
  const { id } = useParams();
11761
11655
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -11779,7 +11673,7 @@ const TransferOwnershipForm = ({ order }) => {
11779
11673
  defaultValues: {
11780
11674
  customer_id: order.customer_id || ""
11781
11675
  },
11782
- resolver: zodResolver(schema)
11676
+ resolver: zodResolver(schema$1)
11783
11677
  });
11784
11678
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11785
11679
  const { handleSuccess } = useRouteModal();
@@ -12229,9 +12123,115 @@ const Illustration = () => {
12229
12123
  }
12230
12124
  );
12231
12125
  };
12232
- const schema = objectType({
12126
+ const schema$1 = objectType({
12233
12127
  customer_id: stringType().min(1)
12234
12128
  });
12129
+ const SalesChannel = () => {
12130
+ const { id } = useParams();
12131
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12132
+ id,
12133
+ {
12134
+ fields: "+sales_channel_id"
12135
+ },
12136
+ {
12137
+ enabled: !!id
12138
+ }
12139
+ );
12140
+ if (isError) {
12141
+ throw error;
12142
+ }
12143
+ const ISrEADY = !!draft_order && !isPending;
12144
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12145
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12146
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12147
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12148
+ ] }),
12149
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12150
+ ] });
12151
+ };
12152
+ const SalesChannelForm = ({ order }) => {
12153
+ const form = useForm({
12154
+ defaultValues: {
12155
+ sales_channel_id: order.sales_channel_id || ""
12156
+ },
12157
+ resolver: zodResolver(schema)
12158
+ });
12159
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12160
+ const { handleSuccess } = useRouteModal();
12161
+ const onSubmit = form.handleSubmit(async (data) => {
12162
+ await mutateAsync(
12163
+ {
12164
+ sales_channel_id: data.sales_channel_id
12165
+ },
12166
+ {
12167
+ onSuccess: () => {
12168
+ toast.success("Sales channel updated");
12169
+ handleSuccess();
12170
+ },
12171
+ onError: (error) => {
12172
+ toast.error(error.message);
12173
+ }
12174
+ }
12175
+ );
12176
+ });
12177
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12178
+ KeyboundForm,
12179
+ {
12180
+ className: "flex flex-1 flex-col overflow-hidden",
12181
+ onSubmit,
12182
+ children: [
12183
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12184
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12185
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12186
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12187
+ ] }) })
12188
+ ]
12189
+ }
12190
+ ) });
12191
+ };
12192
+ const SalesChannelField = ({ control, order }) => {
12193
+ const salesChannels = useComboboxData({
12194
+ queryFn: async (params) => {
12195
+ return await sdk.admin.salesChannel.list(params);
12196
+ },
12197
+ queryKey: ["sales-channels"],
12198
+ getOptions: (data) => {
12199
+ return data.sales_channels.map((salesChannel) => ({
12200
+ label: salesChannel.name,
12201
+ value: salesChannel.id
12202
+ }));
12203
+ },
12204
+ defaultValue: order.sales_channel_id || void 0
12205
+ });
12206
+ return /* @__PURE__ */ jsx(
12207
+ Form$2.Field,
12208
+ {
12209
+ control,
12210
+ name: "sales_channel_id",
12211
+ render: ({ field }) => {
12212
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12213
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12214
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12215
+ Combobox,
12216
+ {
12217
+ options: salesChannels.options,
12218
+ fetchNextPage: salesChannels.fetchNextPage,
12219
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12220
+ searchValue: salesChannels.searchValue,
12221
+ onSearchValueChange: salesChannels.onSearchValueChange,
12222
+ placeholder: "Select sales channel",
12223
+ ...field
12224
+ }
12225
+ ) }),
12226
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12227
+ ] });
12228
+ }
12229
+ }
12230
+ );
12231
+ };
12232
+ const schema = objectType({
12233
+ sales_channel_id: stringType().min(1)
12234
+ });
12235
12235
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
12236
12236
  const Shipping = () => {
12237
12237
  var _a;
@@ -13063,14 +13063,14 @@ const routeModule = {
13063
13063
  Component: BillingAddress,
13064
13064
  path: "/draft-orders/:id/billing-address"
13065
13065
  },
13066
- {
13067
- Component: CustomItems,
13068
- path: "/draft-orders/:id/custom-items"
13069
- },
13070
13066
  {
13071
13067
  Component: Email,
13072
13068
  path: "/draft-orders/:id/email"
13073
13069
  },
13070
+ {
13071
+ Component: CustomItems,
13072
+ path: "/draft-orders/:id/custom-items"
13073
+ },
13074
13074
  {
13075
13075
  Component: Items,
13076
13076
  path: "/draft-orders/:id/items"
@@ -13083,10 +13083,6 @@ const routeModule = {
13083
13083
  Component: Promotions,
13084
13084
  path: "/draft-orders/:id/promotions"
13085
13085
  },
13086
- {
13087
- Component: SalesChannel,
13088
- path: "/draft-orders/:id/sales-channel"
13089
- },
13090
13086
  {
13091
13087
  Component: ShippingAddress,
13092
13088
  path: "/draft-orders/:id/shipping-address"
@@ -13095,6 +13091,10 @@ const routeModule = {
13095
13091
  Component: TransferOwnership,
13096
13092
  path: "/draft-orders/:id/transfer-ownership"
13097
13093
  },
13094
+ {
13095
+ Component: SalesChannel,
13096
+ path: "/draft-orders/:id/sales-channel"
13097
+ },
13098
13098
  {
13099
13099
  Component: Shipping,
13100
13100
  path: "/draft-orders/:id/shipping"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.10.2-preview-20250910030955",
3
+ "version": "2.10.2-preview-20250910090158",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@ariakit/react": "^0.4.15",
38
38
  "@hookform/resolvers": "3.4.2",
39
- "@medusajs/js-sdk": "2.10.2-preview-20250910030955",
39
+ "@medusajs/js-sdk": "2.10.2-preview-20250910090158",
40
40
  "@tanstack/react-query": "5.64.2",
41
41
  "@uiw/react-json-view": "^2.0.0-alpha.17",
42
42
  "date-fns": "^3.6.0",
@@ -45,14 +45,14 @@
45
45
  "react-hook-form": "7.49.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@medusajs/admin-sdk": "2.10.2-preview-20250910030955",
49
- "@medusajs/cli": "2.10.2-preview-20250910030955",
50
- "@medusajs/framework": "2.10.2-preview-20250910030955",
51
- "@medusajs/icons": "2.10.2-preview-20250910030955",
52
- "@medusajs/test-utils": "2.10.2-preview-20250910030955",
53
- "@medusajs/types": "2.10.2-preview-20250910030955",
54
- "@medusajs/ui": "4.0.22-preview-20250910030955",
55
- "@medusajs/ui-preset": "2.10.2-preview-20250910030955",
48
+ "@medusajs/admin-sdk": "2.10.2-preview-20250910090158",
49
+ "@medusajs/cli": "2.10.2-preview-20250910090158",
50
+ "@medusajs/framework": "2.10.2-preview-20250910090158",
51
+ "@medusajs/icons": "2.10.2-preview-20250910090158",
52
+ "@medusajs/test-utils": "2.10.2-preview-20250910090158",
53
+ "@medusajs/types": "2.10.2-preview-20250910090158",
54
+ "@medusajs/ui": "4.0.22-preview-20250910090158",
55
+ "@medusajs/ui-preset": "2.10.2-preview-20250910090158",
56
56
  "@mikro-orm/cli": "6.4.3",
57
57
  "@mikro-orm/core": "6.4.3",
58
58
  "@mikro-orm/knex": "6.4.3",
@@ -76,12 +76,12 @@
76
76
  "yalc": "^1.0.0-pre.53"
77
77
  },
78
78
  "peerDependencies": {
79
- "@medusajs/admin-sdk": "2.10.2-preview-20250910030955",
80
- "@medusajs/cli": "2.10.2-preview-20250910030955",
81
- "@medusajs/framework": "2.10.2-preview-20250910030955",
82
- "@medusajs/icons": "2.10.2-preview-20250910030955",
83
- "@medusajs/test-utils": "2.10.2-preview-20250910030955",
84
- "@medusajs/ui": "4.0.22-preview-20250910030955",
79
+ "@medusajs/admin-sdk": "2.10.2-preview-20250910090158",
80
+ "@medusajs/cli": "2.10.2-preview-20250910090158",
81
+ "@medusajs/framework": "2.10.2-preview-20250910090158",
82
+ "@medusajs/icons": "2.10.2-preview-20250910090158",
83
+ "@medusajs/test-utils": "2.10.2-preview-20250910090158",
84
+ "@medusajs/ui": "4.0.22-preview-20250910090158",
85
85
  "@mikro-orm/cli": "6.4.3",
86
86
  "@mikro-orm/core": "6.4.3",
87
87
  "@mikro-orm/knex": "6.4.3",