@medusajs/draft-order 2.12.4-snapshot-20251217150114 → 2.12.4-snapshot-20251218091536

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.
@@ -9762,6 +9762,27 @@ const BillingAddressForm = ({ order }) => {
9762
9762
  ) });
9763
9763
  };
9764
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
+ });
9765
9786
  const Email = () => {
9766
9787
  const { id } = reactRouterDom.useParams();
9767
9788
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9784,7 +9805,7 @@ const EmailForm = ({ order }) => {
9784
9805
  defaultValues: {
9785
9806
  email: order.email ?? ""
9786
9807
  },
9787
- resolver: zod.zodResolver(schema$4)
9808
+ resolver: zod.zodResolver(schema$3)
9788
9809
  });
9789
9810
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9790
9811
  const { handleSuccess } = useRouteModal();
@@ -9827,27 +9848,6 @@ const EmailForm = ({ order }) => {
9827
9848
  }
9828
9849
  ) });
9829
9850
  };
9830
- const schema$4 = objectType({
9831
- email: stringType().email()
9832
- });
9833
- const CustomItems = () => {
9834
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9835
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9836
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9837
- ] });
9838
- };
9839
- const CustomItemsForm = () => {
9840
- const form = reactHookForm.useForm({
9841
- resolver: zod.zodResolver(schema$3)
9842
- });
9843
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9844
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9845
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9846
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9847
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9848
- ] }) })
9849
- ] }) });
9850
- };
9851
9851
  const schema$3 = objectType({
9852
9852
  email: stringType().email()
9853
9853
  });
@@ -12259,112 +12259,6 @@ const CustomAmountField = ({
12259
12259
  }
12260
12260
  );
12261
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
- });
12368
12262
  const ShippingAddress = () => {
12369
12263
  const { id } = reactRouterDom.useParams();
12370
12264
  const { order, isPending, isError, error } = useOrder(id, {
@@ -12397,7 +12291,7 @@ const ShippingAddressForm = ({ order }) => {
12397
12291
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12398
12292
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12399
12293
  },
12400
- resolver: zod.zodResolver(schema$1)
12294
+ resolver: zod.zodResolver(schema$2)
12401
12295
  });
12402
12296
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12403
12297
  const { handleSuccess } = useRouteModal();
@@ -12567,7 +12461,113 @@ const ShippingAddressForm = ({ order }) => {
12567
12461
  }
12568
12462
  ) });
12569
12463
  };
12570
- const schema$1 = addressSchema;
12464
+ const schema$2 = addressSchema;
12465
+ const SalesChannel = () => {
12466
+ const { id } = reactRouterDom.useParams();
12467
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12468
+ id,
12469
+ {
12470
+ fields: "+sales_channel_id"
12471
+ },
12472
+ {
12473
+ enabled: !!id
12474
+ }
12475
+ );
12476
+ if (isError) {
12477
+ throw error;
12478
+ }
12479
+ const ISrEADY = !!draft_order && !isPending;
12480
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12481
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12482
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12483
+ /* @__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" }) })
12484
+ ] }),
12485
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12486
+ ] });
12487
+ };
12488
+ const SalesChannelForm = ({ order }) => {
12489
+ const form = reactHookForm.useForm({
12490
+ defaultValues: {
12491
+ sales_channel_id: order.sales_channel_id || ""
12492
+ },
12493
+ resolver: zod.zodResolver(schema$1)
12494
+ });
12495
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12496
+ const { handleSuccess } = useRouteModal();
12497
+ const onSubmit = form.handleSubmit(async (data) => {
12498
+ await mutateAsync(
12499
+ {
12500
+ sales_channel_id: data.sales_channel_id
12501
+ },
12502
+ {
12503
+ onSuccess: () => {
12504
+ ui.toast.success("Sales channel updated");
12505
+ handleSuccess();
12506
+ },
12507
+ onError: (error) => {
12508
+ ui.toast.error(error.message);
12509
+ }
12510
+ }
12511
+ );
12512
+ });
12513
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12514
+ KeyboundForm,
12515
+ {
12516
+ className: "flex flex-1 flex-col overflow-hidden",
12517
+ onSubmit,
12518
+ children: [
12519
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12520
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12521
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12522
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12523
+ ] }) })
12524
+ ]
12525
+ }
12526
+ ) });
12527
+ };
12528
+ const SalesChannelField = ({ control, order }) => {
12529
+ const salesChannels = useComboboxData({
12530
+ queryFn: async (params) => {
12531
+ return await sdk.admin.salesChannel.list(params);
12532
+ },
12533
+ queryKey: ["sales-channels"],
12534
+ getOptions: (data) => {
12535
+ return data.sales_channels.map((salesChannel) => ({
12536
+ label: salesChannel.name,
12537
+ value: salesChannel.id
12538
+ }));
12539
+ },
12540
+ defaultValue: order.sales_channel_id || void 0
12541
+ });
12542
+ return /* @__PURE__ */ jsxRuntime.jsx(
12543
+ Form$2.Field,
12544
+ {
12545
+ control,
12546
+ name: "sales_channel_id",
12547
+ render: ({ field }) => {
12548
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12549
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12550
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12551
+ Combobox,
12552
+ {
12553
+ options: salesChannels.options,
12554
+ fetchNextPage: salesChannels.fetchNextPage,
12555
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12556
+ searchValue: salesChannels.searchValue,
12557
+ onSearchValueChange: salesChannels.onSearchValueChange,
12558
+ placeholder: "Select sales channel",
12559
+ ...field
12560
+ }
12561
+ ) }),
12562
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12563
+ ] });
12564
+ }
12565
+ }
12566
+ );
12567
+ };
12568
+ const schema$1 = objectType({
12569
+ sales_channel_id: stringType().min(1)
12570
+ });
12571
12571
  const TransferOwnership = () => {
12572
12572
  const { id } = reactRouterDom.useParams();
12573
12573
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -13068,14 +13068,14 @@ const routeModule = {
13068
13068
  Component: BillingAddress,
13069
13069
  path: "/draft-orders/:id/billing-address"
13070
13070
  },
13071
- {
13072
- Component: Email,
13073
- path: "/draft-orders/:id/email"
13074
- },
13075
13071
  {
13076
13072
  Component: CustomItems,
13077
13073
  path: "/draft-orders/:id/custom-items"
13078
13074
  },
13075
+ {
13076
+ Component: Email,
13077
+ path: "/draft-orders/:id/email"
13078
+ },
13079
13079
  {
13080
13080
  Component: Items,
13081
13081
  path: "/draft-orders/:id/items"
@@ -13092,14 +13092,14 @@ const routeModule = {
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
- },
13099
13095
  {
13100
13096
  Component: ShippingAddress,
13101
13097
  path: "/draft-orders/:id/shipping-address"
13102
13098
  },
13099
+ {
13100
+ Component: SalesChannel,
13101
+ path: "/draft-orders/:id/sales-channel"
13102
+ },
13103
13103
  {
13104
13104
  Component: TransferOwnership,
13105
13105
  path: "/draft-orders/:id/transfer-ownership"
@@ -9755,6 +9755,27 @@ const BillingAddressForm = ({ order }) => {
9755
9755
  ) });
9756
9756
  };
9757
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
+ });
9758
9779
  const Email = () => {
9759
9780
  const { id } = useParams();
9760
9781
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9777,7 +9798,7 @@ const EmailForm = ({ order }) => {
9777
9798
  defaultValues: {
9778
9799
  email: order.email ?? ""
9779
9800
  },
9780
- resolver: zodResolver(schema$4)
9801
+ resolver: zodResolver(schema$3)
9781
9802
  });
9782
9803
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9783
9804
  const { handleSuccess } = useRouteModal();
@@ -9820,27 +9841,6 @@ const EmailForm = ({ order }) => {
9820
9841
  }
9821
9842
  ) });
9822
9843
  };
9823
- const schema$4 = objectType({
9824
- email: stringType().email()
9825
- });
9826
- const CustomItems = () => {
9827
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9828
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9829
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9830
- ] });
9831
- };
9832
- const CustomItemsForm = () => {
9833
- const form = useForm({
9834
- resolver: zodResolver(schema$3)
9835
- });
9836
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9837
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9838
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9839
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9840
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9841
- ] }) })
9842
- ] }) });
9843
- };
9844
9844
  const schema$3 = objectType({
9845
9845
  email: stringType().email()
9846
9846
  });
@@ -12252,112 +12252,6 @@ const CustomAmountField = ({
12252
12252
  }
12253
12253
  );
12254
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
- });
12361
12255
  const ShippingAddress = () => {
12362
12256
  const { id } = useParams();
12363
12257
  const { order, isPending, isError, error } = useOrder(id, {
@@ -12390,7 +12284,7 @@ const ShippingAddressForm = ({ order }) => {
12390
12284
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12391
12285
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12392
12286
  },
12393
- resolver: zodResolver(schema$1)
12287
+ resolver: zodResolver(schema$2)
12394
12288
  });
12395
12289
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12396
12290
  const { handleSuccess } = useRouteModal();
@@ -12560,7 +12454,113 @@ const ShippingAddressForm = ({ order }) => {
12560
12454
  }
12561
12455
  ) });
12562
12456
  };
12563
- const schema$1 = addressSchema;
12457
+ const schema$2 = addressSchema;
12458
+ const SalesChannel = () => {
12459
+ const { id } = useParams();
12460
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12461
+ id,
12462
+ {
12463
+ fields: "+sales_channel_id"
12464
+ },
12465
+ {
12466
+ enabled: !!id
12467
+ }
12468
+ );
12469
+ if (isError) {
12470
+ throw error;
12471
+ }
12472
+ const ISrEADY = !!draft_order && !isPending;
12473
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12474
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12475
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12476
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12477
+ ] }),
12478
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12479
+ ] });
12480
+ };
12481
+ const SalesChannelForm = ({ order }) => {
12482
+ const form = useForm({
12483
+ defaultValues: {
12484
+ sales_channel_id: order.sales_channel_id || ""
12485
+ },
12486
+ resolver: zodResolver(schema$1)
12487
+ });
12488
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12489
+ const { handleSuccess } = useRouteModal();
12490
+ const onSubmit = form.handleSubmit(async (data) => {
12491
+ await mutateAsync(
12492
+ {
12493
+ sales_channel_id: data.sales_channel_id
12494
+ },
12495
+ {
12496
+ onSuccess: () => {
12497
+ toast.success("Sales channel updated");
12498
+ handleSuccess();
12499
+ },
12500
+ onError: (error) => {
12501
+ toast.error(error.message);
12502
+ }
12503
+ }
12504
+ );
12505
+ });
12506
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12507
+ KeyboundForm,
12508
+ {
12509
+ className: "flex flex-1 flex-col overflow-hidden",
12510
+ onSubmit,
12511
+ children: [
12512
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12513
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12514
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12515
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12516
+ ] }) })
12517
+ ]
12518
+ }
12519
+ ) });
12520
+ };
12521
+ const SalesChannelField = ({ control, order }) => {
12522
+ const salesChannels = useComboboxData({
12523
+ queryFn: async (params) => {
12524
+ return await sdk.admin.salesChannel.list(params);
12525
+ },
12526
+ queryKey: ["sales-channels"],
12527
+ getOptions: (data) => {
12528
+ return data.sales_channels.map((salesChannel) => ({
12529
+ label: salesChannel.name,
12530
+ value: salesChannel.id
12531
+ }));
12532
+ },
12533
+ defaultValue: order.sales_channel_id || void 0
12534
+ });
12535
+ return /* @__PURE__ */ jsx(
12536
+ Form$2.Field,
12537
+ {
12538
+ control,
12539
+ name: "sales_channel_id",
12540
+ render: ({ field }) => {
12541
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12542
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12543
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12544
+ Combobox,
12545
+ {
12546
+ options: salesChannels.options,
12547
+ fetchNextPage: salesChannels.fetchNextPage,
12548
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12549
+ searchValue: salesChannels.searchValue,
12550
+ onSearchValueChange: salesChannels.onSearchValueChange,
12551
+ placeholder: "Select sales channel",
12552
+ ...field
12553
+ }
12554
+ ) }),
12555
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12556
+ ] });
12557
+ }
12558
+ }
12559
+ );
12560
+ };
12561
+ const schema$1 = objectType({
12562
+ sales_channel_id: stringType().min(1)
12563
+ });
12564
12564
  const TransferOwnership = () => {
12565
12565
  const { id } = useParams();
12566
12566
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -13061,14 +13061,14 @@ const routeModule = {
13061
13061
  Component: BillingAddress,
13062
13062
  path: "/draft-orders/:id/billing-address"
13063
13063
  },
13064
- {
13065
- Component: Email,
13066
- path: "/draft-orders/:id/email"
13067
- },
13068
13064
  {
13069
13065
  Component: CustomItems,
13070
13066
  path: "/draft-orders/:id/custom-items"
13071
13067
  },
13068
+ {
13069
+ Component: Email,
13070
+ path: "/draft-orders/:id/email"
13071
+ },
13072
13072
  {
13073
13073
  Component: Items,
13074
13074
  path: "/draft-orders/:id/items"
@@ -13085,14 +13085,14 @@ const routeModule = {
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
- },
13092
13088
  {
13093
13089
  Component: ShippingAddress,
13094
13090
  path: "/draft-orders/:id/shipping-address"
13095
13091
  },
13092
+ {
13093
+ Component: SalesChannel,
13094
+ path: "/draft-orders/:id/sales-channel"
13095
+ },
13096
13096
  {
13097
13097
  Component: TransferOwnership,
13098
13098
  path: "/draft-orders/:id/transfer-ownership"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.12.4-snapshot-20251217150114",
3
+ "version": "2.12.4-snapshot-20251218091536",
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.12.4-snapshot-20251217150114",
45
+ "@medusajs/js-sdk": "2.12.4-snapshot-20251218091536",
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.12.4-snapshot-20251217150114",
57
- "@medusajs/cli": "2.12.4-snapshot-20251217150114",
58
- "@medusajs/framework": "2.12.4-snapshot-20251217150114",
59
- "@medusajs/icons": "2.12.4-snapshot-20251217150114",
60
- "@medusajs/test-utils": "2.12.4-snapshot-20251217150114",
61
- "@medusajs/types": "2.12.4-snapshot-20251217150114",
62
- "@medusajs/ui": "4.0.32-snapshot-20251217150114",
63
- "@medusajs/ui-preset": "2.12.4-snapshot-20251217150114"
56
+ "@medusajs/admin-sdk": "2.12.4-snapshot-20251218091536",
57
+ "@medusajs/cli": "2.12.4-snapshot-20251218091536",
58
+ "@medusajs/framework": "2.12.4-snapshot-20251218091536",
59
+ "@medusajs/icons": "2.12.4-snapshot-20251218091536",
60
+ "@medusajs/test-utils": "2.12.4-snapshot-20251218091536",
61
+ "@medusajs/types": "2.12.4-snapshot-20251218091536",
62
+ "@medusajs/ui": "4.0.32-snapshot-20251218091536",
63
+ "@medusajs/ui-preset": "2.12.4-snapshot-20251218091536"
64
64
  },
65
65
  "peerDependencies": {
66
- "@medusajs/admin-sdk": "2.12.4-snapshot-20251217150114",
67
- "@medusajs/cli": "2.12.4-snapshot-20251217150114",
68
- "@medusajs/framework": "2.12.4-snapshot-20251217150114",
69
- "@medusajs/icons": "2.12.4-snapshot-20251217150114",
70
- "@medusajs/test-utils": "2.12.4-snapshot-20251217150114",
71
- "@medusajs/ui": "4.0.32-snapshot-20251217150114",
66
+ "@medusajs/admin-sdk": "2.12.4-snapshot-20251218091536",
67
+ "@medusajs/cli": "2.12.4-snapshot-20251218091536",
68
+ "@medusajs/framework": "2.12.4-snapshot-20251218091536",
69
+ "@medusajs/icons": "2.12.4-snapshot-20251218091536",
70
+ "@medusajs/test-utils": "2.12.4-snapshot-20251218091536",
71
+ "@medusajs/ui": "4.0.32-snapshot-20251218091536",
72
72
  "react": "^18.3.1",
73
73
  "react-dom": "^18.3.1",
74
74
  "react-router-dom": "6.20.1"