@medusajs/draft-order 2.10.2-preview-20250912060156 → 2.10.2-preview-20250912090157

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,23 +9763,70 @@ const BillingAddressForm = ({ order }) => {
9763
9763
  ) });
9764
9764
  };
9765
9765
  const schema$5 = addressSchema;
9766
- const CustomItems = () => {
9766
+ const Email = () => {
9767
+ const { id } = reactRouterDom.useParams();
9768
+ const { order, isPending, isError, error } = useOrder(id, {
9769
+ fields: "+email"
9770
+ });
9771
+ if (isError) {
9772
+ throw error;
9773
+ }
9774
+ const isReady = !isPending && !!order;
9767
9775
  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, {})
9776
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9777
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9778
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9779
+ ] }),
9780
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9770
9781
  ] });
9771
9782
  };
9772
- const CustomItemsForm = () => {
9783
+ const EmailForm = ({ order }) => {
9773
9784
  const form = reactHookForm.useForm({
9785
+ defaultValues: {
9786
+ email: order.email ?? ""
9787
+ },
9774
9788
  resolver: zod.zodResolver(schema$4)
9775
9789
  });
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
- ] }) });
9790
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9791
+ const { handleSuccess } = useRouteModal();
9792
+ const onSubmit = form.handleSubmit(async (data) => {
9793
+ await mutateAsync(
9794
+ { email: data.email },
9795
+ {
9796
+ onSuccess: () => {
9797
+ handleSuccess();
9798
+ },
9799
+ onError: (error) => {
9800
+ ui.toast.error(error.message);
9801
+ }
9802
+ }
9803
+ );
9804
+ });
9805
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9806
+ KeyboundForm,
9807
+ {
9808
+ className: "flex flex-1 flex-col overflow-hidden",
9809
+ onSubmit,
9810
+ children: [
9811
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9812
+ Form$2.Field,
9813
+ {
9814
+ control: form.control,
9815
+ name: "email",
9816
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9817
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9818
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9819
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9820
+ ] })
9821
+ }
9822
+ ) }),
9823
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9824
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9825
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9826
+ ] }) })
9827
+ ]
9828
+ }
9829
+ ) });
9783
9830
  };
9784
9831
  const schema$4 = objectType({
9785
9832
  email: stringType().email()
@@ -11385,112 +11432,6 @@ function getPromotionIds(items, shippingMethods) {
11385
11432
  }
11386
11433
  return Array.from(promotionIds);
11387
11434
  }
11388
- const SalesChannel = () => {
11389
- const { id } = reactRouterDom.useParams();
11390
- const { draft_order, isPending, isError, error } = useDraftOrder(
11391
- id,
11392
- {
11393
- fields: "+sales_channel_id"
11394
- },
11395
- {
11396
- enabled: !!id
11397
- }
11398
- );
11399
- if (isError) {
11400
- throw error;
11401
- }
11402
- const ISrEADY = !!draft_order && !isPending;
11403
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11404
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11405
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11406
- /* @__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" }) })
11407
- ] }),
11408
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11409
- ] });
11410
- };
11411
- const SalesChannelForm = ({ order }) => {
11412
- const form = reactHookForm.useForm({
11413
- defaultValues: {
11414
- sales_channel_id: order.sales_channel_id || ""
11415
- },
11416
- resolver: zod.zodResolver(schema$3)
11417
- });
11418
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11419
- const { handleSuccess } = useRouteModal();
11420
- const onSubmit = form.handleSubmit(async (data) => {
11421
- await mutateAsync(
11422
- {
11423
- sales_channel_id: data.sales_channel_id
11424
- },
11425
- {
11426
- onSuccess: () => {
11427
- ui.toast.success("Sales channel updated");
11428
- handleSuccess();
11429
- },
11430
- onError: (error) => {
11431
- ui.toast.error(error.message);
11432
- }
11433
- }
11434
- );
11435
- });
11436
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11437
- KeyboundForm,
11438
- {
11439
- className: "flex flex-1 flex-col overflow-hidden",
11440
- onSubmit,
11441
- children: [
11442
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11443
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11444
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11445
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11446
- ] }) })
11447
- ]
11448
- }
11449
- ) });
11450
- };
11451
- const SalesChannelField = ({ control, order }) => {
11452
- const salesChannels = useComboboxData({
11453
- queryFn: async (params) => {
11454
- return await sdk.admin.salesChannel.list(params);
11455
- },
11456
- queryKey: ["sales-channels"],
11457
- getOptions: (data) => {
11458
- return data.sales_channels.map((salesChannel) => ({
11459
- label: salesChannel.name,
11460
- value: salesChannel.id
11461
- }));
11462
- },
11463
- defaultValue: order.sales_channel_id || void 0
11464
- });
11465
- return /* @__PURE__ */ jsxRuntime.jsx(
11466
- Form$2.Field,
11467
- {
11468
- control,
11469
- name: "sales_channel_id",
11470
- render: ({ field }) => {
11471
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11472
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11473
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11474
- Combobox,
11475
- {
11476
- options: salesChannels.options,
11477
- fetchNextPage: salesChannels.fetchNextPage,
11478
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11479
- searchValue: salesChannels.searchValue,
11480
- onSearchValueChange: salesChannels.onSearchValueChange,
11481
- placeholder: "Select sales channel",
11482
- ...field
11483
- }
11484
- ) }),
11485
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11486
- ] });
11487
- }
11488
- }
11489
- );
11490
- };
11491
- const schema$3 = objectType({
11492
- sales_channel_id: stringType().min(1)
11493
- });
11494
11435
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11495
11436
  const Shipping = () => {
11496
11437
  var _a;
@@ -12330,7 +12271,7 @@ const ShippingAddressForm = ({ order }) => {
12330
12271
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12331
12272
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12332
12273
  },
12333
- resolver: zod.zodResolver(schema$2)
12274
+ resolver: zod.zodResolver(schema$3)
12334
12275
  });
12335
12276
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12336
12277
  const { handleSuccess } = useRouteModal();
@@ -12500,7 +12441,7 @@ const ShippingAddressForm = ({ order }) => {
12500
12441
  }
12501
12442
  ) });
12502
12443
  };
12503
- const schema$2 = addressSchema;
12444
+ const schema$3 = addressSchema;
12504
12445
  const TransferOwnership = () => {
12505
12446
  const { id } = reactRouterDom.useParams();
12506
12447
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12524,7 +12465,7 @@ const TransferOwnershipForm = ({ order }) => {
12524
12465
  defaultValues: {
12525
12466
  customer_id: order.customer_id || ""
12526
12467
  },
12527
- resolver: zod.zodResolver(schema$1)
12468
+ resolver: zod.zodResolver(schema$2)
12528
12469
  });
12529
12470
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12530
12471
  const { handleSuccess } = useRouteModal();
@@ -12974,30 +12915,57 @@ const Illustration = () => {
12974
12915
  }
12975
12916
  );
12976
12917
  };
12977
- const schema$1 = objectType({
12918
+ const schema$2 = objectType({
12978
12919
  customer_id: stringType().min(1)
12979
12920
  });
12980
- const Email = () => {
12981
- const { id } = reactRouterDom.useParams();
12982
- const { order, isPending, isError, error } = useOrder(id, {
12983
- fields: "+email"
12921
+ const CustomItems = () => {
12922
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12923
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
12924
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
12925
+ ] });
12926
+ };
12927
+ const CustomItemsForm = () => {
12928
+ const form = reactHookForm.useForm({
12929
+ resolver: zod.zodResolver(schema$1)
12984
12930
  });
12931
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
12932
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
12933
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12934
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12935
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
12936
+ ] }) })
12937
+ ] }) });
12938
+ };
12939
+ const schema$1 = objectType({
12940
+ email: stringType().email()
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
+ );
12985
12953
  if (isError) {
12986
12954
  throw error;
12987
12955
  }
12988
- const isReady = !isPending && !!order;
12956
+ const ISrEADY = !!draft_order && !isPending;
12989
12957
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12990
12958
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12991
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
12992
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
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" }) })
12993
12961
  ] }),
12994
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
12962
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12995
12963
  ] });
12996
12964
  };
12997
- const EmailForm = ({ order }) => {
12965
+ const SalesChannelForm = ({ order }) => {
12998
12966
  const form = reactHookForm.useForm({
12999
12967
  defaultValues: {
13000
- email: order.email ?? ""
12968
+ sales_channel_id: order.sales_channel_id || ""
13001
12969
  },
13002
12970
  resolver: zod.zodResolver(schema)
13003
12971
  });
@@ -13005,9 +12973,12 @@ const EmailForm = ({ order }) => {
13005
12973
  const { handleSuccess } = useRouteModal();
13006
12974
  const onSubmit = form.handleSubmit(async (data) => {
13007
12975
  await mutateAsync(
13008
- { email: data.email },
12976
+ {
12977
+ sales_channel_id: data.sales_channel_id
12978
+ },
13009
12979
  {
13010
12980
  onSuccess: () => {
12981
+ ui.toast.success("Sales channel updated");
13011
12982
  handleSuccess();
13012
12983
  },
13013
12984
  onError: (error) => {
@@ -13022,18 +12993,7 @@ const EmailForm = ({ order }) => {
13022
12993
  className: "flex flex-1 flex-col overflow-hidden",
13023
12994
  onSubmit,
13024
12995
  children: [
13025
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
13026
- Form$2.Field,
13027
- {
13028
- control: form.control,
13029
- name: "email",
13030
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13031
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
13032
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13033
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13034
- ] })
13035
- }
13036
- ) }),
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 }) }),
13037
12997
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13038
12998
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13039
12999
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -13042,8 +13002,48 @@ const EmailForm = ({ order }) => {
13042
13002
  }
13043
13003
  ) });
13044
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
13045
  const schema = objectType({
13046
- email: stringType().email()
13046
+ sales_channel_id: stringType().min(1)
13047
13047
  });
13048
13048
  const widgetModule = { widgets: [] };
13049
13049
  const routeModule = {
@@ -13070,8 +13070,8 @@ const routeModule = {
13070
13070
  path: "/draft-orders/:id/billing-address"
13071
13071
  },
13072
13072
  {
13073
- Component: CustomItems,
13074
- path: "/draft-orders/:id/custom-items"
13073
+ Component: Email,
13074
+ path: "/draft-orders/:id/email"
13075
13075
  },
13076
13076
  {
13077
13077
  Component: Items,
@@ -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"
@@ -13102,8 +13098,12 @@ const routeModule = {
13102
13098
  path: "/draft-orders/:id/transfer-ownership"
13103
13099
  },
13104
13100
  {
13105
- Component: Email,
13106
- path: "/draft-orders/:id/email"
13101
+ Component: CustomItems,
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
  }
@@ -9757,23 +9757,70 @@ const BillingAddressForm = ({ order }) => {
9757
9757
  ) });
9758
9758
  };
9759
9759
  const schema$5 = addressSchema;
9760
- const CustomItems = () => {
9760
+ const Email = () => {
9761
+ const { id } = useParams();
9762
+ const { order, isPending, isError, error } = useOrder(id, {
9763
+ fields: "+email"
9764
+ });
9765
+ if (isError) {
9766
+ throw error;
9767
+ }
9768
+ const isReady = !isPending && !!order;
9761
9769
  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, {})
9770
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9771
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
9772
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9773
+ ] }),
9774
+ isReady && /* @__PURE__ */ jsx(EmailForm, { order })
9764
9775
  ] });
9765
9776
  };
9766
- const CustomItemsForm = () => {
9777
+ const EmailForm = ({ order }) => {
9767
9778
  const form = useForm({
9779
+ defaultValues: {
9780
+ email: order.email ?? ""
9781
+ },
9768
9782
  resolver: zodResolver(schema$4)
9769
9783
  });
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
- ] }) });
9784
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9785
+ const { handleSuccess } = useRouteModal();
9786
+ const onSubmit = form.handleSubmit(async (data) => {
9787
+ await mutateAsync(
9788
+ { email: data.email },
9789
+ {
9790
+ onSuccess: () => {
9791
+ handleSuccess();
9792
+ },
9793
+ onError: (error) => {
9794
+ toast.error(error.message);
9795
+ }
9796
+ }
9797
+ );
9798
+ });
9799
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9800
+ KeyboundForm,
9801
+ {
9802
+ className: "flex flex-1 flex-col overflow-hidden",
9803
+ onSubmit,
9804
+ children: [
9805
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
9806
+ Form$2.Field,
9807
+ {
9808
+ control: form.control,
9809
+ name: "email",
9810
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9811
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
9812
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9813
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9814
+ ] })
9815
+ }
9816
+ ) }),
9817
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9818
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9819
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9820
+ ] }) })
9821
+ ]
9822
+ }
9823
+ ) });
9777
9824
  };
9778
9825
  const schema$4 = objectType({
9779
9826
  email: stringType().email()
@@ -11379,112 +11426,6 @@ function getPromotionIds(items, shippingMethods) {
11379
11426
  }
11380
11427
  return Array.from(promotionIds);
11381
11428
  }
11382
- const SalesChannel = () => {
11383
- const { id } = useParams();
11384
- const { draft_order, isPending, isError, error } = useDraftOrder(
11385
- id,
11386
- {
11387
- fields: "+sales_channel_id"
11388
- },
11389
- {
11390
- enabled: !!id
11391
- }
11392
- );
11393
- if (isError) {
11394
- throw error;
11395
- }
11396
- const ISrEADY = !!draft_order && !isPending;
11397
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11398
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11399
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11400
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11401
- ] }),
11402
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11403
- ] });
11404
- };
11405
- const SalesChannelForm = ({ order }) => {
11406
- const form = useForm({
11407
- defaultValues: {
11408
- sales_channel_id: order.sales_channel_id || ""
11409
- },
11410
- resolver: zodResolver(schema$3)
11411
- });
11412
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11413
- const { handleSuccess } = useRouteModal();
11414
- const onSubmit = form.handleSubmit(async (data) => {
11415
- await mutateAsync(
11416
- {
11417
- sales_channel_id: data.sales_channel_id
11418
- },
11419
- {
11420
- onSuccess: () => {
11421
- toast.success("Sales channel updated");
11422
- handleSuccess();
11423
- },
11424
- onError: (error) => {
11425
- toast.error(error.message);
11426
- }
11427
- }
11428
- );
11429
- });
11430
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11431
- KeyboundForm,
11432
- {
11433
- className: "flex flex-1 flex-col overflow-hidden",
11434
- onSubmit,
11435
- children: [
11436
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11437
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11438
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11439
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11440
- ] }) })
11441
- ]
11442
- }
11443
- ) });
11444
- };
11445
- const SalesChannelField = ({ control, order }) => {
11446
- const salesChannels = useComboboxData({
11447
- queryFn: async (params) => {
11448
- return await sdk.admin.salesChannel.list(params);
11449
- },
11450
- queryKey: ["sales-channels"],
11451
- getOptions: (data) => {
11452
- return data.sales_channels.map((salesChannel) => ({
11453
- label: salesChannel.name,
11454
- value: salesChannel.id
11455
- }));
11456
- },
11457
- defaultValue: order.sales_channel_id || void 0
11458
- });
11459
- return /* @__PURE__ */ jsx(
11460
- Form$2.Field,
11461
- {
11462
- control,
11463
- name: "sales_channel_id",
11464
- render: ({ field }) => {
11465
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11466
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11467
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11468
- Combobox,
11469
- {
11470
- options: salesChannels.options,
11471
- fetchNextPage: salesChannels.fetchNextPage,
11472
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11473
- searchValue: salesChannels.searchValue,
11474
- onSearchValueChange: salesChannels.onSearchValueChange,
11475
- placeholder: "Select sales channel",
11476
- ...field
11477
- }
11478
- ) }),
11479
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11480
- ] });
11481
- }
11482
- }
11483
- );
11484
- };
11485
- const schema$3 = objectType({
11486
- sales_channel_id: stringType().min(1)
11487
- });
11488
11429
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11489
11430
  const Shipping = () => {
11490
11431
  var _a;
@@ -12324,7 +12265,7 @@ const ShippingAddressForm = ({ order }) => {
12324
12265
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12325
12266
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12326
12267
  },
12327
- resolver: zodResolver(schema$2)
12268
+ resolver: zodResolver(schema$3)
12328
12269
  });
12329
12270
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12330
12271
  const { handleSuccess } = useRouteModal();
@@ -12494,7 +12435,7 @@ const ShippingAddressForm = ({ order }) => {
12494
12435
  }
12495
12436
  ) });
12496
12437
  };
12497
- const schema$2 = addressSchema;
12438
+ const schema$3 = addressSchema;
12498
12439
  const TransferOwnership = () => {
12499
12440
  const { id } = useParams();
12500
12441
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12518,7 +12459,7 @@ const TransferOwnershipForm = ({ order }) => {
12518
12459
  defaultValues: {
12519
12460
  customer_id: order.customer_id || ""
12520
12461
  },
12521
- resolver: zodResolver(schema$1)
12462
+ resolver: zodResolver(schema$2)
12522
12463
  });
12523
12464
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12524
12465
  const { handleSuccess } = useRouteModal();
@@ -12968,30 +12909,57 @@ const Illustration = () => {
12968
12909
  }
12969
12910
  );
12970
12911
  };
12971
- const schema$1 = objectType({
12912
+ const schema$2 = objectType({
12972
12913
  customer_id: stringType().min(1)
12973
12914
  });
12974
- const Email = () => {
12975
- const { id } = useParams();
12976
- const { order, isPending, isError, error } = useOrder(id, {
12977
- fields: "+email"
12915
+ const CustomItems = () => {
12916
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12917
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
12918
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
12919
+ ] });
12920
+ };
12921
+ const CustomItemsForm = () => {
12922
+ const form = useForm({
12923
+ resolver: zodResolver(schema$1)
12978
12924
  });
12925
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
12926
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
12927
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12928
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12929
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
12930
+ ] }) })
12931
+ ] }) });
12932
+ };
12933
+ const schema$1 = objectType({
12934
+ email: stringType().email()
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
+ );
12979
12947
  if (isError) {
12980
12948
  throw error;
12981
12949
  }
12982
- const isReady = !isPending && !!order;
12950
+ const ISrEADY = !!draft_order && !isPending;
12983
12951
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12984
12952
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12985
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
12986
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
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" }) })
12987
12955
  ] }),
12988
- isReady && /* @__PURE__ */ jsx(EmailForm, { order })
12956
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12989
12957
  ] });
12990
12958
  };
12991
- const EmailForm = ({ order }) => {
12959
+ const SalesChannelForm = ({ order }) => {
12992
12960
  const form = useForm({
12993
12961
  defaultValues: {
12994
- email: order.email ?? ""
12962
+ sales_channel_id: order.sales_channel_id || ""
12995
12963
  },
12996
12964
  resolver: zodResolver(schema)
12997
12965
  });
@@ -12999,9 +12967,12 @@ const EmailForm = ({ order }) => {
12999
12967
  const { handleSuccess } = useRouteModal();
13000
12968
  const onSubmit = form.handleSubmit(async (data) => {
13001
12969
  await mutateAsync(
13002
- { email: data.email },
12970
+ {
12971
+ sales_channel_id: data.sales_channel_id
12972
+ },
13003
12973
  {
13004
12974
  onSuccess: () => {
12975
+ toast.success("Sales channel updated");
13005
12976
  handleSuccess();
13006
12977
  },
13007
12978
  onError: (error) => {
@@ -13016,18 +12987,7 @@ const EmailForm = ({ order }) => {
13016
12987
  className: "flex flex-1 flex-col overflow-hidden",
13017
12988
  onSubmit,
13018
12989
  children: [
13019
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
13020
- Form$2.Field,
13021
- {
13022
- control: form.control,
13023
- name: "email",
13024
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13025
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
13026
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13027
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13028
- ] })
13029
- }
13030
- ) }),
12990
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
13031
12991
  /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13032
12992
  /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13033
12993
  /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -13036,8 +12996,48 @@ const EmailForm = ({ order }) => {
13036
12996
  }
13037
12997
  ) });
13038
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
13039
  const schema = objectType({
13040
- email: stringType().email()
13040
+ sales_channel_id: stringType().min(1)
13041
13041
  });
13042
13042
  const widgetModule = { widgets: [] };
13043
13043
  const routeModule = {
@@ -13064,8 +13064,8 @@ const routeModule = {
13064
13064
  path: "/draft-orders/:id/billing-address"
13065
13065
  },
13066
13066
  {
13067
- Component: CustomItems,
13068
- path: "/draft-orders/:id/custom-items"
13067
+ Component: Email,
13068
+ path: "/draft-orders/:id/email"
13069
13069
  },
13070
13070
  {
13071
13071
  Component: Items,
@@ -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"
@@ -13096,8 +13092,12 @@ const routeModule = {
13096
13092
  path: "/draft-orders/:id/transfer-ownership"
13097
13093
  },
13098
13094
  {
13099
- Component: Email,
13100
- path: "/draft-orders/:id/email"
13095
+ Component: CustomItems,
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-20250912060156",
3
+ "version": "2.10.2-preview-20250912090157",
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-20250912060156",
39
+ "@medusajs/js-sdk": "2.10.2-preview-20250912090157",
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-20250912060156",
49
- "@medusajs/cli": "2.10.2-preview-20250912060156",
50
- "@medusajs/framework": "2.10.2-preview-20250912060156",
51
- "@medusajs/icons": "2.10.2-preview-20250912060156",
52
- "@medusajs/test-utils": "2.10.2-preview-20250912060156",
53
- "@medusajs/types": "2.10.2-preview-20250912060156",
54
- "@medusajs/ui": "4.0.22-preview-20250912060156",
55
- "@medusajs/ui-preset": "2.10.2-preview-20250912060156",
48
+ "@medusajs/admin-sdk": "2.10.2-preview-20250912090157",
49
+ "@medusajs/cli": "2.10.2-preview-20250912090157",
50
+ "@medusajs/framework": "2.10.2-preview-20250912090157",
51
+ "@medusajs/icons": "2.10.2-preview-20250912090157",
52
+ "@medusajs/test-utils": "2.10.2-preview-20250912090157",
53
+ "@medusajs/types": "2.10.2-preview-20250912090157",
54
+ "@medusajs/ui": "4.0.22-preview-20250912090157",
55
+ "@medusajs/ui-preset": "2.10.2-preview-20250912090157",
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-20250912060156",
80
- "@medusajs/cli": "2.10.2-preview-20250912060156",
81
- "@medusajs/framework": "2.10.2-preview-20250912060156",
82
- "@medusajs/icons": "2.10.2-preview-20250912060156",
83
- "@medusajs/test-utils": "2.10.2-preview-20250912060156",
84
- "@medusajs/ui": "4.0.22-preview-20250912060156",
79
+ "@medusajs/admin-sdk": "2.10.2-preview-20250912090157",
80
+ "@medusajs/cli": "2.10.2-preview-20250912090157",
81
+ "@medusajs/framework": "2.10.2-preview-20250912090157",
82
+ "@medusajs/icons": "2.10.2-preview-20250912090157",
83
+ "@medusajs/test-utils": "2.10.2-preview-20250912090157",
84
+ "@medusajs/ui": "4.0.22-preview-20250912090157",
85
85
  "@mikro-orm/cli": "6.4.3",
86
86
  "@mikro-orm/core": "6.4.3",
87
87
  "@mikro-orm/knex": "6.4.3",