@medusajs/draft-order 2.11.3-preview-20251103120146 → 2.11.3-preview-20251104090411

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.
@@ -4654,9 +4654,6 @@ ZodReadonly.create = (type, params) => {
4654
4654
  ...processCreateParams(params)
4655
4655
  });
4656
4656
  };
4657
- ({
4658
- object: ZodObject.lazycreate
4659
- });
4660
4657
  var ZodFirstPartyTypeKind;
4661
4658
  (function(ZodFirstPartyTypeKind2) {
4662
4659
  ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
@@ -4703,7 +4700,6 @@ const anyType = ZodAny.create;
4703
4700
  ZodNever.create;
4704
4701
  const arrayType = ZodArray.create;
4705
4702
  const objectType = ZodObject.create;
4706
- ZodObject.strictCreate;
4707
4703
  const unionType = ZodUnion.create;
4708
4704
  ZodIntersection.create;
4709
4705
  ZodTuple.create;
@@ -11452,6 +11448,112 @@ function getPromotionIds(items, shippingMethods) {
11452
11448
  }
11453
11449
  return Array.from(promotionIds);
11454
11450
  }
11451
+ const SalesChannel = () => {
11452
+ const { id } = reactRouterDom.useParams();
11453
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11454
+ id,
11455
+ {
11456
+ fields: "+sales_channel_id"
11457
+ },
11458
+ {
11459
+ enabled: !!id
11460
+ }
11461
+ );
11462
+ if (isError) {
11463
+ throw error;
11464
+ }
11465
+ const ISrEADY = !!draft_order && !isPending;
11466
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11467
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11468
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11469
+ /* @__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" }) })
11470
+ ] }),
11471
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11472
+ ] });
11473
+ };
11474
+ const SalesChannelForm = ({ order }) => {
11475
+ const form = reactHookForm.useForm({
11476
+ defaultValues: {
11477
+ sales_channel_id: order.sales_channel_id || ""
11478
+ },
11479
+ resolver: zod.zodResolver(schema$2)
11480
+ });
11481
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11482
+ const { handleSuccess } = useRouteModal();
11483
+ const onSubmit = form.handleSubmit(async (data) => {
11484
+ await mutateAsync(
11485
+ {
11486
+ sales_channel_id: data.sales_channel_id
11487
+ },
11488
+ {
11489
+ onSuccess: () => {
11490
+ ui.toast.success("Sales channel updated");
11491
+ handleSuccess();
11492
+ },
11493
+ onError: (error) => {
11494
+ ui.toast.error(error.message);
11495
+ }
11496
+ }
11497
+ );
11498
+ });
11499
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11500
+ KeyboundForm,
11501
+ {
11502
+ className: "flex flex-1 flex-col overflow-hidden",
11503
+ onSubmit,
11504
+ children: [
11505
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11506
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11507
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11508
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11509
+ ] }) })
11510
+ ]
11511
+ }
11512
+ ) });
11513
+ };
11514
+ const SalesChannelField = ({ control, order }) => {
11515
+ const salesChannels = useComboboxData({
11516
+ queryFn: async (params) => {
11517
+ return await sdk.admin.salesChannel.list(params);
11518
+ },
11519
+ queryKey: ["sales-channels"],
11520
+ getOptions: (data) => {
11521
+ return data.sales_channels.map((salesChannel) => ({
11522
+ label: salesChannel.name,
11523
+ value: salesChannel.id
11524
+ }));
11525
+ },
11526
+ defaultValue: order.sales_channel_id || void 0
11527
+ });
11528
+ return /* @__PURE__ */ jsxRuntime.jsx(
11529
+ Form$2.Field,
11530
+ {
11531
+ control,
11532
+ name: "sales_channel_id",
11533
+ render: ({ field }) => {
11534
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11535
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11536
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11537
+ Combobox,
11538
+ {
11539
+ options: salesChannels.options,
11540
+ fetchNextPage: salesChannels.fetchNextPage,
11541
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11542
+ searchValue: salesChannels.searchValue,
11543
+ onSearchValueChange: salesChannels.onSearchValueChange,
11544
+ placeholder: "Select sales channel",
11545
+ ...field
11546
+ }
11547
+ ) }),
11548
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11549
+ ] });
11550
+ }
11551
+ }
11552
+ );
11553
+ };
11554
+ const schema$2 = objectType({
11555
+ sales_channel_id: stringType().min(1)
11556
+ });
11455
11557
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11456
11558
  const Shipping = () => {
11457
11559
  var _a;
@@ -12291,7 +12393,7 @@ const ShippingAddressForm = ({ order }) => {
12291
12393
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12292
12394
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12293
12395
  },
12294
- resolver: zod.zodResolver(schema$2)
12396
+ resolver: zod.zodResolver(schema$1)
12295
12397
  });
12296
12398
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12297
12399
  const { handleSuccess } = useRouteModal();
@@ -12461,7 +12563,7 @@ const ShippingAddressForm = ({ order }) => {
12461
12563
  }
12462
12564
  ) });
12463
12565
  };
12464
- const schema$2 = addressSchema;
12566
+ const schema$1 = addressSchema;
12465
12567
  const TransferOwnership = () => {
12466
12568
  const { id } = reactRouterDom.useParams();
12467
12569
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12485,7 +12587,7 @@ const TransferOwnershipForm = ({ order }) => {
12485
12587
  defaultValues: {
12486
12588
  customer_id: order.customer_id || ""
12487
12589
  },
12488
- resolver: zod.zodResolver(schema$1)
12590
+ resolver: zod.zodResolver(schema)
12489
12591
  });
12490
12592
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12491
12593
  const { handleSuccess } = useRouteModal();
@@ -12935,114 +13037,8 @@ const Illustration = () => {
12935
13037
  }
12936
13038
  );
12937
13039
  };
12938
- const schema$1 = objectType({
12939
- customer_id: stringType().min(1)
12940
- });
12941
- const SalesChannel = () => {
12942
- const { id } = reactRouterDom.useParams();
12943
- const { draft_order, isPending, isError, error } = useDraftOrder(
12944
- id,
12945
- {
12946
- fields: "+sales_channel_id"
12947
- },
12948
- {
12949
- enabled: !!id
12950
- }
12951
- );
12952
- if (isError) {
12953
- throw error;
12954
- }
12955
- const ISrEADY = !!draft_order && !isPending;
12956
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12957
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12958
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12959
- /* @__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" }) })
12960
- ] }),
12961
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12962
- ] });
12963
- };
12964
- const SalesChannelForm = ({ order }) => {
12965
- const form = reactHookForm.useForm({
12966
- defaultValues: {
12967
- sales_channel_id: order.sales_channel_id || ""
12968
- },
12969
- resolver: zod.zodResolver(schema)
12970
- });
12971
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12972
- const { handleSuccess } = useRouteModal();
12973
- const onSubmit = form.handleSubmit(async (data) => {
12974
- await mutateAsync(
12975
- {
12976
- sales_channel_id: data.sales_channel_id
12977
- },
12978
- {
12979
- onSuccess: () => {
12980
- ui.toast.success("Sales channel updated");
12981
- handleSuccess();
12982
- },
12983
- onError: (error) => {
12984
- ui.toast.error(error.message);
12985
- }
12986
- }
12987
- );
12988
- });
12989
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12990
- KeyboundForm,
12991
- {
12992
- className: "flex flex-1 flex-col overflow-hidden",
12993
- onSubmit,
12994
- children: [
12995
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12996
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12997
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12998
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12999
- ] }) })
13000
- ]
13001
- }
13002
- ) });
13003
- };
13004
- const SalesChannelField = ({ control, order }) => {
13005
- const salesChannels = useComboboxData({
13006
- queryFn: async (params) => {
13007
- return await sdk.admin.salesChannel.list(params);
13008
- },
13009
- queryKey: ["sales-channels"],
13010
- getOptions: (data) => {
13011
- return data.sales_channels.map((salesChannel) => ({
13012
- label: salesChannel.name,
13013
- value: salesChannel.id
13014
- }));
13015
- },
13016
- defaultValue: order.sales_channel_id || void 0
13017
- });
13018
- return /* @__PURE__ */ jsxRuntime.jsx(
13019
- Form$2.Field,
13020
- {
13021
- control,
13022
- name: "sales_channel_id",
13023
- render: ({ field }) => {
13024
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13025
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
13026
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
13027
- Combobox,
13028
- {
13029
- options: salesChannels.options,
13030
- fetchNextPage: salesChannels.fetchNextPage,
13031
- isFetchingNextPage: salesChannels.isFetchingNextPage,
13032
- searchValue: salesChannels.searchValue,
13033
- onSearchValueChange: salesChannels.onSearchValueChange,
13034
- placeholder: "Select sales channel",
13035
- ...field
13036
- }
13037
- ) }),
13038
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13039
- ] });
13040
- }
13041
- }
13042
- );
13043
- };
13044
13040
  const schema = objectType({
13045
- sales_channel_id: stringType().min(1)
13041
+ customer_id: stringType().min(1)
13046
13042
  });
13047
13043
  const widgetModule = { widgets: [] };
13048
13044
  const routeModule = {
@@ -13088,6 +13084,10 @@ const routeModule = {
13088
13084
  Component: Promotions,
13089
13085
  path: "/draft-orders/:id/promotions"
13090
13086
  },
13087
+ {
13088
+ Component: SalesChannel,
13089
+ path: "/draft-orders/:id/sales-channel"
13090
+ },
13091
13091
  {
13092
13092
  Component: Shipping,
13093
13093
  path: "/draft-orders/:id/shipping"
@@ -13099,10 +13099,6 @@ const routeModule = {
13099
13099
  {
13100
13100
  Component: TransferOwnership,
13101
13101
  path: "/draft-orders/:id/transfer-ownership"
13102
- },
13103
- {
13104
- Component: SalesChannel,
13105
- path: "/draft-orders/:id/sales-channel"
13106
13102
  }
13107
13103
  ]
13108
13104
  }
@@ -9,7 +9,7 @@ import Medusa from "@medusajs/js-sdk";
9
9
  import { format, formatDistance, sub, subDays, subMonths } from "date-fns";
10
10
  import { enUS } from "date-fns/locale";
11
11
  import { zodResolver } from "@hookform/resolvers/zod";
12
- import { FormProvider, Controller, useFormContext, useFormState, useForm, useWatch, useFieldArray } from "react-hook-form";
12
+ import { FormProvider, useFormContext, useFormState, Controller, useForm, useWatch, useFieldArray } from "react-hook-form";
13
13
  import { Slot, Collapsible, Accordion } from "radix-ui";
14
14
  import { ComboboxProvider, Combobox as Combobox$1, ComboboxDisclosure, ComboboxPopover, ComboboxItem, ComboboxItemCheck, ComboboxItemValue, Separator } from "@ariakit/react";
15
15
  import { matchSorter } from "match-sorter";
@@ -4647,9 +4647,6 @@ ZodReadonly.create = (type, params) => {
4647
4647
  ...processCreateParams(params)
4648
4648
  });
4649
4649
  };
4650
- ({
4651
- object: ZodObject.lazycreate
4652
- });
4653
4650
  var ZodFirstPartyTypeKind;
4654
4651
  (function(ZodFirstPartyTypeKind2) {
4655
4652
  ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
@@ -4696,7 +4693,6 @@ const anyType = ZodAny.create;
4696
4693
  ZodNever.create;
4697
4694
  const arrayType = ZodArray.create;
4698
4695
  const objectType = ZodObject.create;
4699
- ZodObject.strictCreate;
4700
4696
  const unionType = ZodUnion.create;
4701
4697
  ZodIntersection.create;
4702
4698
  ZodTuple.create;
@@ -11445,6 +11441,112 @@ function getPromotionIds(items, shippingMethods) {
11445
11441
  }
11446
11442
  return Array.from(promotionIds);
11447
11443
  }
11444
+ const SalesChannel = () => {
11445
+ const { id } = useParams();
11446
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11447
+ id,
11448
+ {
11449
+ fields: "+sales_channel_id"
11450
+ },
11451
+ {
11452
+ enabled: !!id
11453
+ }
11454
+ );
11455
+ if (isError) {
11456
+ throw error;
11457
+ }
11458
+ const ISrEADY = !!draft_order && !isPending;
11459
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11460
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11461
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11462
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11463
+ ] }),
11464
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11465
+ ] });
11466
+ };
11467
+ const SalesChannelForm = ({ order }) => {
11468
+ const form = useForm({
11469
+ defaultValues: {
11470
+ sales_channel_id: order.sales_channel_id || ""
11471
+ },
11472
+ resolver: zodResolver(schema$2)
11473
+ });
11474
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11475
+ const { handleSuccess } = useRouteModal();
11476
+ const onSubmit = form.handleSubmit(async (data) => {
11477
+ await mutateAsync(
11478
+ {
11479
+ sales_channel_id: data.sales_channel_id
11480
+ },
11481
+ {
11482
+ onSuccess: () => {
11483
+ toast.success("Sales channel updated");
11484
+ handleSuccess();
11485
+ },
11486
+ onError: (error) => {
11487
+ toast.error(error.message);
11488
+ }
11489
+ }
11490
+ );
11491
+ });
11492
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11493
+ KeyboundForm,
11494
+ {
11495
+ className: "flex flex-1 flex-col overflow-hidden",
11496
+ onSubmit,
11497
+ children: [
11498
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11499
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11500
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11501
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11502
+ ] }) })
11503
+ ]
11504
+ }
11505
+ ) });
11506
+ };
11507
+ const SalesChannelField = ({ control, order }) => {
11508
+ const salesChannels = useComboboxData({
11509
+ queryFn: async (params) => {
11510
+ return await sdk.admin.salesChannel.list(params);
11511
+ },
11512
+ queryKey: ["sales-channels"],
11513
+ getOptions: (data) => {
11514
+ return data.sales_channels.map((salesChannel) => ({
11515
+ label: salesChannel.name,
11516
+ value: salesChannel.id
11517
+ }));
11518
+ },
11519
+ defaultValue: order.sales_channel_id || void 0
11520
+ });
11521
+ return /* @__PURE__ */ jsx(
11522
+ Form$2.Field,
11523
+ {
11524
+ control,
11525
+ name: "sales_channel_id",
11526
+ render: ({ field }) => {
11527
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11528
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11529
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11530
+ Combobox,
11531
+ {
11532
+ options: salesChannels.options,
11533
+ fetchNextPage: salesChannels.fetchNextPage,
11534
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11535
+ searchValue: salesChannels.searchValue,
11536
+ onSearchValueChange: salesChannels.onSearchValueChange,
11537
+ placeholder: "Select sales channel",
11538
+ ...field
11539
+ }
11540
+ ) }),
11541
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11542
+ ] });
11543
+ }
11544
+ }
11545
+ );
11546
+ };
11547
+ const schema$2 = objectType({
11548
+ sales_channel_id: stringType().min(1)
11549
+ });
11448
11550
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11449
11551
  const Shipping = () => {
11450
11552
  var _a;
@@ -12284,7 +12386,7 @@ const ShippingAddressForm = ({ order }) => {
12284
12386
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12285
12387
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12286
12388
  },
12287
- resolver: zodResolver(schema$2)
12389
+ resolver: zodResolver(schema$1)
12288
12390
  });
12289
12391
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12290
12392
  const { handleSuccess } = useRouteModal();
@@ -12454,7 +12556,7 @@ const ShippingAddressForm = ({ order }) => {
12454
12556
  }
12455
12557
  ) });
12456
12558
  };
12457
- const schema$2 = addressSchema;
12559
+ const schema$1 = addressSchema;
12458
12560
  const TransferOwnership = () => {
12459
12561
  const { id } = useParams();
12460
12562
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12478,7 +12580,7 @@ const TransferOwnershipForm = ({ order }) => {
12478
12580
  defaultValues: {
12479
12581
  customer_id: order.customer_id || ""
12480
12582
  },
12481
- resolver: zodResolver(schema$1)
12583
+ resolver: zodResolver(schema)
12482
12584
  });
12483
12585
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12484
12586
  const { handleSuccess } = useRouteModal();
@@ -12928,114 +13030,8 @@ const Illustration = () => {
12928
13030
  }
12929
13031
  );
12930
13032
  };
12931
- const schema$1 = objectType({
12932
- customer_id: stringType().min(1)
12933
- });
12934
- const SalesChannel = () => {
12935
- const { id } = useParams();
12936
- const { draft_order, isPending, isError, error } = useDraftOrder(
12937
- id,
12938
- {
12939
- fields: "+sales_channel_id"
12940
- },
12941
- {
12942
- enabled: !!id
12943
- }
12944
- );
12945
- if (isError) {
12946
- throw error;
12947
- }
12948
- const ISrEADY = !!draft_order && !isPending;
12949
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12950
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12951
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12952
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12953
- ] }),
12954
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12955
- ] });
12956
- };
12957
- const SalesChannelForm = ({ order }) => {
12958
- const form = useForm({
12959
- defaultValues: {
12960
- sales_channel_id: order.sales_channel_id || ""
12961
- },
12962
- resolver: zodResolver(schema)
12963
- });
12964
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12965
- const { handleSuccess } = useRouteModal();
12966
- const onSubmit = form.handleSubmit(async (data) => {
12967
- await mutateAsync(
12968
- {
12969
- sales_channel_id: data.sales_channel_id
12970
- },
12971
- {
12972
- onSuccess: () => {
12973
- toast.success("Sales channel updated");
12974
- handleSuccess();
12975
- },
12976
- onError: (error) => {
12977
- toast.error(error.message);
12978
- }
12979
- }
12980
- );
12981
- });
12982
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12983
- KeyboundForm,
12984
- {
12985
- className: "flex flex-1 flex-col overflow-hidden",
12986
- onSubmit,
12987
- children: [
12988
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12989
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12990
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12991
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12992
- ] }) })
12993
- ]
12994
- }
12995
- ) });
12996
- };
12997
- const SalesChannelField = ({ control, order }) => {
12998
- const salesChannels = useComboboxData({
12999
- queryFn: async (params) => {
13000
- return await sdk.admin.salesChannel.list(params);
13001
- },
13002
- queryKey: ["sales-channels"],
13003
- getOptions: (data) => {
13004
- return data.sales_channels.map((salesChannel) => ({
13005
- label: salesChannel.name,
13006
- value: salesChannel.id
13007
- }));
13008
- },
13009
- defaultValue: order.sales_channel_id || void 0
13010
- });
13011
- return /* @__PURE__ */ jsx(
13012
- Form$2.Field,
13013
- {
13014
- control,
13015
- name: "sales_channel_id",
13016
- render: ({ field }) => {
13017
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13018
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
13019
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
13020
- Combobox,
13021
- {
13022
- options: salesChannels.options,
13023
- fetchNextPage: salesChannels.fetchNextPage,
13024
- isFetchingNextPage: salesChannels.isFetchingNextPage,
13025
- searchValue: salesChannels.searchValue,
13026
- onSearchValueChange: salesChannels.onSearchValueChange,
13027
- placeholder: "Select sales channel",
13028
- ...field
13029
- }
13030
- ) }),
13031
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13032
- ] });
13033
- }
13034
- }
13035
- );
13036
- };
13037
13033
  const schema = objectType({
13038
- sales_channel_id: stringType().min(1)
13034
+ customer_id: stringType().min(1)
13039
13035
  });
13040
13036
  const widgetModule = { widgets: [] };
13041
13037
  const routeModule = {
@@ -13081,6 +13077,10 @@ const routeModule = {
13081
13077
  Component: Promotions,
13082
13078
  path: "/draft-orders/:id/promotions"
13083
13079
  },
13080
+ {
13081
+ Component: SalesChannel,
13082
+ path: "/draft-orders/:id/sales-channel"
13083
+ },
13084
13084
  {
13085
13085
  Component: Shipping,
13086
13086
  path: "/draft-orders/:id/shipping"
@@ -13092,10 +13092,6 @@ const routeModule = {
13092
13092
  {
13093
13093
  Component: TransferOwnership,
13094
13094
  path: "/draft-orders/:id/transfer-ownership"
13095
- },
13096
- {
13097
- Component: SalesChannel,
13098
- path: "/draft-orders/:id/sales-channel"
13099
13095
  }
13100
13096
  ]
13101
13097
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.11.3-preview-20251103120146",
3
+ "version": "2.11.3-preview-20251104090411",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "@ariakit/react": "^0.4.15",
38
38
  "@babel/runtime": "^7.26.10",
39
39
  "@hookform/resolvers": "3.4.2",
40
- "@medusajs/js-sdk": "2.11.3-preview-20251103120146",
40
+ "@medusajs/js-sdk": "2.11.3-preview-20251104090411",
41
41
  "@tanstack/react-query": "5.64.2",
42
42
  "@uiw/react-json-view": "^2.0.0-alpha.17",
43
43
  "date-fns": "^3.6.0",
@@ -48,37 +48,22 @@
48
48
  "react-hook-form": "7.49.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@medusajs/admin-sdk": "2.11.3-preview-20251103120146",
52
- "@medusajs/cli": "2.11.3-preview-20251103120146",
53
- "@medusajs/framework": "2.11.3-preview-20251103120146",
54
- "@medusajs/icons": "2.11.3-preview-20251103120146",
55
- "@medusajs/test-utils": "2.11.3-preview-20251103120146",
56
- "@medusajs/types": "2.11.3-preview-20251103120146",
57
- "@medusajs/ui": "4.0.27-preview-20251103120146",
58
- "@medusajs/ui-preset": "2.11.3-preview-20251103120146",
59
- "@swc/core": "^1.7.28",
60
- "@types/lodash": "^4.17.15",
61
- "@types/lodash.debounce": "^4.0.9",
62
- "@types/lodash.isequal": "^4.5.8",
63
- "@types/node": "^20.12.11",
64
- "@types/react": "^18.3.2",
65
- "@types/react-dom": "^18.2.25",
66
- "react": "^18.3.1",
67
- "react-dom": "^18.3.1",
68
- "react-router-dom": "6.20.1",
69
- "ts-node": "^10.9.2",
70
- "tsup": "^8.4.0",
71
- "typescript": "^5.6.2",
72
- "vite": "^5.4.14",
73
- "yalc": "^1.0.0-pre.53"
51
+ "@medusajs/admin-sdk": "2.11.3-preview-20251104090411",
52
+ "@medusajs/cli": "2.11.3-preview-20251104090411",
53
+ "@medusajs/framework": "2.11.3-preview-20251104090411",
54
+ "@medusajs/icons": "2.11.3-preview-20251104090411",
55
+ "@medusajs/test-utils": "2.11.3-preview-20251104090411",
56
+ "@medusajs/types": "2.11.3-preview-20251104090411",
57
+ "@medusajs/ui": "4.0.27-preview-20251104090411",
58
+ "@medusajs/ui-preset": "2.11.3-preview-20251104090411"
74
59
  },
75
60
  "peerDependencies": {
76
- "@medusajs/admin-sdk": "2.11.3-preview-20251103120146",
77
- "@medusajs/cli": "2.11.3-preview-20251103120146",
78
- "@medusajs/framework": "2.11.3-preview-20251103120146",
79
- "@medusajs/icons": "2.11.3-preview-20251103120146",
80
- "@medusajs/test-utils": "2.11.3-preview-20251103120146",
81
- "@medusajs/ui": "4.0.27-preview-20251103120146",
61
+ "@medusajs/admin-sdk": "2.11.3-preview-20251104090411",
62
+ "@medusajs/cli": "2.11.3-preview-20251104090411",
63
+ "@medusajs/framework": "2.11.3-preview-20251104090411",
64
+ "@medusajs/icons": "2.11.3-preview-20251104090411",
65
+ "@medusajs/test-utils": "2.11.3-preview-20251104090411",
66
+ "@medusajs/ui": "4.0.27-preview-20251104090411",
82
67
  "react": "^18.3.1",
83
68
  "react-dom": "^18.3.1",
84
69
  "react-router-dom": "6.20.1"