@medusajs/draft-order 2.10.2-preview-20250912120159 → 2.10.2-preview-20250912125034

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.
@@ -11432,112 +11432,6 @@ function getPromotionIds(items, shippingMethods) {
11432
11432
  }
11433
11433
  return Array.from(promotionIds);
11434
11434
  }
11435
- const SalesChannel = () => {
11436
- const { id } = reactRouterDom.useParams();
11437
- const { draft_order, isPending, isError, error } = useDraftOrder(
11438
- id,
11439
- {
11440
- fields: "+sales_channel_id"
11441
- },
11442
- {
11443
- enabled: !!id
11444
- }
11445
- );
11446
- if (isError) {
11447
- throw error;
11448
- }
11449
- const ISrEADY = !!draft_order && !isPending;
11450
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11451
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11452
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11453
- /* @__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" }) })
11454
- ] }),
11455
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11456
- ] });
11457
- };
11458
- const SalesChannelForm = ({ order }) => {
11459
- const form = reactHookForm.useForm({
11460
- defaultValues: {
11461
- sales_channel_id: order.sales_channel_id || ""
11462
- },
11463
- resolver: zod.zodResolver(schema$3)
11464
- });
11465
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11466
- const { handleSuccess } = useRouteModal();
11467
- const onSubmit = form.handleSubmit(async (data) => {
11468
- await mutateAsync(
11469
- {
11470
- sales_channel_id: data.sales_channel_id
11471
- },
11472
- {
11473
- onSuccess: () => {
11474
- ui.toast.success("Sales channel updated");
11475
- handleSuccess();
11476
- },
11477
- onError: (error) => {
11478
- ui.toast.error(error.message);
11479
- }
11480
- }
11481
- );
11482
- });
11483
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11484
- KeyboundForm,
11485
- {
11486
- className: "flex flex-1 flex-col overflow-hidden",
11487
- onSubmit,
11488
- children: [
11489
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11490
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11491
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11492
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11493
- ] }) })
11494
- ]
11495
- }
11496
- ) });
11497
- };
11498
- const SalesChannelField = ({ control, order }) => {
11499
- const salesChannels = useComboboxData({
11500
- queryFn: async (params) => {
11501
- return await sdk.admin.salesChannel.list(params);
11502
- },
11503
- queryKey: ["sales-channels"],
11504
- getOptions: (data) => {
11505
- return data.sales_channels.map((salesChannel) => ({
11506
- label: salesChannel.name,
11507
- value: salesChannel.id
11508
- }));
11509
- },
11510
- defaultValue: order.sales_channel_id || void 0
11511
- });
11512
- return /* @__PURE__ */ jsxRuntime.jsx(
11513
- Form$2.Field,
11514
- {
11515
- control,
11516
- name: "sales_channel_id",
11517
- render: ({ field }) => {
11518
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11519
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11520
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11521
- Combobox,
11522
- {
11523
- options: salesChannels.options,
11524
- fetchNextPage: salesChannels.fetchNextPage,
11525
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11526
- searchValue: salesChannels.searchValue,
11527
- onSearchValueChange: salesChannels.onSearchValueChange,
11528
- placeholder: "Select sales channel",
11529
- ...field
11530
- }
11531
- ) }),
11532
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11533
- ] });
11534
- }
11535
- }
11536
- );
11537
- };
11538
- const schema$3 = objectType({
11539
- sales_channel_id: stringType().min(1)
11540
- });
11541
11435
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11542
11436
  const Shipping = () => {
11543
11437
  var _a;
@@ -12377,7 +12271,7 @@ const ShippingAddressForm = ({ order }) => {
12377
12271
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12378
12272
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12379
12273
  },
12380
- resolver: zod.zodResolver(schema$2)
12274
+ resolver: zod.zodResolver(schema$3)
12381
12275
  });
12382
12276
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12383
12277
  const { handleSuccess } = useRouteModal();
@@ -12547,7 +12441,7 @@ const ShippingAddressForm = ({ order }) => {
12547
12441
  }
12548
12442
  ) });
12549
12443
  };
12550
- const schema$2 = addressSchema;
12444
+ const schema$3 = addressSchema;
12551
12445
  const TransferOwnership = () => {
12552
12446
  const { id } = reactRouterDom.useParams();
12553
12447
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12571,7 +12465,7 @@ const TransferOwnershipForm = ({ order }) => {
12571
12465
  defaultValues: {
12572
12466
  customer_id: order.customer_id || ""
12573
12467
  },
12574
- resolver: zod.zodResolver(schema$1)
12468
+ resolver: zod.zodResolver(schema$2)
12575
12469
  });
12576
12470
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12577
12471
  const { handleSuccess } = useRouteModal();
@@ -13021,7 +12915,7 @@ const Illustration = () => {
13021
12915
  }
13022
12916
  );
13023
12917
  };
13024
- const schema$1 = objectType({
12918
+ const schema$2 = objectType({
13025
12919
  customer_id: stringType().min(1)
13026
12920
  });
13027
12921
  const CustomItems = () => {
@@ -13032,7 +12926,7 @@ const CustomItems = () => {
13032
12926
  };
13033
12927
  const CustomItemsForm = () => {
13034
12928
  const form = reactHookForm.useForm({
13035
- resolver: zod.zodResolver(schema)
12929
+ resolver: zod.zodResolver(schema$1)
13036
12930
  });
13037
12931
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13038
12932
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -13042,9 +12936,115 @@ const CustomItemsForm = () => {
13042
12936
  ] }) })
13043
12937
  ] }) });
13044
12938
  };
13045
- const schema = objectType({
12939
+ const schema$1 = objectType({
13046
12940
  email: stringType().email()
13047
12941
  });
12942
+ const SalesChannel = () => {
12943
+ const { id } = reactRouterDom.useParams();
12944
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12945
+ id,
12946
+ {
12947
+ fields: "+sales_channel_id"
12948
+ },
12949
+ {
12950
+ enabled: !!id
12951
+ }
12952
+ );
12953
+ if (isError) {
12954
+ throw error;
12955
+ }
12956
+ const ISrEADY = !!draft_order && !isPending;
12957
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12958
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12959
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12960
+ /* @__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" }) })
12961
+ ] }),
12962
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12963
+ ] });
12964
+ };
12965
+ const SalesChannelForm = ({ order }) => {
12966
+ const form = reactHookForm.useForm({
12967
+ defaultValues: {
12968
+ sales_channel_id: order.sales_channel_id || ""
12969
+ },
12970
+ resolver: zod.zodResolver(schema)
12971
+ });
12972
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12973
+ const { handleSuccess } = useRouteModal();
12974
+ const onSubmit = form.handleSubmit(async (data) => {
12975
+ await mutateAsync(
12976
+ {
12977
+ sales_channel_id: data.sales_channel_id
12978
+ },
12979
+ {
12980
+ onSuccess: () => {
12981
+ ui.toast.success("Sales channel updated");
12982
+ handleSuccess();
12983
+ },
12984
+ onError: (error) => {
12985
+ ui.toast.error(error.message);
12986
+ }
12987
+ }
12988
+ );
12989
+ });
12990
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12991
+ KeyboundForm,
12992
+ {
12993
+ className: "flex flex-1 flex-col overflow-hidden",
12994
+ onSubmit,
12995
+ children: [
12996
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12997
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12998
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12999
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13000
+ ] }) })
13001
+ ]
13002
+ }
13003
+ ) });
13004
+ };
13005
+ const SalesChannelField = ({ control, order }) => {
13006
+ const salesChannels = useComboboxData({
13007
+ queryFn: async (params) => {
13008
+ return await sdk.admin.salesChannel.list(params);
13009
+ },
13010
+ queryKey: ["sales-channels"],
13011
+ getOptions: (data) => {
13012
+ return data.sales_channels.map((salesChannel) => ({
13013
+ label: salesChannel.name,
13014
+ value: salesChannel.id
13015
+ }));
13016
+ },
13017
+ defaultValue: order.sales_channel_id || void 0
13018
+ });
13019
+ return /* @__PURE__ */ jsxRuntime.jsx(
13020
+ Form$2.Field,
13021
+ {
13022
+ control,
13023
+ name: "sales_channel_id",
13024
+ render: ({ field }) => {
13025
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13026
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
13027
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
13028
+ Combobox,
13029
+ {
13030
+ options: salesChannels.options,
13031
+ fetchNextPage: salesChannels.fetchNextPage,
13032
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
13033
+ searchValue: salesChannels.searchValue,
13034
+ onSearchValueChange: salesChannels.onSearchValueChange,
13035
+ placeholder: "Select sales channel",
13036
+ ...field
13037
+ }
13038
+ ) }),
13039
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13040
+ ] });
13041
+ }
13042
+ }
13043
+ );
13044
+ };
13045
+ const schema = objectType({
13046
+ sales_channel_id: stringType().min(1)
13047
+ });
13048
13048
  const widgetModule = { widgets: [] };
13049
13049
  const routeModule = {
13050
13050
  routes: [
@@ -13085,10 +13085,6 @@ const routeModule = {
13085
13085
  Component: Promotions,
13086
13086
  path: "/draft-orders/:id/promotions"
13087
13087
  },
13088
- {
13089
- Component: SalesChannel,
13090
- path: "/draft-orders/:id/sales-channel"
13091
- },
13092
13088
  {
13093
13089
  Component: Shipping,
13094
13090
  path: "/draft-orders/:id/shipping"
@@ -13104,6 +13100,10 @@ const routeModule = {
13104
13100
  {
13105
13101
  Component: CustomItems,
13106
13102
  path: "/draft-orders/:id/custom-items"
13103
+ },
13104
+ {
13105
+ Component: SalesChannel,
13106
+ path: "/draft-orders/:id/sales-channel"
13107
13107
  }
13108
13108
  ]
13109
13109
  }
@@ -11426,112 +11426,6 @@ function getPromotionIds(items, shippingMethods) {
11426
11426
  }
11427
11427
  return Array.from(promotionIds);
11428
11428
  }
11429
- const SalesChannel = () => {
11430
- const { id } = useParams();
11431
- const { draft_order, isPending, isError, error } = useDraftOrder(
11432
- id,
11433
- {
11434
- fields: "+sales_channel_id"
11435
- },
11436
- {
11437
- enabled: !!id
11438
- }
11439
- );
11440
- if (isError) {
11441
- throw error;
11442
- }
11443
- const ISrEADY = !!draft_order && !isPending;
11444
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11445
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11446
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11447
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11448
- ] }),
11449
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11450
- ] });
11451
- };
11452
- const SalesChannelForm = ({ order }) => {
11453
- const form = useForm({
11454
- defaultValues: {
11455
- sales_channel_id: order.sales_channel_id || ""
11456
- },
11457
- resolver: zodResolver(schema$3)
11458
- });
11459
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11460
- const { handleSuccess } = useRouteModal();
11461
- const onSubmit = form.handleSubmit(async (data) => {
11462
- await mutateAsync(
11463
- {
11464
- sales_channel_id: data.sales_channel_id
11465
- },
11466
- {
11467
- onSuccess: () => {
11468
- toast.success("Sales channel updated");
11469
- handleSuccess();
11470
- },
11471
- onError: (error) => {
11472
- toast.error(error.message);
11473
- }
11474
- }
11475
- );
11476
- });
11477
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11478
- KeyboundForm,
11479
- {
11480
- className: "flex flex-1 flex-col overflow-hidden",
11481
- onSubmit,
11482
- children: [
11483
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11484
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11485
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11486
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11487
- ] }) })
11488
- ]
11489
- }
11490
- ) });
11491
- };
11492
- const SalesChannelField = ({ control, order }) => {
11493
- const salesChannels = useComboboxData({
11494
- queryFn: async (params) => {
11495
- return await sdk.admin.salesChannel.list(params);
11496
- },
11497
- queryKey: ["sales-channels"],
11498
- getOptions: (data) => {
11499
- return data.sales_channels.map((salesChannel) => ({
11500
- label: salesChannel.name,
11501
- value: salesChannel.id
11502
- }));
11503
- },
11504
- defaultValue: order.sales_channel_id || void 0
11505
- });
11506
- return /* @__PURE__ */ jsx(
11507
- Form$2.Field,
11508
- {
11509
- control,
11510
- name: "sales_channel_id",
11511
- render: ({ field }) => {
11512
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11513
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11514
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11515
- Combobox,
11516
- {
11517
- options: salesChannels.options,
11518
- fetchNextPage: salesChannels.fetchNextPage,
11519
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11520
- searchValue: salesChannels.searchValue,
11521
- onSearchValueChange: salesChannels.onSearchValueChange,
11522
- placeholder: "Select sales channel",
11523
- ...field
11524
- }
11525
- ) }),
11526
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11527
- ] });
11528
- }
11529
- }
11530
- );
11531
- };
11532
- const schema$3 = objectType({
11533
- sales_channel_id: stringType().min(1)
11534
- });
11535
11429
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11536
11430
  const Shipping = () => {
11537
11431
  var _a;
@@ -12371,7 +12265,7 @@ const ShippingAddressForm = ({ order }) => {
12371
12265
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12372
12266
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12373
12267
  },
12374
- resolver: zodResolver(schema$2)
12268
+ resolver: zodResolver(schema$3)
12375
12269
  });
12376
12270
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12377
12271
  const { handleSuccess } = useRouteModal();
@@ -12541,7 +12435,7 @@ const ShippingAddressForm = ({ order }) => {
12541
12435
  }
12542
12436
  ) });
12543
12437
  };
12544
- const schema$2 = addressSchema;
12438
+ const schema$3 = addressSchema;
12545
12439
  const TransferOwnership = () => {
12546
12440
  const { id } = useParams();
12547
12441
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12565,7 +12459,7 @@ const TransferOwnershipForm = ({ order }) => {
12565
12459
  defaultValues: {
12566
12460
  customer_id: order.customer_id || ""
12567
12461
  },
12568
- resolver: zodResolver(schema$1)
12462
+ resolver: zodResolver(schema$2)
12569
12463
  });
12570
12464
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12571
12465
  const { handleSuccess } = useRouteModal();
@@ -13015,7 +12909,7 @@ const Illustration = () => {
13015
12909
  }
13016
12910
  );
13017
12911
  };
13018
- const schema$1 = objectType({
12912
+ const schema$2 = objectType({
13019
12913
  customer_id: stringType().min(1)
13020
12914
  });
13021
12915
  const CustomItems = () => {
@@ -13026,7 +12920,7 @@ const CustomItems = () => {
13026
12920
  };
13027
12921
  const CustomItemsForm = () => {
13028
12922
  const form = useForm({
13029
- resolver: zodResolver(schema)
12923
+ resolver: zodResolver(schema$1)
13030
12924
  });
13031
12925
  return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13032
12926
  /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
@@ -13036,9 +12930,115 @@ const CustomItemsForm = () => {
13036
12930
  ] }) })
13037
12931
  ] }) });
13038
12932
  };
13039
- const schema = objectType({
12933
+ const schema$1 = objectType({
13040
12934
  email: stringType().email()
13041
12935
  });
12936
+ const SalesChannel = () => {
12937
+ const { id } = useParams();
12938
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12939
+ id,
12940
+ {
12941
+ fields: "+sales_channel_id"
12942
+ },
12943
+ {
12944
+ enabled: !!id
12945
+ }
12946
+ );
12947
+ if (isError) {
12948
+ throw error;
12949
+ }
12950
+ const ISrEADY = !!draft_order && !isPending;
12951
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12952
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12953
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12954
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12955
+ ] }),
12956
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12957
+ ] });
12958
+ };
12959
+ const SalesChannelForm = ({ order }) => {
12960
+ const form = useForm({
12961
+ defaultValues: {
12962
+ sales_channel_id: order.sales_channel_id || ""
12963
+ },
12964
+ resolver: zodResolver(schema)
12965
+ });
12966
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12967
+ const { handleSuccess } = useRouteModal();
12968
+ const onSubmit = form.handleSubmit(async (data) => {
12969
+ await mutateAsync(
12970
+ {
12971
+ sales_channel_id: data.sales_channel_id
12972
+ },
12973
+ {
12974
+ onSuccess: () => {
12975
+ toast.success("Sales channel updated");
12976
+ handleSuccess();
12977
+ },
12978
+ onError: (error) => {
12979
+ toast.error(error.message);
12980
+ }
12981
+ }
12982
+ );
12983
+ });
12984
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12985
+ KeyboundForm,
12986
+ {
12987
+ className: "flex flex-1 flex-col overflow-hidden",
12988
+ onSubmit,
12989
+ children: [
12990
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12991
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12992
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12993
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12994
+ ] }) })
12995
+ ]
12996
+ }
12997
+ ) });
12998
+ };
12999
+ const SalesChannelField = ({ control, order }) => {
13000
+ const salesChannels = useComboboxData({
13001
+ queryFn: async (params) => {
13002
+ return await sdk.admin.salesChannel.list(params);
13003
+ },
13004
+ queryKey: ["sales-channels"],
13005
+ getOptions: (data) => {
13006
+ return data.sales_channels.map((salesChannel) => ({
13007
+ label: salesChannel.name,
13008
+ value: salesChannel.id
13009
+ }));
13010
+ },
13011
+ defaultValue: order.sales_channel_id || void 0
13012
+ });
13013
+ return /* @__PURE__ */ jsx(
13014
+ Form$2.Field,
13015
+ {
13016
+ control,
13017
+ name: "sales_channel_id",
13018
+ render: ({ field }) => {
13019
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13020
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
13021
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
13022
+ Combobox,
13023
+ {
13024
+ options: salesChannels.options,
13025
+ fetchNextPage: salesChannels.fetchNextPage,
13026
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
13027
+ searchValue: salesChannels.searchValue,
13028
+ onSearchValueChange: salesChannels.onSearchValueChange,
13029
+ placeholder: "Select sales channel",
13030
+ ...field
13031
+ }
13032
+ ) }),
13033
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13034
+ ] });
13035
+ }
13036
+ }
13037
+ );
13038
+ };
13039
+ const schema = objectType({
13040
+ sales_channel_id: stringType().min(1)
13041
+ });
13042
13042
  const widgetModule = { widgets: [] };
13043
13043
  const routeModule = {
13044
13044
  routes: [
@@ -13079,10 +13079,6 @@ const routeModule = {
13079
13079
  Component: Promotions,
13080
13080
  path: "/draft-orders/:id/promotions"
13081
13081
  },
13082
- {
13083
- Component: SalesChannel,
13084
- path: "/draft-orders/:id/sales-channel"
13085
- },
13086
13082
  {
13087
13083
  Component: Shipping,
13088
13084
  path: "/draft-orders/:id/shipping"
@@ -13098,6 +13094,10 @@ const routeModule = {
13098
13094
  {
13099
13095
  Component: CustomItems,
13100
13096
  path: "/draft-orders/:id/custom-items"
13097
+ },
13098
+ {
13099
+ Component: SalesChannel,
13100
+ path: "/draft-orders/:id/sales-channel"
13101
13101
  }
13102
13102
  ]
13103
13103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.10.2-preview-20250912120159",
3
+ "version": "2.10.2-preview-20250912125034",
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-20250912120159",
39
+ "@medusajs/js-sdk": "2.10.2-preview-20250912125034",
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-20250912120159",
49
- "@medusajs/cli": "2.10.2-preview-20250912120159",
50
- "@medusajs/framework": "2.10.2-preview-20250912120159",
51
- "@medusajs/icons": "2.10.2-preview-20250912120159",
52
- "@medusajs/test-utils": "2.10.2-preview-20250912120159",
53
- "@medusajs/types": "2.10.2-preview-20250912120159",
54
- "@medusajs/ui": "4.0.22-preview-20250912120159",
55
- "@medusajs/ui-preset": "2.10.2-preview-20250912120159",
48
+ "@medusajs/admin-sdk": "2.10.2-preview-20250912125034",
49
+ "@medusajs/cli": "2.10.2-preview-20250912125034",
50
+ "@medusajs/framework": "2.10.2-preview-20250912125034",
51
+ "@medusajs/icons": "2.10.2-preview-20250912125034",
52
+ "@medusajs/test-utils": "2.10.2-preview-20250912125034",
53
+ "@medusajs/types": "2.10.2-preview-20250912125034",
54
+ "@medusajs/ui": "4.0.22-preview-20250912125034",
55
+ "@medusajs/ui-preset": "2.10.2-preview-20250912125034",
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-20250912120159",
80
- "@medusajs/cli": "2.10.2-preview-20250912120159",
81
- "@medusajs/framework": "2.10.2-preview-20250912120159",
82
- "@medusajs/icons": "2.10.2-preview-20250912120159",
83
- "@medusajs/test-utils": "2.10.2-preview-20250912120159",
84
- "@medusajs/ui": "4.0.22-preview-20250912120159",
79
+ "@medusajs/admin-sdk": "2.10.2-preview-20250912125034",
80
+ "@medusajs/cli": "2.10.2-preview-20250912125034",
81
+ "@medusajs/framework": "2.10.2-preview-20250912125034",
82
+ "@medusajs/icons": "2.10.2-preview-20250912125034",
83
+ "@medusajs/test-utils": "2.10.2-preview-20250912125034",
84
+ "@medusajs/ui": "4.0.22-preview-20250912125034",
85
85
  "@mikro-orm/cli": "6.4.3",
86
86
  "@mikro-orm/core": "6.4.3",
87
87
  "@mikro-orm/knex": "6.4.3",