@medusajs/draft-order 2.11.4-preview-20251111060141 → 2.11.4-preview-20251111120137

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.
@@ -352,10 +352,14 @@ const DataTableAction = ({
352
352
  }
353
353
  return /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { ...buttonProps, onClick: props.onClick, children: label });
354
354
  };
355
+ const backendUrl = __BACKEND_URL__ ?? "/";
356
+ const authType = __AUTH_TYPE__ ?? "session";
357
+ const jwtTokenStorageKey = __JWT_TOKEN_STORAGE_KEY__ || void 0;
355
358
  const sdk = new Medusa__default.default({
356
- baseUrl: __BACKEND_URL__ || "/",
359
+ baseUrl: backendUrl,
357
360
  auth: {
358
- type: "session"
361
+ type: authType,
362
+ jwtTokenStorageKey
359
363
  }
360
364
  });
361
365
  const CUSTOMER_QUERY_KEY = "customers";
@@ -9758,6 +9762,27 @@ const BillingAddressForm = ({ order }) => {
9758
9762
  ) });
9759
9763
  };
9760
9764
  const schema$5 = addressSchema;
9765
+ const CustomItems = () => {
9766
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9767
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9768
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9769
+ ] });
9770
+ };
9771
+ const CustomItemsForm = () => {
9772
+ const form = reactHookForm.useForm({
9773
+ resolver: zod.zodResolver(schema$4)
9774
+ });
9775
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9776
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9777
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9778
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9779
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9780
+ ] }) })
9781
+ ] }) });
9782
+ };
9783
+ const schema$4 = objectType({
9784
+ email: stringType().email()
9785
+ });
9761
9786
  const Email = () => {
9762
9787
  const { id } = reactRouterDom.useParams();
9763
9788
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9780,7 +9805,7 @@ const EmailForm = ({ order }) => {
9780
9805
  defaultValues: {
9781
9806
  email: order.email ?? ""
9782
9807
  },
9783
- resolver: zod.zodResolver(schema$4)
9808
+ resolver: zod.zodResolver(schema$3)
9784
9809
  });
9785
9810
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9786
9811
  const { handleSuccess } = useRouteModal();
@@ -9823,27 +9848,6 @@ const EmailForm = ({ order }) => {
9823
9848
  }
9824
9849
  ) });
9825
9850
  };
9826
- const schema$4 = objectType({
9827
- email: stringType().email()
9828
- });
9829
- const CustomItems = () => {
9830
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9831
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9832
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9833
- ] });
9834
- };
9835
- const CustomItemsForm = () => {
9836
- const form = reactHookForm.useForm({
9837
- resolver: zod.zodResolver(schema$3)
9838
- });
9839
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9840
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9841
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9842
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9843
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9844
- ] }) })
9845
- ] }) });
9846
- };
9847
9851
  const schema$3 = objectType({
9848
9852
  email: stringType().email()
9849
9853
  });
@@ -11448,112 +11452,6 @@ function getPromotionIds(items, shippingMethods) {
11448
11452
  }
11449
11453
  return Array.from(promotionIds);
11450
11454
  }
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
- });
11557
11455
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11558
11456
  const Shipping = () => {
11559
11457
  var _a;
@@ -12361,6 +12259,112 @@ const CustomAmountField = ({
12361
12259
  }
12362
12260
  );
12363
12261
  };
12262
+ const SalesChannel = () => {
12263
+ const { id } = reactRouterDom.useParams();
12264
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12265
+ id,
12266
+ {
12267
+ fields: "+sales_channel_id"
12268
+ },
12269
+ {
12270
+ enabled: !!id
12271
+ }
12272
+ );
12273
+ if (isError) {
12274
+ throw error;
12275
+ }
12276
+ const ISrEADY = !!draft_order && !isPending;
12277
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12278
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12279
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12280
+ /* @__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" }) })
12281
+ ] }),
12282
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12283
+ ] });
12284
+ };
12285
+ const SalesChannelForm = ({ order }) => {
12286
+ const form = reactHookForm.useForm({
12287
+ defaultValues: {
12288
+ sales_channel_id: order.sales_channel_id || ""
12289
+ },
12290
+ resolver: zod.zodResolver(schema$2)
12291
+ });
12292
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12293
+ const { handleSuccess } = useRouteModal();
12294
+ const onSubmit = form.handleSubmit(async (data) => {
12295
+ await mutateAsync(
12296
+ {
12297
+ sales_channel_id: data.sales_channel_id
12298
+ },
12299
+ {
12300
+ onSuccess: () => {
12301
+ ui.toast.success("Sales channel updated");
12302
+ handleSuccess();
12303
+ },
12304
+ onError: (error) => {
12305
+ ui.toast.error(error.message);
12306
+ }
12307
+ }
12308
+ );
12309
+ });
12310
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12311
+ KeyboundForm,
12312
+ {
12313
+ className: "flex flex-1 flex-col overflow-hidden",
12314
+ onSubmit,
12315
+ children: [
12316
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12317
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12318
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12319
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12320
+ ] }) })
12321
+ ]
12322
+ }
12323
+ ) });
12324
+ };
12325
+ const SalesChannelField = ({ control, order }) => {
12326
+ const salesChannels = useComboboxData({
12327
+ queryFn: async (params) => {
12328
+ return await sdk.admin.salesChannel.list(params);
12329
+ },
12330
+ queryKey: ["sales-channels"],
12331
+ getOptions: (data) => {
12332
+ return data.sales_channels.map((salesChannel) => ({
12333
+ label: salesChannel.name,
12334
+ value: salesChannel.id
12335
+ }));
12336
+ },
12337
+ defaultValue: order.sales_channel_id || void 0
12338
+ });
12339
+ return /* @__PURE__ */ jsxRuntime.jsx(
12340
+ Form$2.Field,
12341
+ {
12342
+ control,
12343
+ name: "sales_channel_id",
12344
+ render: ({ field }) => {
12345
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12346
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12347
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12348
+ Combobox,
12349
+ {
12350
+ options: salesChannels.options,
12351
+ fetchNextPage: salesChannels.fetchNextPage,
12352
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12353
+ searchValue: salesChannels.searchValue,
12354
+ onSearchValueChange: salesChannels.onSearchValueChange,
12355
+ placeholder: "Select sales channel",
12356
+ ...field
12357
+ }
12358
+ ) }),
12359
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12360
+ ] });
12361
+ }
12362
+ }
12363
+ );
12364
+ };
12365
+ const schema$2 = objectType({
12366
+ sales_channel_id: stringType().min(1)
12367
+ });
12364
12368
  const ShippingAddress = () => {
12365
12369
  const { id } = reactRouterDom.useParams();
12366
12370
  const { order, isPending, isError, error } = useOrder(id, {
@@ -13064,14 +13068,14 @@ const routeModule = {
13064
13068
  Component: BillingAddress,
13065
13069
  path: "/draft-orders/:id/billing-address"
13066
13070
  },
13067
- {
13068
- Component: Email,
13069
- path: "/draft-orders/:id/email"
13070
- },
13071
13071
  {
13072
13072
  Component: CustomItems,
13073
13073
  path: "/draft-orders/:id/custom-items"
13074
13074
  },
13075
+ {
13076
+ Component: Email,
13077
+ path: "/draft-orders/:id/email"
13078
+ },
13075
13079
  {
13076
13080
  Component: Items,
13077
13081
  path: "/draft-orders/:id/items"
@@ -13084,14 +13088,14 @@ const routeModule = {
13084
13088
  Component: Promotions,
13085
13089
  path: "/draft-orders/:id/promotions"
13086
13090
  },
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"
13094
13094
  },
13095
+ {
13096
+ Component: SalesChannel,
13097
+ path: "/draft-orders/:id/sales-channel"
13098
+ },
13095
13099
  {
13096
13100
  Component: ShippingAddress,
13097
13101
  path: "/draft-orders/:id/shipping-address"
@@ -345,10 +345,14 @@ const DataTableAction = ({
345
345
  }
346
346
  return /* @__PURE__ */ jsx(Button, { ...buttonProps, onClick: props.onClick, children: label });
347
347
  };
348
+ const backendUrl = __BACKEND_URL__ ?? "/";
349
+ const authType = __AUTH_TYPE__ ?? "session";
350
+ const jwtTokenStorageKey = __JWT_TOKEN_STORAGE_KEY__ || void 0;
348
351
  const sdk = new Medusa({
349
- baseUrl: __BACKEND_URL__ || "/",
352
+ baseUrl: backendUrl,
350
353
  auth: {
351
- type: "session"
354
+ type: authType,
355
+ jwtTokenStorageKey
352
356
  }
353
357
  });
354
358
  const CUSTOMER_QUERY_KEY = "customers";
@@ -9751,6 +9755,27 @@ const BillingAddressForm = ({ order }) => {
9751
9755
  ) });
9752
9756
  };
9753
9757
  const schema$5 = addressSchema;
9758
+ const CustomItems = () => {
9759
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9760
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9761
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9762
+ ] });
9763
+ };
9764
+ const CustomItemsForm = () => {
9765
+ const form = useForm({
9766
+ resolver: zodResolver(schema$4)
9767
+ });
9768
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9769
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9770
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9771
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9772
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9773
+ ] }) })
9774
+ ] }) });
9775
+ };
9776
+ const schema$4 = objectType({
9777
+ email: stringType().email()
9778
+ });
9754
9779
  const Email = () => {
9755
9780
  const { id } = useParams();
9756
9781
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9773,7 +9798,7 @@ const EmailForm = ({ order }) => {
9773
9798
  defaultValues: {
9774
9799
  email: order.email ?? ""
9775
9800
  },
9776
- resolver: zodResolver(schema$4)
9801
+ resolver: zodResolver(schema$3)
9777
9802
  });
9778
9803
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9779
9804
  const { handleSuccess } = useRouteModal();
@@ -9816,27 +9841,6 @@ const EmailForm = ({ order }) => {
9816
9841
  }
9817
9842
  ) });
9818
9843
  };
9819
- const schema$4 = objectType({
9820
- email: stringType().email()
9821
- });
9822
- const CustomItems = () => {
9823
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9824
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9825
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9826
- ] });
9827
- };
9828
- const CustomItemsForm = () => {
9829
- const form = useForm({
9830
- resolver: zodResolver(schema$3)
9831
- });
9832
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9833
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9834
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9835
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9836
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9837
- ] }) })
9838
- ] }) });
9839
- };
9840
9844
  const schema$3 = objectType({
9841
9845
  email: stringType().email()
9842
9846
  });
@@ -11441,112 +11445,6 @@ function getPromotionIds(items, shippingMethods) {
11441
11445
  }
11442
11446
  return Array.from(promotionIds);
11443
11447
  }
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
- });
11550
11448
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11551
11449
  const Shipping = () => {
11552
11450
  var _a;
@@ -12354,6 +12252,112 @@ const CustomAmountField = ({
12354
12252
  }
12355
12253
  );
12356
12254
  };
12255
+ const SalesChannel = () => {
12256
+ const { id } = useParams();
12257
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12258
+ id,
12259
+ {
12260
+ fields: "+sales_channel_id"
12261
+ },
12262
+ {
12263
+ enabled: !!id
12264
+ }
12265
+ );
12266
+ if (isError) {
12267
+ throw error;
12268
+ }
12269
+ const ISrEADY = !!draft_order && !isPending;
12270
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12271
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12272
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12273
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12274
+ ] }),
12275
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12276
+ ] });
12277
+ };
12278
+ const SalesChannelForm = ({ order }) => {
12279
+ const form = useForm({
12280
+ defaultValues: {
12281
+ sales_channel_id: order.sales_channel_id || ""
12282
+ },
12283
+ resolver: zodResolver(schema$2)
12284
+ });
12285
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12286
+ const { handleSuccess } = useRouteModal();
12287
+ const onSubmit = form.handleSubmit(async (data) => {
12288
+ await mutateAsync(
12289
+ {
12290
+ sales_channel_id: data.sales_channel_id
12291
+ },
12292
+ {
12293
+ onSuccess: () => {
12294
+ toast.success("Sales channel updated");
12295
+ handleSuccess();
12296
+ },
12297
+ onError: (error) => {
12298
+ toast.error(error.message);
12299
+ }
12300
+ }
12301
+ );
12302
+ });
12303
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12304
+ KeyboundForm,
12305
+ {
12306
+ className: "flex flex-1 flex-col overflow-hidden",
12307
+ onSubmit,
12308
+ children: [
12309
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12310
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12311
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12312
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12313
+ ] }) })
12314
+ ]
12315
+ }
12316
+ ) });
12317
+ };
12318
+ const SalesChannelField = ({ control, order }) => {
12319
+ const salesChannels = useComboboxData({
12320
+ queryFn: async (params) => {
12321
+ return await sdk.admin.salesChannel.list(params);
12322
+ },
12323
+ queryKey: ["sales-channels"],
12324
+ getOptions: (data) => {
12325
+ return data.sales_channels.map((salesChannel) => ({
12326
+ label: salesChannel.name,
12327
+ value: salesChannel.id
12328
+ }));
12329
+ },
12330
+ defaultValue: order.sales_channel_id || void 0
12331
+ });
12332
+ return /* @__PURE__ */ jsx(
12333
+ Form$2.Field,
12334
+ {
12335
+ control,
12336
+ name: "sales_channel_id",
12337
+ render: ({ field }) => {
12338
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12339
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12340
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12341
+ Combobox,
12342
+ {
12343
+ options: salesChannels.options,
12344
+ fetchNextPage: salesChannels.fetchNextPage,
12345
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12346
+ searchValue: salesChannels.searchValue,
12347
+ onSearchValueChange: salesChannels.onSearchValueChange,
12348
+ placeholder: "Select sales channel",
12349
+ ...field
12350
+ }
12351
+ ) }),
12352
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12353
+ ] });
12354
+ }
12355
+ }
12356
+ );
12357
+ };
12358
+ const schema$2 = objectType({
12359
+ sales_channel_id: stringType().min(1)
12360
+ });
12357
12361
  const ShippingAddress = () => {
12358
12362
  const { id } = useParams();
12359
12363
  const { order, isPending, isError, error } = useOrder(id, {
@@ -13057,14 +13061,14 @@ const routeModule = {
13057
13061
  Component: BillingAddress,
13058
13062
  path: "/draft-orders/:id/billing-address"
13059
13063
  },
13060
- {
13061
- Component: Email,
13062
- path: "/draft-orders/:id/email"
13063
- },
13064
13064
  {
13065
13065
  Component: CustomItems,
13066
13066
  path: "/draft-orders/:id/custom-items"
13067
13067
  },
13068
+ {
13069
+ Component: Email,
13070
+ path: "/draft-orders/:id/email"
13071
+ },
13068
13072
  {
13069
13073
  Component: Items,
13070
13074
  path: "/draft-orders/:id/items"
@@ -13077,14 +13081,14 @@ const routeModule = {
13077
13081
  Component: Promotions,
13078
13082
  path: "/draft-orders/:id/promotions"
13079
13083
  },
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"
13087
13087
  },
13088
+ {
13089
+ Component: SalesChannel,
13090
+ path: "/draft-orders/:id/sales-channel"
13091
+ },
13088
13092
  {
13089
13093
  Component: ShippingAddress,
13090
13094
  path: "/draft-orders/:id/shipping-address"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.11.4-preview-20251111060141",
3
+ "version": "2.11.4-preview-20251111120137",
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.4-preview-20251111060141",
40
+ "@medusajs/js-sdk": "2.11.4-preview-20251111120137",
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,22 +48,22 @@
48
48
  "react-hook-form": "7.49.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@medusajs/admin-sdk": "2.11.4-preview-20251111060141",
52
- "@medusajs/cli": "2.11.4-preview-20251111060141",
53
- "@medusajs/framework": "2.11.4-preview-20251111060141",
54
- "@medusajs/icons": "2.11.4-preview-20251111060141",
55
- "@medusajs/test-utils": "2.11.4-preview-20251111060141",
56
- "@medusajs/types": "2.11.4-preview-20251111060141",
57
- "@medusajs/ui": "4.0.28-preview-20251111060141",
58
- "@medusajs/ui-preset": "2.11.4-preview-20251111060141"
51
+ "@medusajs/admin-sdk": "2.11.4-preview-20251111120137",
52
+ "@medusajs/cli": "2.11.4-preview-20251111120137",
53
+ "@medusajs/framework": "2.11.4-preview-20251111120137",
54
+ "@medusajs/icons": "2.11.4-preview-20251111120137",
55
+ "@medusajs/test-utils": "2.11.4-preview-20251111120137",
56
+ "@medusajs/types": "2.11.4-preview-20251111120137",
57
+ "@medusajs/ui": "4.0.28-preview-20251111120137",
58
+ "@medusajs/ui-preset": "2.11.4-preview-20251111120137"
59
59
  },
60
60
  "peerDependencies": {
61
- "@medusajs/admin-sdk": "2.11.4-preview-20251111060141",
62
- "@medusajs/cli": "2.11.4-preview-20251111060141",
63
- "@medusajs/framework": "2.11.4-preview-20251111060141",
64
- "@medusajs/icons": "2.11.4-preview-20251111060141",
65
- "@medusajs/test-utils": "2.11.4-preview-20251111060141",
66
- "@medusajs/ui": "4.0.28-preview-20251111060141",
61
+ "@medusajs/admin-sdk": "2.11.4-preview-20251111120137",
62
+ "@medusajs/cli": "2.11.4-preview-20251111120137",
63
+ "@medusajs/framework": "2.11.4-preview-20251111120137",
64
+ "@medusajs/icons": "2.11.4-preview-20251111120137",
65
+ "@medusajs/test-utils": "2.11.4-preview-20251111120137",
66
+ "@medusajs/ui": "4.0.28-preview-20251111120137",
67
67
  "react": "^18.3.1",
68
68
  "react-dom": "^18.3.1",
69
69
  "react-router-dom": "6.20.1"