@medusajs/draft-order 2.10.0-preview-20250827180155 → 2.10.0-preview-20250828000308

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.
@@ -9750,27 +9750,6 @@ const BillingAddressForm = ({ order }) => {
9750
9750
  ) });
9751
9751
  };
9752
9752
  const schema$5 = addressSchema;
9753
- const CustomItems = () => {
9754
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9755
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9756
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9757
- ] });
9758
- };
9759
- const CustomItemsForm = () => {
9760
- const form = reactHookForm.useForm({
9761
- resolver: zod.zodResolver(schema$4)
9762
- });
9763
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9764
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9765
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9766
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9767
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9768
- ] }) })
9769
- ] }) });
9770
- };
9771
- const schema$4 = objectType({
9772
- email: stringType().email()
9773
- });
9774
9753
  const Email = () => {
9775
9754
  const { id } = reactRouterDom.useParams();
9776
9755
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9793,7 +9772,7 @@ const EmailForm = ({ order }) => {
9793
9772
  defaultValues: {
9794
9773
  email: order.email ?? ""
9795
9774
  },
9796
- resolver: zod.zodResolver(schema$3)
9775
+ resolver: zod.zodResolver(schema$4)
9797
9776
  });
9798
9777
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9799
9778
  const { handleSuccess } = useRouteModal();
@@ -9836,6 +9815,27 @@ const EmailForm = ({ order }) => {
9836
9815
  }
9837
9816
  ) });
9838
9817
  };
9818
+ const schema$4 = objectType({
9819
+ email: stringType().email()
9820
+ });
9821
+ const CustomItems = () => {
9822
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9823
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9824
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9825
+ ] });
9826
+ };
9827
+ const CustomItemsForm = () => {
9828
+ const form = reactHookForm.useForm({
9829
+ resolver: zod.zodResolver(schema$3)
9830
+ });
9831
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9832
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9833
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9834
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9835
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9836
+ ] }) })
9837
+ ] }) });
9838
+ };
9839
9839
  const schema$3 = objectType({
9840
9840
  email: stringType().email()
9841
9841
  });
@@ -11440,6 +11440,112 @@ function getPromotionCodes(items, shippingMethods) {
11440
11440
  }
11441
11441
  return Array.from(codes);
11442
11442
  }
11443
+ const SalesChannel = () => {
11444
+ const { id } = reactRouterDom.useParams();
11445
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11446
+ id,
11447
+ {
11448
+ fields: "+sales_channel_id"
11449
+ },
11450
+ {
11451
+ enabled: !!id
11452
+ }
11453
+ );
11454
+ if (isError) {
11455
+ throw error;
11456
+ }
11457
+ const ISrEADY = !!draft_order && !isPending;
11458
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11459
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11460
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11461
+ /* @__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" }) })
11462
+ ] }),
11463
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11464
+ ] });
11465
+ };
11466
+ const SalesChannelForm = ({ order }) => {
11467
+ const form = reactHookForm.useForm({
11468
+ defaultValues: {
11469
+ sales_channel_id: order.sales_channel_id || ""
11470
+ },
11471
+ resolver: zod.zodResolver(schema$2)
11472
+ });
11473
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11474
+ const { handleSuccess } = useRouteModal();
11475
+ const onSubmit = form.handleSubmit(async (data) => {
11476
+ await mutateAsync(
11477
+ {
11478
+ sales_channel_id: data.sales_channel_id
11479
+ },
11480
+ {
11481
+ onSuccess: () => {
11482
+ ui.toast.success("Sales channel updated");
11483
+ handleSuccess();
11484
+ },
11485
+ onError: (error) => {
11486
+ ui.toast.error(error.message);
11487
+ }
11488
+ }
11489
+ );
11490
+ });
11491
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11492
+ KeyboundForm,
11493
+ {
11494
+ className: "flex flex-1 flex-col overflow-hidden",
11495
+ onSubmit,
11496
+ children: [
11497
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11498
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11499
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11500
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11501
+ ] }) })
11502
+ ]
11503
+ }
11504
+ ) });
11505
+ };
11506
+ const SalesChannelField = ({ control, order }) => {
11507
+ const salesChannels = useComboboxData({
11508
+ queryFn: async (params) => {
11509
+ return await sdk.admin.salesChannel.list(params);
11510
+ },
11511
+ queryKey: ["sales-channels"],
11512
+ getOptions: (data) => {
11513
+ return data.sales_channels.map((salesChannel) => ({
11514
+ label: salesChannel.name,
11515
+ value: salesChannel.id
11516
+ }));
11517
+ },
11518
+ defaultValue: order.sales_channel_id || void 0
11519
+ });
11520
+ return /* @__PURE__ */ jsxRuntime.jsx(
11521
+ Form$2.Field,
11522
+ {
11523
+ control,
11524
+ name: "sales_channel_id",
11525
+ render: ({ field }) => {
11526
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11527
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11528
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11529
+ Combobox,
11530
+ {
11531
+ options: salesChannels.options,
11532
+ fetchNextPage: salesChannels.fetchNextPage,
11533
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11534
+ searchValue: salesChannels.searchValue,
11535
+ onSearchValueChange: salesChannels.onSearchValueChange,
11536
+ placeholder: "Select sales channel",
11537
+ ...field
11538
+ }
11539
+ ) }),
11540
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11541
+ ] });
11542
+ }
11543
+ }
11544
+ );
11545
+ };
11546
+ const schema$2 = objectType({
11547
+ sales_channel_id: stringType().min(1)
11548
+ });
11443
11549
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11444
11550
  const Shipping = () => {
11445
11551
  var _a;
@@ -12279,7 +12385,7 @@ const ShippingAddressForm = ({ order }) => {
12279
12385
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12280
12386
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12281
12387
  },
12282
- resolver: zod.zodResolver(schema$2)
12388
+ resolver: zod.zodResolver(schema$1)
12283
12389
  });
12284
12390
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12285
12391
  const { handleSuccess } = useRouteModal();
@@ -12449,7 +12555,7 @@ const ShippingAddressForm = ({ order }) => {
12449
12555
  }
12450
12556
  ) });
12451
12557
  };
12452
- const schema$2 = addressSchema;
12558
+ const schema$1 = addressSchema;
12453
12559
  const TransferOwnership = () => {
12454
12560
  const { id } = reactRouterDom.useParams();
12455
12561
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12473,7 +12579,7 @@ const TransferOwnershipForm = ({ order }) => {
12473
12579
  defaultValues: {
12474
12580
  customer_id: order.customer_id || ""
12475
12581
  },
12476
- resolver: zod.zodResolver(schema$1)
12582
+ resolver: zod.zodResolver(schema)
12477
12583
  });
12478
12584
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12479
12585
  const { handleSuccess } = useRouteModal();
@@ -12923,114 +13029,8 @@ const Illustration = () => {
12923
13029
  }
12924
13030
  );
12925
13031
  };
12926
- const schema$1 = objectType({
12927
- customer_id: stringType().min(1)
12928
- });
12929
- const SalesChannel = () => {
12930
- const { id } = reactRouterDom.useParams();
12931
- const { draft_order, isPending, isError, error } = useDraftOrder(
12932
- id,
12933
- {
12934
- fields: "+sales_channel_id"
12935
- },
12936
- {
12937
- enabled: !!id
12938
- }
12939
- );
12940
- if (isError) {
12941
- throw error;
12942
- }
12943
- const ISrEADY = !!draft_order && !isPending;
12944
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12945
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12946
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12947
- /* @__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" }) })
12948
- ] }),
12949
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12950
- ] });
12951
- };
12952
- const SalesChannelForm = ({ order }) => {
12953
- const form = reactHookForm.useForm({
12954
- defaultValues: {
12955
- sales_channel_id: order.sales_channel_id || ""
12956
- },
12957
- resolver: zod.zodResolver(schema)
12958
- });
12959
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12960
- const { handleSuccess } = useRouteModal();
12961
- const onSubmit = form.handleSubmit(async (data) => {
12962
- await mutateAsync(
12963
- {
12964
- sales_channel_id: data.sales_channel_id
12965
- },
12966
- {
12967
- onSuccess: () => {
12968
- ui.toast.success("Sales channel updated");
12969
- handleSuccess();
12970
- },
12971
- onError: (error) => {
12972
- ui.toast.error(error.message);
12973
- }
12974
- }
12975
- );
12976
- });
12977
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12978
- KeyboundForm,
12979
- {
12980
- className: "flex flex-1 flex-col overflow-hidden",
12981
- onSubmit,
12982
- children: [
12983
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12984
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12985
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12986
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12987
- ] }) })
12988
- ]
12989
- }
12990
- ) });
12991
- };
12992
- const SalesChannelField = ({ control, order }) => {
12993
- const salesChannels = useComboboxData({
12994
- queryFn: async (params) => {
12995
- return await sdk.admin.salesChannel.list(params);
12996
- },
12997
- queryKey: ["sales-channels"],
12998
- getOptions: (data) => {
12999
- return data.sales_channels.map((salesChannel) => ({
13000
- label: salesChannel.name,
13001
- value: salesChannel.id
13002
- }));
13003
- },
13004
- defaultValue: order.sales_channel_id || void 0
13005
- });
13006
- return /* @__PURE__ */ jsxRuntime.jsx(
13007
- Form$2.Field,
13008
- {
13009
- control,
13010
- name: "sales_channel_id",
13011
- render: ({ field }) => {
13012
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13013
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
13014
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
13015
- Combobox,
13016
- {
13017
- options: salesChannels.options,
13018
- fetchNextPage: salesChannels.fetchNextPage,
13019
- isFetchingNextPage: salesChannels.isFetchingNextPage,
13020
- searchValue: salesChannels.searchValue,
13021
- onSearchValueChange: salesChannels.onSearchValueChange,
13022
- placeholder: "Select sales channel",
13023
- ...field
13024
- }
13025
- ) }),
13026
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13027
- ] });
13028
- }
13029
- }
13030
- );
13031
- };
13032
13032
  const schema = objectType({
13033
- sales_channel_id: stringType().min(1)
13033
+ customer_id: stringType().min(1)
13034
13034
  });
13035
13035
  const widgetModule = { widgets: [] };
13036
13036
  const routeModule = {
@@ -13056,14 +13056,14 @@ const routeModule = {
13056
13056
  Component: BillingAddress,
13057
13057
  path: "/draft-orders/:id/billing-address"
13058
13058
  },
13059
- {
13060
- Component: CustomItems,
13061
- path: "/draft-orders/:id/custom-items"
13062
- },
13063
13059
  {
13064
13060
  Component: Email,
13065
13061
  path: "/draft-orders/:id/email"
13066
13062
  },
13063
+ {
13064
+ Component: CustomItems,
13065
+ path: "/draft-orders/:id/custom-items"
13066
+ },
13067
13067
  {
13068
13068
  Component: Items,
13069
13069
  path: "/draft-orders/:id/items"
@@ -13076,6 +13076,10 @@ const routeModule = {
13076
13076
  Component: Promotions,
13077
13077
  path: "/draft-orders/:id/promotions"
13078
13078
  },
13079
+ {
13080
+ Component: SalesChannel,
13081
+ path: "/draft-orders/:id/sales-channel"
13082
+ },
13079
13083
  {
13080
13084
  Component: Shipping,
13081
13085
  path: "/draft-orders/:id/shipping"
@@ -13087,10 +13091,6 @@ const routeModule = {
13087
13091
  {
13088
13092
  Component: TransferOwnership,
13089
13093
  path: "/draft-orders/:id/transfer-ownership"
13090
- },
13091
- {
13092
- Component: SalesChannel,
13093
- path: "/draft-orders/:id/sales-channel"
13094
13094
  }
13095
13095
  ]
13096
13096
  }
@@ -9744,27 +9744,6 @@ const BillingAddressForm = ({ order }) => {
9744
9744
  ) });
9745
9745
  };
9746
9746
  const schema$5 = addressSchema;
9747
- const CustomItems = () => {
9748
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9749
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9750
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9751
- ] });
9752
- };
9753
- const CustomItemsForm = () => {
9754
- const form = useForm({
9755
- resolver: zodResolver(schema$4)
9756
- });
9757
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9758
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9759
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9760
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9761
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9762
- ] }) })
9763
- ] }) });
9764
- };
9765
- const schema$4 = objectType({
9766
- email: stringType().email()
9767
- });
9768
9747
  const Email = () => {
9769
9748
  const { id } = useParams();
9770
9749
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9787,7 +9766,7 @@ const EmailForm = ({ order }) => {
9787
9766
  defaultValues: {
9788
9767
  email: order.email ?? ""
9789
9768
  },
9790
- resolver: zodResolver(schema$3)
9769
+ resolver: zodResolver(schema$4)
9791
9770
  });
9792
9771
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9793
9772
  const { handleSuccess } = useRouteModal();
@@ -9830,6 +9809,27 @@ const EmailForm = ({ order }) => {
9830
9809
  }
9831
9810
  ) });
9832
9811
  };
9812
+ const schema$4 = objectType({
9813
+ email: stringType().email()
9814
+ });
9815
+ const CustomItems = () => {
9816
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9817
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9818
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9819
+ ] });
9820
+ };
9821
+ const CustomItemsForm = () => {
9822
+ const form = useForm({
9823
+ resolver: zodResolver(schema$3)
9824
+ });
9825
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9826
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9827
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9828
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9829
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9830
+ ] }) })
9831
+ ] }) });
9832
+ };
9833
9833
  const schema$3 = objectType({
9834
9834
  email: stringType().email()
9835
9835
  });
@@ -11434,6 +11434,112 @@ function getPromotionCodes(items, shippingMethods) {
11434
11434
  }
11435
11435
  return Array.from(codes);
11436
11436
  }
11437
+ const SalesChannel = () => {
11438
+ const { id } = useParams();
11439
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11440
+ id,
11441
+ {
11442
+ fields: "+sales_channel_id"
11443
+ },
11444
+ {
11445
+ enabled: !!id
11446
+ }
11447
+ );
11448
+ if (isError) {
11449
+ throw error;
11450
+ }
11451
+ const ISrEADY = !!draft_order && !isPending;
11452
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11453
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11454
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11455
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11456
+ ] }),
11457
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11458
+ ] });
11459
+ };
11460
+ const SalesChannelForm = ({ order }) => {
11461
+ const form = useForm({
11462
+ defaultValues: {
11463
+ sales_channel_id: order.sales_channel_id || ""
11464
+ },
11465
+ resolver: zodResolver(schema$2)
11466
+ });
11467
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11468
+ const { handleSuccess } = useRouteModal();
11469
+ const onSubmit = form.handleSubmit(async (data) => {
11470
+ await mutateAsync(
11471
+ {
11472
+ sales_channel_id: data.sales_channel_id
11473
+ },
11474
+ {
11475
+ onSuccess: () => {
11476
+ toast.success("Sales channel updated");
11477
+ handleSuccess();
11478
+ },
11479
+ onError: (error) => {
11480
+ toast.error(error.message);
11481
+ }
11482
+ }
11483
+ );
11484
+ });
11485
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11486
+ KeyboundForm,
11487
+ {
11488
+ className: "flex flex-1 flex-col overflow-hidden",
11489
+ onSubmit,
11490
+ children: [
11491
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11492
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11493
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11494
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11495
+ ] }) })
11496
+ ]
11497
+ }
11498
+ ) });
11499
+ };
11500
+ const SalesChannelField = ({ control, order }) => {
11501
+ const salesChannels = useComboboxData({
11502
+ queryFn: async (params) => {
11503
+ return await sdk.admin.salesChannel.list(params);
11504
+ },
11505
+ queryKey: ["sales-channels"],
11506
+ getOptions: (data) => {
11507
+ return data.sales_channels.map((salesChannel) => ({
11508
+ label: salesChannel.name,
11509
+ value: salesChannel.id
11510
+ }));
11511
+ },
11512
+ defaultValue: order.sales_channel_id || void 0
11513
+ });
11514
+ return /* @__PURE__ */ jsx(
11515
+ Form$2.Field,
11516
+ {
11517
+ control,
11518
+ name: "sales_channel_id",
11519
+ render: ({ field }) => {
11520
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11521
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11522
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11523
+ Combobox,
11524
+ {
11525
+ options: salesChannels.options,
11526
+ fetchNextPage: salesChannels.fetchNextPage,
11527
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11528
+ searchValue: salesChannels.searchValue,
11529
+ onSearchValueChange: salesChannels.onSearchValueChange,
11530
+ placeholder: "Select sales channel",
11531
+ ...field
11532
+ }
11533
+ ) }),
11534
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11535
+ ] });
11536
+ }
11537
+ }
11538
+ );
11539
+ };
11540
+ const schema$2 = objectType({
11541
+ sales_channel_id: stringType().min(1)
11542
+ });
11437
11543
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11438
11544
  const Shipping = () => {
11439
11545
  var _a;
@@ -12273,7 +12379,7 @@ const ShippingAddressForm = ({ order }) => {
12273
12379
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12274
12380
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12275
12381
  },
12276
- resolver: zodResolver(schema$2)
12382
+ resolver: zodResolver(schema$1)
12277
12383
  });
12278
12384
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12279
12385
  const { handleSuccess } = useRouteModal();
@@ -12443,7 +12549,7 @@ const ShippingAddressForm = ({ order }) => {
12443
12549
  }
12444
12550
  ) });
12445
12551
  };
12446
- const schema$2 = addressSchema;
12552
+ const schema$1 = addressSchema;
12447
12553
  const TransferOwnership = () => {
12448
12554
  const { id } = useParams();
12449
12555
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12467,7 +12573,7 @@ const TransferOwnershipForm = ({ order }) => {
12467
12573
  defaultValues: {
12468
12574
  customer_id: order.customer_id || ""
12469
12575
  },
12470
- resolver: zodResolver(schema$1)
12576
+ resolver: zodResolver(schema)
12471
12577
  });
12472
12578
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12473
12579
  const { handleSuccess } = useRouteModal();
@@ -12917,114 +13023,8 @@ const Illustration = () => {
12917
13023
  }
12918
13024
  );
12919
13025
  };
12920
- const schema$1 = objectType({
12921
- customer_id: stringType().min(1)
12922
- });
12923
- const SalesChannel = () => {
12924
- const { id } = useParams();
12925
- const { draft_order, isPending, isError, error } = useDraftOrder(
12926
- id,
12927
- {
12928
- fields: "+sales_channel_id"
12929
- },
12930
- {
12931
- enabled: !!id
12932
- }
12933
- );
12934
- if (isError) {
12935
- throw error;
12936
- }
12937
- const ISrEADY = !!draft_order && !isPending;
12938
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12939
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12940
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12941
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12942
- ] }),
12943
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12944
- ] });
12945
- };
12946
- const SalesChannelForm = ({ order }) => {
12947
- const form = useForm({
12948
- defaultValues: {
12949
- sales_channel_id: order.sales_channel_id || ""
12950
- },
12951
- resolver: zodResolver(schema)
12952
- });
12953
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12954
- const { handleSuccess } = useRouteModal();
12955
- const onSubmit = form.handleSubmit(async (data) => {
12956
- await mutateAsync(
12957
- {
12958
- sales_channel_id: data.sales_channel_id
12959
- },
12960
- {
12961
- onSuccess: () => {
12962
- toast.success("Sales channel updated");
12963
- handleSuccess();
12964
- },
12965
- onError: (error) => {
12966
- toast.error(error.message);
12967
- }
12968
- }
12969
- );
12970
- });
12971
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12972
- KeyboundForm,
12973
- {
12974
- className: "flex flex-1 flex-col overflow-hidden",
12975
- onSubmit,
12976
- children: [
12977
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12978
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12979
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12980
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12981
- ] }) })
12982
- ]
12983
- }
12984
- ) });
12985
- };
12986
- const SalesChannelField = ({ control, order }) => {
12987
- const salesChannels = useComboboxData({
12988
- queryFn: async (params) => {
12989
- return await sdk.admin.salesChannel.list(params);
12990
- },
12991
- queryKey: ["sales-channels"],
12992
- getOptions: (data) => {
12993
- return data.sales_channels.map((salesChannel) => ({
12994
- label: salesChannel.name,
12995
- value: salesChannel.id
12996
- }));
12997
- },
12998
- defaultValue: order.sales_channel_id || void 0
12999
- });
13000
- return /* @__PURE__ */ jsx(
13001
- Form$2.Field,
13002
- {
13003
- control,
13004
- name: "sales_channel_id",
13005
- render: ({ field }) => {
13006
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13007
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
13008
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
13009
- Combobox,
13010
- {
13011
- options: salesChannels.options,
13012
- fetchNextPage: salesChannels.fetchNextPage,
13013
- isFetchingNextPage: salesChannels.isFetchingNextPage,
13014
- searchValue: salesChannels.searchValue,
13015
- onSearchValueChange: salesChannels.onSearchValueChange,
13016
- placeholder: "Select sales channel",
13017
- ...field
13018
- }
13019
- ) }),
13020
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13021
- ] });
13022
- }
13023
- }
13024
- );
13025
- };
13026
13026
  const schema = objectType({
13027
- sales_channel_id: stringType().min(1)
13027
+ customer_id: stringType().min(1)
13028
13028
  });
13029
13029
  const widgetModule = { widgets: [] };
13030
13030
  const routeModule = {
@@ -13050,14 +13050,14 @@ const routeModule = {
13050
13050
  Component: BillingAddress,
13051
13051
  path: "/draft-orders/:id/billing-address"
13052
13052
  },
13053
- {
13054
- Component: CustomItems,
13055
- path: "/draft-orders/:id/custom-items"
13056
- },
13057
13053
  {
13058
13054
  Component: Email,
13059
13055
  path: "/draft-orders/:id/email"
13060
13056
  },
13057
+ {
13058
+ Component: CustomItems,
13059
+ path: "/draft-orders/:id/custom-items"
13060
+ },
13061
13061
  {
13062
13062
  Component: Items,
13063
13063
  path: "/draft-orders/:id/items"
@@ -13070,6 +13070,10 @@ const routeModule = {
13070
13070
  Component: Promotions,
13071
13071
  path: "/draft-orders/:id/promotions"
13072
13072
  },
13073
+ {
13074
+ Component: SalesChannel,
13075
+ path: "/draft-orders/:id/sales-channel"
13076
+ },
13073
13077
  {
13074
13078
  Component: Shipping,
13075
13079
  path: "/draft-orders/:id/shipping"
@@ -13081,10 +13085,6 @@ const routeModule = {
13081
13085
  {
13082
13086
  Component: TransferOwnership,
13083
13087
  path: "/draft-orders/:id/transfer-ownership"
13084
- },
13085
- {
13086
- Component: SalesChannel,
13087
- path: "/draft-orders/:id/sales-channel"
13088
13088
  }
13089
13089
  ]
13090
13090
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.10.0-preview-20250827180155",
3
+ "version": "2.10.0-preview-20250828000308",
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.0-preview-20250827180155",
39
+ "@medusajs/js-sdk": "2.10.0-preview-20250828000308",
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,15 +45,15 @@
45
45
  "react-hook-form": "7.49.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@medusajs/admin-sdk": "2.10.0-preview-20250827180155",
49
- "@medusajs/cli": "2.10.0-preview-20250827180155",
50
- "@medusajs/framework": "2.10.0-preview-20250827180155",
51
- "@medusajs/icons": "2.10.0-preview-20250827180155",
52
- "@medusajs/medusa": "2.10.0-preview-20250827180155",
53
- "@medusajs/test-utils": "2.10.0-preview-20250827180155",
54
- "@medusajs/types": "2.10.0-preview-20250827180155",
55
- "@medusajs/ui": "4.0.20-preview-20250827180155",
56
- "@medusajs/ui-preset": "2.10.0-preview-20250827180155",
48
+ "@medusajs/admin-sdk": "2.10.0-preview-20250828000308",
49
+ "@medusajs/cli": "2.10.0-preview-20250828000308",
50
+ "@medusajs/framework": "2.10.0-preview-20250828000308",
51
+ "@medusajs/icons": "2.10.0-preview-20250828000308",
52
+ "@medusajs/medusa": "2.10.0-preview-20250828000308",
53
+ "@medusajs/test-utils": "2.10.0-preview-20250828000308",
54
+ "@medusajs/types": "2.10.0-preview-20250828000308",
55
+ "@medusajs/ui": "4.0.20-preview-20250828000308",
56
+ "@medusajs/ui-preset": "2.10.0-preview-20250828000308",
57
57
  "@mikro-orm/cli": "6.4.3",
58
58
  "@mikro-orm/core": "6.4.3",
59
59
  "@mikro-orm/knex": "6.4.3",
@@ -77,13 +77,13 @@
77
77
  "yalc": "^1.0.0-pre.53"
78
78
  },
79
79
  "peerDependencies": {
80
- "@medusajs/admin-sdk": "2.10.0-preview-20250827180155",
81
- "@medusajs/cli": "2.10.0-preview-20250827180155",
82
- "@medusajs/framework": "2.10.0-preview-20250827180155",
83
- "@medusajs/icons": "2.10.0-preview-20250827180155",
84
- "@medusajs/medusa": "2.10.0-preview-20250827180155",
85
- "@medusajs/test-utils": "2.10.0-preview-20250827180155",
86
- "@medusajs/ui": "4.0.20-preview-20250827180155",
80
+ "@medusajs/admin-sdk": "2.10.0-preview-20250828000308",
81
+ "@medusajs/cli": "2.10.0-preview-20250828000308",
82
+ "@medusajs/framework": "2.10.0-preview-20250828000308",
83
+ "@medusajs/icons": "2.10.0-preview-20250828000308",
84
+ "@medusajs/medusa": "2.10.0-preview-20250828000308",
85
+ "@medusajs/test-utils": "2.10.0-preview-20250828000308",
86
+ "@medusajs/ui": "4.0.20-preview-20250828000308",
87
87
  "@mikro-orm/cli": "6.4.3",
88
88
  "@mikro-orm/core": "6.4.3",
89
89
  "@mikro-orm/knex": "6.4.3",