@medusajs/draft-order 2.14.2 → 2.14.3-preview-20260504001529

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.
@@ -9899,6 +9899,27 @@ const ID = () => {
9899
9899
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9900
9900
  ] });
9901
9901
  };
9902
+ const CustomItems = () => {
9903
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9904
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9905
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9906
+ ] });
9907
+ };
9908
+ const CustomItemsForm = () => {
9909
+ const form = reactHookForm.useForm({
9910
+ resolver: zod.zodResolver(schema$5)
9911
+ });
9912
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9913
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9914
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9915
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9916
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9917
+ ] }) })
9918
+ ] }) });
9919
+ };
9920
+ const schema$5 = object({
9921
+ email: string().email()
9922
+ });
9902
9923
  const BillingAddress = () => {
9903
9924
  const { id } = reactRouterDom.useParams();
9904
9925
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9931,7 +9952,7 @@ const BillingAddressForm = ({ order }) => {
9931
9952
  postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9932
9953
  phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9933
9954
  },
9934
- resolver: zod.zodResolver(schema$5)
9955
+ resolver: zod.zodResolver(schema$4)
9935
9956
  });
9936
9957
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9937
9958
  const { handleSuccess } = useRouteModal();
@@ -10088,28 +10109,7 @@ const BillingAddressForm = ({ order }) => {
10088
10109
  }
10089
10110
  ) });
10090
10111
  };
10091
- const schema$5 = addressSchema;
10092
- const CustomItems = () => {
10093
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10094
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
10095
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
10096
- ] });
10097
- };
10098
- const CustomItemsForm = () => {
10099
- const form = reactHookForm.useForm({
10100
- resolver: zod.zodResolver(schema$4)
10101
- });
10102
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
10103
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
10104
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10105
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10106
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
10107
- ] }) })
10108
- ] }) });
10109
- };
10110
- const schema$4 = object({
10111
- email: string().email()
10112
- });
10112
+ const schema$4 = addressSchema;
10113
10113
  const Email = () => {
10114
10114
  const { id } = reactRouterDom.useParams();
10115
10115
  const { order, isPending, isError, error } = useOrder(id, {
@@ -11779,112 +11779,6 @@ function getPromotionIds(items, shippingMethods) {
11779
11779
  }
11780
11780
  return Array.from(promotionIds);
11781
11781
  }
11782
- const SalesChannel = () => {
11783
- const { id } = reactRouterDom.useParams();
11784
- const { draft_order, isPending, isError, error } = useDraftOrder(
11785
- id,
11786
- {
11787
- fields: "+sales_channel_id"
11788
- },
11789
- {
11790
- enabled: !!id
11791
- }
11792
- );
11793
- if (isError) {
11794
- throw error;
11795
- }
11796
- const ISrEADY = !!draft_order && !isPending;
11797
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11798
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11799
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11800
- /* @__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" }) })
11801
- ] }),
11802
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11803
- ] });
11804
- };
11805
- const SalesChannelForm = ({ order }) => {
11806
- const form = reactHookForm.useForm({
11807
- defaultValues: {
11808
- sales_channel_id: order.sales_channel_id || ""
11809
- },
11810
- resolver: zod.zodResolver(schema$2)
11811
- });
11812
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11813
- const { handleSuccess } = useRouteModal();
11814
- const onSubmit = form.handleSubmit(async (data) => {
11815
- await mutateAsync(
11816
- {
11817
- sales_channel_id: data.sales_channel_id
11818
- },
11819
- {
11820
- onSuccess: () => {
11821
- ui.toast.success("Sales channel updated");
11822
- handleSuccess();
11823
- },
11824
- onError: (error) => {
11825
- ui.toast.error(error.message);
11826
- }
11827
- }
11828
- );
11829
- });
11830
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11831
- KeyboundForm,
11832
- {
11833
- className: "flex flex-1 flex-col overflow-hidden",
11834
- onSubmit,
11835
- children: [
11836
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11837
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11838
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11839
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11840
- ] }) })
11841
- ]
11842
- }
11843
- ) });
11844
- };
11845
- const SalesChannelField = ({ control, order }) => {
11846
- const salesChannels = useComboboxData({
11847
- queryFn: async (params) => {
11848
- return await sdk.admin.salesChannel.list(params);
11849
- },
11850
- queryKey: ["sales-channels"],
11851
- getOptions: (data) => {
11852
- return data.sales_channels.map((salesChannel) => ({
11853
- label: salesChannel.name,
11854
- value: salesChannel.id
11855
- }));
11856
- },
11857
- defaultValue: order.sales_channel_id || void 0
11858
- });
11859
- return /* @__PURE__ */ jsxRuntime.jsx(
11860
- Form$2.Field,
11861
- {
11862
- control,
11863
- name: "sales_channel_id",
11864
- render: ({ field }) => {
11865
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11866
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11867
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11868
- Combobox,
11869
- {
11870
- options: salesChannels.options,
11871
- fetchNextPage: salesChannels.fetchNextPage,
11872
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11873
- searchValue: salesChannels.searchValue,
11874
- onSearchValueChange: salesChannels.onSearchValueChange,
11875
- placeholder: "Select sales channel",
11876
- ...field
11877
- }
11878
- ) }),
11879
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11880
- ] });
11881
- }
11882
- }
11883
- );
11884
- };
11885
- const schema$2 = object({
11886
- sales_channel_id: string().min(1)
11887
- });
11888
11782
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11889
11783
  const Shipping = () => {
11890
11784
  var _a2;
@@ -12724,7 +12618,7 @@ const ShippingAddressForm = ({ order }) => {
12724
12618
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12725
12619
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12726
12620
  },
12727
- resolver: zod.zodResolver(schema$1)
12621
+ resolver: zod.zodResolver(schema$2)
12728
12622
  });
12729
12623
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12730
12624
  const { handleSuccess } = useRouteModal();
@@ -12894,7 +12788,7 @@ const ShippingAddressForm = ({ order }) => {
12894
12788
  }
12895
12789
  ) });
12896
12790
  };
12897
- const schema$1 = addressSchema;
12791
+ const schema$2 = addressSchema;
12898
12792
  const TransferOwnership = () => {
12899
12793
  const { id } = reactRouterDom.useParams();
12900
12794
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12918,7 +12812,7 @@ const TransferOwnershipForm = ({ order }) => {
12918
12812
  defaultValues: {
12919
12813
  customer_id: order.customer_id || ""
12920
12814
  },
12921
- resolver: zod.zodResolver(schema)
12815
+ resolver: zod.zodResolver(schema$1)
12922
12816
  });
12923
12817
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12924
12818
  const { handleSuccess } = useRouteModal();
@@ -13368,9 +13262,115 @@ const Illustration = () => {
13368
13262
  }
13369
13263
  );
13370
13264
  };
13371
- const schema = object({
13265
+ const schema$1 = object({
13372
13266
  customer_id: string().min(1)
13373
13267
  });
13268
+ const SalesChannel = () => {
13269
+ const { id } = reactRouterDom.useParams();
13270
+ const { draft_order, isPending, isError, error } = useDraftOrder(
13271
+ id,
13272
+ {
13273
+ fields: "+sales_channel_id"
13274
+ },
13275
+ {
13276
+ enabled: !!id
13277
+ }
13278
+ );
13279
+ if (isError) {
13280
+ throw error;
13281
+ }
13282
+ const ISrEADY = !!draft_order && !isPending;
13283
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
13284
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
13285
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
13286
+ /* @__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" }) })
13287
+ ] }),
13288
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
13289
+ ] });
13290
+ };
13291
+ const SalesChannelForm = ({ order }) => {
13292
+ const form = reactHookForm.useForm({
13293
+ defaultValues: {
13294
+ sales_channel_id: order.sales_channel_id || ""
13295
+ },
13296
+ resolver: zod.zodResolver(schema)
13297
+ });
13298
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
13299
+ const { handleSuccess } = useRouteModal();
13300
+ const onSubmit = form.handleSubmit(async (data) => {
13301
+ await mutateAsync(
13302
+ {
13303
+ sales_channel_id: data.sales_channel_id
13304
+ },
13305
+ {
13306
+ onSuccess: () => {
13307
+ ui.toast.success("Sales channel updated");
13308
+ handleSuccess();
13309
+ },
13310
+ onError: (error) => {
13311
+ ui.toast.error(error.message);
13312
+ }
13313
+ }
13314
+ );
13315
+ });
13316
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
13317
+ KeyboundForm,
13318
+ {
13319
+ className: "flex flex-1 flex-col overflow-hidden",
13320
+ onSubmit,
13321
+ children: [
13322
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
13323
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13324
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13325
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13326
+ ] }) })
13327
+ ]
13328
+ }
13329
+ ) });
13330
+ };
13331
+ const SalesChannelField = ({ control, order }) => {
13332
+ const salesChannels = useComboboxData({
13333
+ queryFn: async (params) => {
13334
+ return await sdk.admin.salesChannel.list(params);
13335
+ },
13336
+ queryKey: ["sales-channels"],
13337
+ getOptions: (data) => {
13338
+ return data.sales_channels.map((salesChannel) => ({
13339
+ label: salesChannel.name,
13340
+ value: salesChannel.id
13341
+ }));
13342
+ },
13343
+ defaultValue: order.sales_channel_id || void 0
13344
+ });
13345
+ return /* @__PURE__ */ jsxRuntime.jsx(
13346
+ Form$2.Field,
13347
+ {
13348
+ control,
13349
+ name: "sales_channel_id",
13350
+ render: ({ field }) => {
13351
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13352
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
13353
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
13354
+ Combobox,
13355
+ {
13356
+ options: salesChannels.options,
13357
+ fetchNextPage: salesChannels.fetchNextPage,
13358
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
13359
+ searchValue: salesChannels.searchValue,
13360
+ onSearchValueChange: salesChannels.onSearchValueChange,
13361
+ placeholder: "Select sales channel",
13362
+ ...field
13363
+ }
13364
+ ) }),
13365
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13366
+ ] });
13367
+ }
13368
+ }
13369
+ );
13370
+ };
13371
+ const schema = object({
13372
+ sales_channel_id: string().min(1)
13373
+ });
13374
13374
  const widgetModule = { widgets: [] };
13375
13375
  const routeModule = {
13376
13376
  routes: [
@@ -13391,14 +13391,14 @@ const routeModule = {
13391
13391
  handle,
13392
13392
  loader,
13393
13393
  children: [
13394
- {
13395
- Component: BillingAddress,
13396
- path: "/draft-orders/:id/billing-address"
13397
- },
13398
13394
  {
13399
13395
  Component: CustomItems,
13400
13396
  path: "/draft-orders/:id/custom-items"
13401
13397
  },
13398
+ {
13399
+ Component: BillingAddress,
13400
+ path: "/draft-orders/:id/billing-address"
13401
+ },
13402
13402
  {
13403
13403
  Component: Email,
13404
13404
  path: "/draft-orders/:id/email"
@@ -13415,10 +13415,6 @@ const routeModule = {
13415
13415
  Component: Promotions,
13416
13416
  path: "/draft-orders/:id/promotions"
13417
13417
  },
13418
- {
13419
- Component: SalesChannel,
13420
- path: "/draft-orders/:id/sales-channel"
13421
- },
13422
13418
  {
13423
13419
  Component: Shipping,
13424
13420
  path: "/draft-orders/:id/shipping"
@@ -13430,6 +13426,10 @@ const routeModule = {
13430
13426
  {
13431
13427
  Component: TransferOwnership,
13432
13428
  path: "/draft-orders/:id/transfer-ownership"
13429
+ },
13430
+ {
13431
+ Component: SalesChannel,
13432
+ path: "/draft-orders/:id/sales-channel"
13433
13433
  }
13434
13434
  ]
13435
13435
  }
@@ -9892,6 +9892,27 @@ const ID = () => {
9892
9892
  /* @__PURE__ */ jsx(Outlet, {})
9893
9893
  ] });
9894
9894
  };
9895
+ const CustomItems = () => {
9896
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9897
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9898
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9899
+ ] });
9900
+ };
9901
+ const CustomItemsForm = () => {
9902
+ const form = useForm({
9903
+ resolver: zodResolver(schema$5)
9904
+ });
9905
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9906
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9907
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9908
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9909
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9910
+ ] }) })
9911
+ ] }) });
9912
+ };
9913
+ const schema$5 = object({
9914
+ email: string().email()
9915
+ });
9895
9916
  const BillingAddress = () => {
9896
9917
  const { id } = useParams();
9897
9918
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9924,7 +9945,7 @@ const BillingAddressForm = ({ order }) => {
9924
9945
  postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9925
9946
  phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9926
9947
  },
9927
- resolver: zodResolver(schema$5)
9948
+ resolver: zodResolver(schema$4)
9928
9949
  });
9929
9950
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9930
9951
  const { handleSuccess } = useRouteModal();
@@ -10081,28 +10102,7 @@ const BillingAddressForm = ({ order }) => {
10081
10102
  }
10082
10103
  ) });
10083
10104
  };
10084
- const schema$5 = addressSchema;
10085
- const CustomItems = () => {
10086
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
10087
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
10088
- /* @__PURE__ */ jsx(CustomItemsForm, {})
10089
- ] });
10090
- };
10091
- const CustomItemsForm = () => {
10092
- const form = useForm({
10093
- resolver: zodResolver(schema$4)
10094
- });
10095
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
10096
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
10097
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
10098
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10099
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
10100
- ] }) })
10101
- ] }) });
10102
- };
10103
- const schema$4 = object({
10104
- email: string().email()
10105
- });
10105
+ const schema$4 = addressSchema;
10106
10106
  const Email = () => {
10107
10107
  const { id } = useParams();
10108
10108
  const { order, isPending, isError, error } = useOrder(id, {
@@ -11772,112 +11772,6 @@ function getPromotionIds(items, shippingMethods) {
11772
11772
  }
11773
11773
  return Array.from(promotionIds);
11774
11774
  }
11775
- const SalesChannel = () => {
11776
- const { id } = useParams();
11777
- const { draft_order, isPending, isError, error } = useDraftOrder(
11778
- id,
11779
- {
11780
- fields: "+sales_channel_id"
11781
- },
11782
- {
11783
- enabled: !!id
11784
- }
11785
- );
11786
- if (isError) {
11787
- throw error;
11788
- }
11789
- const ISrEADY = !!draft_order && !isPending;
11790
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11791
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11792
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11793
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11794
- ] }),
11795
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11796
- ] });
11797
- };
11798
- const SalesChannelForm = ({ order }) => {
11799
- const form = useForm({
11800
- defaultValues: {
11801
- sales_channel_id: order.sales_channel_id || ""
11802
- },
11803
- resolver: zodResolver(schema$2)
11804
- });
11805
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11806
- const { handleSuccess } = useRouteModal();
11807
- const onSubmit = form.handleSubmit(async (data) => {
11808
- await mutateAsync(
11809
- {
11810
- sales_channel_id: data.sales_channel_id
11811
- },
11812
- {
11813
- onSuccess: () => {
11814
- toast.success("Sales channel updated");
11815
- handleSuccess();
11816
- },
11817
- onError: (error) => {
11818
- toast.error(error.message);
11819
- }
11820
- }
11821
- );
11822
- });
11823
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11824
- KeyboundForm,
11825
- {
11826
- className: "flex flex-1 flex-col overflow-hidden",
11827
- onSubmit,
11828
- children: [
11829
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11830
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11831
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11832
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11833
- ] }) })
11834
- ]
11835
- }
11836
- ) });
11837
- };
11838
- const SalesChannelField = ({ control, order }) => {
11839
- const salesChannels = useComboboxData({
11840
- queryFn: async (params) => {
11841
- return await sdk.admin.salesChannel.list(params);
11842
- },
11843
- queryKey: ["sales-channels"],
11844
- getOptions: (data) => {
11845
- return data.sales_channels.map((salesChannel) => ({
11846
- label: salesChannel.name,
11847
- value: salesChannel.id
11848
- }));
11849
- },
11850
- defaultValue: order.sales_channel_id || void 0
11851
- });
11852
- return /* @__PURE__ */ jsx(
11853
- Form$2.Field,
11854
- {
11855
- control,
11856
- name: "sales_channel_id",
11857
- render: ({ field }) => {
11858
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11859
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11860
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11861
- Combobox,
11862
- {
11863
- options: salesChannels.options,
11864
- fetchNextPage: salesChannels.fetchNextPage,
11865
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11866
- searchValue: salesChannels.searchValue,
11867
- onSearchValueChange: salesChannels.onSearchValueChange,
11868
- placeholder: "Select sales channel",
11869
- ...field
11870
- }
11871
- ) }),
11872
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11873
- ] });
11874
- }
11875
- }
11876
- );
11877
- };
11878
- const schema$2 = object({
11879
- sales_channel_id: string().min(1)
11880
- });
11881
11775
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11882
11776
  const Shipping = () => {
11883
11777
  var _a2;
@@ -12717,7 +12611,7 @@ const ShippingAddressForm = ({ order }) => {
12717
12611
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12718
12612
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12719
12613
  },
12720
- resolver: zodResolver(schema$1)
12614
+ resolver: zodResolver(schema$2)
12721
12615
  });
12722
12616
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12723
12617
  const { handleSuccess } = useRouteModal();
@@ -12887,7 +12781,7 @@ const ShippingAddressForm = ({ order }) => {
12887
12781
  }
12888
12782
  ) });
12889
12783
  };
12890
- const schema$1 = addressSchema;
12784
+ const schema$2 = addressSchema;
12891
12785
  const TransferOwnership = () => {
12892
12786
  const { id } = useParams();
12893
12787
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12911,7 +12805,7 @@ const TransferOwnershipForm = ({ order }) => {
12911
12805
  defaultValues: {
12912
12806
  customer_id: order.customer_id || ""
12913
12807
  },
12914
- resolver: zodResolver(schema)
12808
+ resolver: zodResolver(schema$1)
12915
12809
  });
12916
12810
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12917
12811
  const { handleSuccess } = useRouteModal();
@@ -13361,9 +13255,115 @@ const Illustration = () => {
13361
13255
  }
13362
13256
  );
13363
13257
  };
13364
- const schema = object({
13258
+ const schema$1 = object({
13365
13259
  customer_id: string().min(1)
13366
13260
  });
13261
+ const SalesChannel = () => {
13262
+ const { id } = useParams();
13263
+ const { draft_order, isPending, isError, error } = useDraftOrder(
13264
+ id,
13265
+ {
13266
+ fields: "+sales_channel_id"
13267
+ },
13268
+ {
13269
+ enabled: !!id
13270
+ }
13271
+ );
13272
+ if (isError) {
13273
+ throw error;
13274
+ }
13275
+ const ISrEADY = !!draft_order && !isPending;
13276
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13277
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
13278
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
13279
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
13280
+ ] }),
13281
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
13282
+ ] });
13283
+ };
13284
+ const SalesChannelForm = ({ order }) => {
13285
+ const form = useForm({
13286
+ defaultValues: {
13287
+ sales_channel_id: order.sales_channel_id || ""
13288
+ },
13289
+ resolver: zodResolver(schema)
13290
+ });
13291
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
13292
+ const { handleSuccess } = useRouteModal();
13293
+ const onSubmit = form.handleSubmit(async (data) => {
13294
+ await mutateAsync(
13295
+ {
13296
+ sales_channel_id: data.sales_channel_id
13297
+ },
13298
+ {
13299
+ onSuccess: () => {
13300
+ toast.success("Sales channel updated");
13301
+ handleSuccess();
13302
+ },
13303
+ onError: (error) => {
13304
+ toast.error(error.message);
13305
+ }
13306
+ }
13307
+ );
13308
+ });
13309
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
13310
+ KeyboundForm,
13311
+ {
13312
+ className: "flex flex-1 flex-col overflow-hidden",
13313
+ onSubmit,
13314
+ children: [
13315
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
13316
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13317
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13318
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13319
+ ] }) })
13320
+ ]
13321
+ }
13322
+ ) });
13323
+ };
13324
+ const SalesChannelField = ({ control, order }) => {
13325
+ const salesChannels = useComboboxData({
13326
+ queryFn: async (params) => {
13327
+ return await sdk.admin.salesChannel.list(params);
13328
+ },
13329
+ queryKey: ["sales-channels"],
13330
+ getOptions: (data) => {
13331
+ return data.sales_channels.map((salesChannel) => ({
13332
+ label: salesChannel.name,
13333
+ value: salesChannel.id
13334
+ }));
13335
+ },
13336
+ defaultValue: order.sales_channel_id || void 0
13337
+ });
13338
+ return /* @__PURE__ */ jsx(
13339
+ Form$2.Field,
13340
+ {
13341
+ control,
13342
+ name: "sales_channel_id",
13343
+ render: ({ field }) => {
13344
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13345
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
13346
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
13347
+ Combobox,
13348
+ {
13349
+ options: salesChannels.options,
13350
+ fetchNextPage: salesChannels.fetchNextPage,
13351
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
13352
+ searchValue: salesChannels.searchValue,
13353
+ onSearchValueChange: salesChannels.onSearchValueChange,
13354
+ placeholder: "Select sales channel",
13355
+ ...field
13356
+ }
13357
+ ) }),
13358
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13359
+ ] });
13360
+ }
13361
+ }
13362
+ );
13363
+ };
13364
+ const schema = object({
13365
+ sales_channel_id: string().min(1)
13366
+ });
13367
13367
  const widgetModule = { widgets: [] };
13368
13368
  const routeModule = {
13369
13369
  routes: [
@@ -13384,14 +13384,14 @@ const routeModule = {
13384
13384
  handle,
13385
13385
  loader,
13386
13386
  children: [
13387
- {
13388
- Component: BillingAddress,
13389
- path: "/draft-orders/:id/billing-address"
13390
- },
13391
13387
  {
13392
13388
  Component: CustomItems,
13393
13389
  path: "/draft-orders/:id/custom-items"
13394
13390
  },
13391
+ {
13392
+ Component: BillingAddress,
13393
+ path: "/draft-orders/:id/billing-address"
13394
+ },
13395
13395
  {
13396
13396
  Component: Email,
13397
13397
  path: "/draft-orders/:id/email"
@@ -13408,10 +13408,6 @@ const routeModule = {
13408
13408
  Component: Promotions,
13409
13409
  path: "/draft-orders/:id/promotions"
13410
13410
  },
13411
- {
13412
- Component: SalesChannel,
13413
- path: "/draft-orders/:id/sales-channel"
13414
- },
13415
13411
  {
13416
13412
  Component: Shipping,
13417
13413
  path: "/draft-orders/:id/shipping"
@@ -13423,6 +13419,10 @@ const routeModule = {
13423
13419
  {
13424
13420
  Component: TransferOwnership,
13425
13421
  path: "/draft-orders/:id/transfer-ownership"
13422
+ },
13423
+ {
13424
+ Component: SalesChannel,
13425
+ path: "/draft-orders/:id/sales-channel"
13426
13426
  }
13427
13427
  ]
13428
13428
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.14.2",
3
+ "version": "2.14.3-preview-20260504001529",
4
4
  "description": "A draft order plugin for Medusa.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "@ariakit/react": "^0.4.15",
43
43
  "@babel/runtime": "^7.26.10",
44
44
  "@hookform/resolvers": "3.4.2",
45
- "@medusajs/js-sdk": "2.14.2",
45
+ "@medusajs/js-sdk": "2.14.3-preview-20260504001529",
46
46
  "@tanstack/react-query": "5.64.2",
47
47
  "@uiw/react-json-view": "^2.0.0-alpha.17",
48
48
  "date-fns": "^3.6.0",
@@ -53,22 +53,22 @@
53
53
  "react-hook-form": "7.49.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@medusajs/admin-sdk": "2.14.2",
57
- "@medusajs/cli": "2.14.2",
58
- "@medusajs/framework": "2.14.2",
59
- "@medusajs/icons": "2.14.2",
60
- "@medusajs/test-utils": "2.14.2",
61
- "@medusajs/types": "2.14.2",
62
- "@medusajs/ui": "4.1.9",
63
- "@medusajs/ui-preset": "2.14.2"
56
+ "@medusajs/admin-sdk": "2.14.3-preview-20260504001529",
57
+ "@medusajs/cli": "2.14.3-preview-20260504001529",
58
+ "@medusajs/framework": "2.14.3-preview-20260504001529",
59
+ "@medusajs/icons": "2.14.3-preview-20260504001529",
60
+ "@medusajs/test-utils": "2.14.3-preview-20260504001529",
61
+ "@medusajs/types": "2.14.3-preview-20260504001529",
62
+ "@medusajs/ui": "4.1.10-preview-20260504001529",
63
+ "@medusajs/ui-preset": "2.14.3-preview-20260504001529"
64
64
  },
65
65
  "peerDependencies": {
66
- "@medusajs/admin-sdk": "2.14.2",
67
- "@medusajs/cli": "2.14.2",
68
- "@medusajs/framework": "2.14.2",
69
- "@medusajs/icons": "2.14.2",
70
- "@medusajs/test-utils": "2.14.2",
71
- "@medusajs/ui": "4.1.9",
66
+ "@medusajs/admin-sdk": "2.14.3-preview-20260504001529",
67
+ "@medusajs/cli": "2.14.3-preview-20260504001529",
68
+ "@medusajs/framework": "2.14.3-preview-20260504001529",
69
+ "@medusajs/icons": "2.14.3-preview-20260504001529",
70
+ "@medusajs/test-utils": "2.14.3-preview-20260504001529",
71
+ "@medusajs/ui": "4.1.10-preview-20260504001529",
72
72
  "react": "^18.3.1",
73
73
  "react-dom": "^18.3.1",
74
74
  "react-router-dom": "6.30.3"