@medusajs/draft-order 2.10.3-preview-20250913210149 → 2.10.3-snapshot-20250913212755

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.
@@ -9831,6 +9831,27 @@ const EmailForm = ({ order }) => {
9831
9831
  const schema$4 = objectType({
9832
9832
  email: stringType().email()
9833
9833
  });
9834
+ const CustomItems = () => {
9835
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9836
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9837
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9838
+ ] });
9839
+ };
9840
+ const CustomItemsForm = () => {
9841
+ const form = reactHookForm.useForm({
9842
+ resolver: zod.zodResolver(schema$3)
9843
+ });
9844
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9845
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9846
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9847
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9848
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9849
+ ] }) })
9850
+ ] }) });
9851
+ };
9852
+ const schema$3 = objectType({
9853
+ email: stringType().email()
9854
+ });
9834
9855
  const NumberInput = React.forwardRef(
9835
9856
  ({
9836
9857
  value,
@@ -11432,112 +11453,6 @@ function getPromotionIds(items, shippingMethods) {
11432
11453
  }
11433
11454
  return Array.from(promotionIds);
11434
11455
  }
11435
- const SalesChannel = () => {
11436
- const { id } = reactRouterDom.useParams();
11437
- const { draft_order, isPending, isError, error } = useDraftOrder(
11438
- id,
11439
- {
11440
- fields: "+sales_channel_id"
11441
- },
11442
- {
11443
- enabled: !!id
11444
- }
11445
- );
11446
- if (isError) {
11447
- throw error;
11448
- }
11449
- const ISrEADY = !!draft_order && !isPending;
11450
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11451
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11452
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11453
- /* @__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" }) })
11454
- ] }),
11455
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11456
- ] });
11457
- };
11458
- const SalesChannelForm = ({ order }) => {
11459
- const form = reactHookForm.useForm({
11460
- defaultValues: {
11461
- sales_channel_id: order.sales_channel_id || ""
11462
- },
11463
- resolver: zod.zodResolver(schema$3)
11464
- });
11465
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11466
- const { handleSuccess } = useRouteModal();
11467
- const onSubmit = form.handleSubmit(async (data) => {
11468
- await mutateAsync(
11469
- {
11470
- sales_channel_id: data.sales_channel_id
11471
- },
11472
- {
11473
- onSuccess: () => {
11474
- ui.toast.success("Sales channel updated");
11475
- handleSuccess();
11476
- },
11477
- onError: (error) => {
11478
- ui.toast.error(error.message);
11479
- }
11480
- }
11481
- );
11482
- });
11483
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11484
- KeyboundForm,
11485
- {
11486
- className: "flex flex-1 flex-col overflow-hidden",
11487
- onSubmit,
11488
- children: [
11489
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11490
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11491
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11492
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11493
- ] }) })
11494
- ]
11495
- }
11496
- ) });
11497
- };
11498
- const SalesChannelField = ({ control, order }) => {
11499
- const salesChannels = useComboboxData({
11500
- queryFn: async (params) => {
11501
- return await sdk.admin.salesChannel.list(params);
11502
- },
11503
- queryKey: ["sales-channels"],
11504
- getOptions: (data) => {
11505
- return data.sales_channels.map((salesChannel) => ({
11506
- label: salesChannel.name,
11507
- value: salesChannel.id
11508
- }));
11509
- },
11510
- defaultValue: order.sales_channel_id || void 0
11511
- });
11512
- return /* @__PURE__ */ jsxRuntime.jsx(
11513
- Form$2.Field,
11514
- {
11515
- control,
11516
- name: "sales_channel_id",
11517
- render: ({ field }) => {
11518
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11519
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11520
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11521
- Combobox,
11522
- {
11523
- options: salesChannels.options,
11524
- fetchNextPage: salesChannels.fetchNextPage,
11525
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11526
- searchValue: salesChannels.searchValue,
11527
- onSearchValueChange: salesChannels.onSearchValueChange,
11528
- placeholder: "Select sales channel",
11529
- ...field
11530
- }
11531
- ) }),
11532
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11533
- ] });
11534
- }
11535
- }
11536
- );
11537
- };
11538
- const schema$3 = objectType({
11539
- sales_channel_id: stringType().min(1)
11540
- });
11541
11456
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11542
11457
  const Shipping = () => {
11543
11458
  var _a;
@@ -12345,6 +12260,112 @@ const CustomAmountField = ({
12345
12260
  }
12346
12261
  );
12347
12262
  };
12263
+ const SalesChannel = () => {
12264
+ const { id } = reactRouterDom.useParams();
12265
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12266
+ id,
12267
+ {
12268
+ fields: "+sales_channel_id"
12269
+ },
12270
+ {
12271
+ enabled: !!id
12272
+ }
12273
+ );
12274
+ if (isError) {
12275
+ throw error;
12276
+ }
12277
+ const ISrEADY = !!draft_order && !isPending;
12278
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12279
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12280
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12281
+ /* @__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" }) })
12282
+ ] }),
12283
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12284
+ ] });
12285
+ };
12286
+ const SalesChannelForm = ({ order }) => {
12287
+ const form = reactHookForm.useForm({
12288
+ defaultValues: {
12289
+ sales_channel_id: order.sales_channel_id || ""
12290
+ },
12291
+ resolver: zod.zodResolver(schema$2)
12292
+ });
12293
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12294
+ const { handleSuccess } = useRouteModal();
12295
+ const onSubmit = form.handleSubmit(async (data) => {
12296
+ await mutateAsync(
12297
+ {
12298
+ sales_channel_id: data.sales_channel_id
12299
+ },
12300
+ {
12301
+ onSuccess: () => {
12302
+ ui.toast.success("Sales channel updated");
12303
+ handleSuccess();
12304
+ },
12305
+ onError: (error) => {
12306
+ ui.toast.error(error.message);
12307
+ }
12308
+ }
12309
+ );
12310
+ });
12311
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12312
+ KeyboundForm,
12313
+ {
12314
+ className: "flex flex-1 flex-col overflow-hidden",
12315
+ onSubmit,
12316
+ children: [
12317
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12318
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12319
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12320
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12321
+ ] }) })
12322
+ ]
12323
+ }
12324
+ ) });
12325
+ };
12326
+ const SalesChannelField = ({ control, order }) => {
12327
+ const salesChannels = useComboboxData({
12328
+ queryFn: async (params) => {
12329
+ return await sdk.admin.salesChannel.list(params);
12330
+ },
12331
+ queryKey: ["sales-channels"],
12332
+ getOptions: (data) => {
12333
+ return data.sales_channels.map((salesChannel) => ({
12334
+ label: salesChannel.name,
12335
+ value: salesChannel.id
12336
+ }));
12337
+ },
12338
+ defaultValue: order.sales_channel_id || void 0
12339
+ });
12340
+ return /* @__PURE__ */ jsxRuntime.jsx(
12341
+ Form$2.Field,
12342
+ {
12343
+ control,
12344
+ name: "sales_channel_id",
12345
+ render: ({ field }) => {
12346
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12347
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12348
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12349
+ Combobox,
12350
+ {
12351
+ options: salesChannels.options,
12352
+ fetchNextPage: salesChannels.fetchNextPage,
12353
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12354
+ searchValue: salesChannels.searchValue,
12355
+ onSearchValueChange: salesChannels.onSearchValueChange,
12356
+ placeholder: "Select sales channel",
12357
+ ...field
12358
+ }
12359
+ ) }),
12360
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12361
+ ] });
12362
+ }
12363
+ }
12364
+ );
12365
+ };
12366
+ const schema$2 = objectType({
12367
+ sales_channel_id: stringType().min(1)
12368
+ });
12348
12369
  const ShippingAddress = () => {
12349
12370
  const { id } = reactRouterDom.useParams();
12350
12371
  const { order, isPending, isError, error } = useOrder(id, {
@@ -12377,7 +12398,7 @@ const ShippingAddressForm = ({ order }) => {
12377
12398
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12378
12399
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12379
12400
  },
12380
- resolver: zod.zodResolver(schema$2)
12401
+ resolver: zod.zodResolver(schema$1)
12381
12402
  });
12382
12403
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12383
12404
  const { handleSuccess } = useRouteModal();
@@ -12547,7 +12568,7 @@ const ShippingAddressForm = ({ order }) => {
12547
12568
  }
12548
12569
  ) });
12549
12570
  };
12550
- const schema$2 = addressSchema;
12571
+ const schema$1 = addressSchema;
12551
12572
  const TransferOwnership = () => {
12552
12573
  const { id } = reactRouterDom.useParams();
12553
12574
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12571,7 +12592,7 @@ const TransferOwnershipForm = ({ order }) => {
12571
12592
  defaultValues: {
12572
12593
  customer_id: order.customer_id || ""
12573
12594
  },
12574
- resolver: zod.zodResolver(schema$1)
12595
+ resolver: zod.zodResolver(schema)
12575
12596
  });
12576
12597
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12577
12598
  const { handleSuccess } = useRouteModal();
@@ -13021,29 +13042,8 @@ const Illustration = () => {
13021
13042
  }
13022
13043
  );
13023
13044
  };
13024
- const schema$1 = objectType({
13025
- customer_id: stringType().min(1)
13026
- });
13027
- const CustomItems = () => {
13028
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
13029
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
13030
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
13031
- ] });
13032
- };
13033
- const CustomItemsForm = () => {
13034
- const form = reactHookForm.useForm({
13035
- resolver: zod.zodResolver(schema)
13036
- });
13037
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13038
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
13039
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13040
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13041
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
13042
- ] }) })
13043
- ] }) });
13044
- };
13045
13045
  const schema = objectType({
13046
- email: stringType().email()
13046
+ customer_id: stringType().min(1)
13047
13047
  });
13048
13048
  const widgetModule = { widgets: [] };
13049
13049
  const routeModule = {
@@ -13073,6 +13073,10 @@ const routeModule = {
13073
13073
  Component: Email,
13074
13074
  path: "/draft-orders/:id/email"
13075
13075
  },
13076
+ {
13077
+ Component: CustomItems,
13078
+ path: "/draft-orders/:id/custom-items"
13079
+ },
13076
13080
  {
13077
13081
  Component: Items,
13078
13082
  path: "/draft-orders/:id/items"
@@ -13085,14 +13089,14 @@ const routeModule = {
13085
13089
  Component: Promotions,
13086
13090
  path: "/draft-orders/:id/promotions"
13087
13091
  },
13088
- {
13089
- Component: SalesChannel,
13090
- path: "/draft-orders/:id/sales-channel"
13091
- },
13092
13092
  {
13093
13093
  Component: Shipping,
13094
13094
  path: "/draft-orders/:id/shipping"
13095
13095
  },
13096
+ {
13097
+ Component: SalesChannel,
13098
+ path: "/draft-orders/:id/sales-channel"
13099
+ },
13096
13100
  {
13097
13101
  Component: ShippingAddress,
13098
13102
  path: "/draft-orders/:id/shipping-address"
@@ -13100,10 +13104,6 @@ const routeModule = {
13100
13104
  {
13101
13105
  Component: TransferOwnership,
13102
13106
  path: "/draft-orders/:id/transfer-ownership"
13103
- },
13104
- {
13105
- Component: CustomItems,
13106
- path: "/draft-orders/:id/custom-items"
13107
13107
  }
13108
13108
  ]
13109
13109
  }
@@ -9825,6 +9825,27 @@ const EmailForm = ({ order }) => {
9825
9825
  const schema$4 = objectType({
9826
9826
  email: stringType().email()
9827
9827
  });
9828
+ const CustomItems = () => {
9829
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9830
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9831
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9832
+ ] });
9833
+ };
9834
+ const CustomItemsForm = () => {
9835
+ const form = useForm({
9836
+ resolver: zodResolver(schema$3)
9837
+ });
9838
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9839
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9840
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9841
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9842
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9843
+ ] }) })
9844
+ ] }) });
9845
+ };
9846
+ const schema$3 = objectType({
9847
+ email: stringType().email()
9848
+ });
9828
9849
  const NumberInput = forwardRef(
9829
9850
  ({
9830
9851
  value,
@@ -11426,112 +11447,6 @@ function getPromotionIds(items, shippingMethods) {
11426
11447
  }
11427
11448
  return Array.from(promotionIds);
11428
11449
  }
11429
- const SalesChannel = () => {
11430
- const { id } = useParams();
11431
- const { draft_order, isPending, isError, error } = useDraftOrder(
11432
- id,
11433
- {
11434
- fields: "+sales_channel_id"
11435
- },
11436
- {
11437
- enabled: !!id
11438
- }
11439
- );
11440
- if (isError) {
11441
- throw error;
11442
- }
11443
- const ISrEADY = !!draft_order && !isPending;
11444
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11445
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11446
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11447
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11448
- ] }),
11449
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11450
- ] });
11451
- };
11452
- const SalesChannelForm = ({ order }) => {
11453
- const form = useForm({
11454
- defaultValues: {
11455
- sales_channel_id: order.sales_channel_id || ""
11456
- },
11457
- resolver: zodResolver(schema$3)
11458
- });
11459
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11460
- const { handleSuccess } = useRouteModal();
11461
- const onSubmit = form.handleSubmit(async (data) => {
11462
- await mutateAsync(
11463
- {
11464
- sales_channel_id: data.sales_channel_id
11465
- },
11466
- {
11467
- onSuccess: () => {
11468
- toast.success("Sales channel updated");
11469
- handleSuccess();
11470
- },
11471
- onError: (error) => {
11472
- toast.error(error.message);
11473
- }
11474
- }
11475
- );
11476
- });
11477
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11478
- KeyboundForm,
11479
- {
11480
- className: "flex flex-1 flex-col overflow-hidden",
11481
- onSubmit,
11482
- children: [
11483
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11484
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11485
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11486
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11487
- ] }) })
11488
- ]
11489
- }
11490
- ) });
11491
- };
11492
- const SalesChannelField = ({ control, order }) => {
11493
- const salesChannels = useComboboxData({
11494
- queryFn: async (params) => {
11495
- return await sdk.admin.salesChannel.list(params);
11496
- },
11497
- queryKey: ["sales-channels"],
11498
- getOptions: (data) => {
11499
- return data.sales_channels.map((salesChannel) => ({
11500
- label: salesChannel.name,
11501
- value: salesChannel.id
11502
- }));
11503
- },
11504
- defaultValue: order.sales_channel_id || void 0
11505
- });
11506
- return /* @__PURE__ */ jsx(
11507
- Form$2.Field,
11508
- {
11509
- control,
11510
- name: "sales_channel_id",
11511
- render: ({ field }) => {
11512
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11513
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11514
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11515
- Combobox,
11516
- {
11517
- options: salesChannels.options,
11518
- fetchNextPage: salesChannels.fetchNextPage,
11519
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11520
- searchValue: salesChannels.searchValue,
11521
- onSearchValueChange: salesChannels.onSearchValueChange,
11522
- placeholder: "Select sales channel",
11523
- ...field
11524
- }
11525
- ) }),
11526
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11527
- ] });
11528
- }
11529
- }
11530
- );
11531
- };
11532
- const schema$3 = objectType({
11533
- sales_channel_id: stringType().min(1)
11534
- });
11535
11450
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11536
11451
  const Shipping = () => {
11537
11452
  var _a;
@@ -12339,6 +12254,112 @@ const CustomAmountField = ({
12339
12254
  }
12340
12255
  );
12341
12256
  };
12257
+ const SalesChannel = () => {
12258
+ const { id } = useParams();
12259
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12260
+ id,
12261
+ {
12262
+ fields: "+sales_channel_id"
12263
+ },
12264
+ {
12265
+ enabled: !!id
12266
+ }
12267
+ );
12268
+ if (isError) {
12269
+ throw error;
12270
+ }
12271
+ const ISrEADY = !!draft_order && !isPending;
12272
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12273
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12274
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12275
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12276
+ ] }),
12277
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12278
+ ] });
12279
+ };
12280
+ const SalesChannelForm = ({ order }) => {
12281
+ const form = useForm({
12282
+ defaultValues: {
12283
+ sales_channel_id: order.sales_channel_id || ""
12284
+ },
12285
+ resolver: zodResolver(schema$2)
12286
+ });
12287
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12288
+ const { handleSuccess } = useRouteModal();
12289
+ const onSubmit = form.handleSubmit(async (data) => {
12290
+ await mutateAsync(
12291
+ {
12292
+ sales_channel_id: data.sales_channel_id
12293
+ },
12294
+ {
12295
+ onSuccess: () => {
12296
+ toast.success("Sales channel updated");
12297
+ handleSuccess();
12298
+ },
12299
+ onError: (error) => {
12300
+ toast.error(error.message);
12301
+ }
12302
+ }
12303
+ );
12304
+ });
12305
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12306
+ KeyboundForm,
12307
+ {
12308
+ className: "flex flex-1 flex-col overflow-hidden",
12309
+ onSubmit,
12310
+ children: [
12311
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12312
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12313
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12314
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12315
+ ] }) })
12316
+ ]
12317
+ }
12318
+ ) });
12319
+ };
12320
+ const SalesChannelField = ({ control, order }) => {
12321
+ const salesChannels = useComboboxData({
12322
+ queryFn: async (params) => {
12323
+ return await sdk.admin.salesChannel.list(params);
12324
+ },
12325
+ queryKey: ["sales-channels"],
12326
+ getOptions: (data) => {
12327
+ return data.sales_channels.map((salesChannel) => ({
12328
+ label: salesChannel.name,
12329
+ value: salesChannel.id
12330
+ }));
12331
+ },
12332
+ defaultValue: order.sales_channel_id || void 0
12333
+ });
12334
+ return /* @__PURE__ */ jsx(
12335
+ Form$2.Field,
12336
+ {
12337
+ control,
12338
+ name: "sales_channel_id",
12339
+ render: ({ field }) => {
12340
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12341
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12342
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12343
+ Combobox,
12344
+ {
12345
+ options: salesChannels.options,
12346
+ fetchNextPage: salesChannels.fetchNextPage,
12347
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12348
+ searchValue: salesChannels.searchValue,
12349
+ onSearchValueChange: salesChannels.onSearchValueChange,
12350
+ placeholder: "Select sales channel",
12351
+ ...field
12352
+ }
12353
+ ) }),
12354
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12355
+ ] });
12356
+ }
12357
+ }
12358
+ );
12359
+ };
12360
+ const schema$2 = objectType({
12361
+ sales_channel_id: stringType().min(1)
12362
+ });
12342
12363
  const ShippingAddress = () => {
12343
12364
  const { id } = useParams();
12344
12365
  const { order, isPending, isError, error } = useOrder(id, {
@@ -12371,7 +12392,7 @@ const ShippingAddressForm = ({ order }) => {
12371
12392
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12372
12393
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12373
12394
  },
12374
- resolver: zodResolver(schema$2)
12395
+ resolver: zodResolver(schema$1)
12375
12396
  });
12376
12397
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12377
12398
  const { handleSuccess } = useRouteModal();
@@ -12541,7 +12562,7 @@ const ShippingAddressForm = ({ order }) => {
12541
12562
  }
12542
12563
  ) });
12543
12564
  };
12544
- const schema$2 = addressSchema;
12565
+ const schema$1 = addressSchema;
12545
12566
  const TransferOwnership = () => {
12546
12567
  const { id } = useParams();
12547
12568
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12565,7 +12586,7 @@ const TransferOwnershipForm = ({ order }) => {
12565
12586
  defaultValues: {
12566
12587
  customer_id: order.customer_id || ""
12567
12588
  },
12568
- resolver: zodResolver(schema$1)
12589
+ resolver: zodResolver(schema)
12569
12590
  });
12570
12591
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12571
12592
  const { handleSuccess } = useRouteModal();
@@ -13015,29 +13036,8 @@ const Illustration = () => {
13015
13036
  }
13016
13037
  );
13017
13038
  };
13018
- const schema$1 = objectType({
13019
- customer_id: stringType().min(1)
13020
- });
13021
- const CustomItems = () => {
13022
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13023
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
13024
- /* @__PURE__ */ jsx(CustomItemsForm, {})
13025
- ] });
13026
- };
13027
- const CustomItemsForm = () => {
13028
- const form = useForm({
13029
- resolver: zodResolver(schema)
13030
- });
13031
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13032
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
13033
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13034
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13035
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
13036
- ] }) })
13037
- ] }) });
13038
- };
13039
13039
  const schema = objectType({
13040
- email: stringType().email()
13040
+ customer_id: stringType().min(1)
13041
13041
  });
13042
13042
  const widgetModule = { widgets: [] };
13043
13043
  const routeModule = {
@@ -13067,6 +13067,10 @@ const routeModule = {
13067
13067
  Component: Email,
13068
13068
  path: "/draft-orders/:id/email"
13069
13069
  },
13070
+ {
13071
+ Component: CustomItems,
13072
+ path: "/draft-orders/:id/custom-items"
13073
+ },
13070
13074
  {
13071
13075
  Component: Items,
13072
13076
  path: "/draft-orders/:id/items"
@@ -13079,14 +13083,14 @@ const routeModule = {
13079
13083
  Component: Promotions,
13080
13084
  path: "/draft-orders/:id/promotions"
13081
13085
  },
13082
- {
13083
- Component: SalesChannel,
13084
- path: "/draft-orders/:id/sales-channel"
13085
- },
13086
13086
  {
13087
13087
  Component: Shipping,
13088
13088
  path: "/draft-orders/:id/shipping"
13089
13089
  },
13090
+ {
13091
+ Component: SalesChannel,
13092
+ path: "/draft-orders/:id/sales-channel"
13093
+ },
13090
13094
  {
13091
13095
  Component: ShippingAddress,
13092
13096
  path: "/draft-orders/:id/shipping-address"
@@ -13094,10 +13098,6 @@ const routeModule = {
13094
13098
  {
13095
13099
  Component: TransferOwnership,
13096
13100
  path: "/draft-orders/:id/transfer-ownership"
13097
- },
13098
- {
13099
- Component: CustomItems,
13100
- path: "/draft-orders/:id/custom-items"
13101
13101
  }
13102
13102
  ]
13103
13103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.10.3-preview-20250913210149",
3
+ "version": "2.10.3-snapshot-20250913212755",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@ariakit/react": "^0.4.15",
38
38
  "@hookform/resolvers": "3.4.2",
39
- "@medusajs/js-sdk": "2.10.3-preview-20250913210149",
39
+ "@medusajs/js-sdk": "2.10.3-snapshot-20250913212755",
40
40
  "@tanstack/react-query": "5.64.2",
41
41
  "@uiw/react-json-view": "^2.0.0-alpha.17",
42
42
  "date-fns": "^3.6.0",
@@ -45,14 +45,14 @@
45
45
  "react-hook-form": "7.49.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@medusajs/admin-sdk": "2.10.3-preview-20250913210149",
49
- "@medusajs/cli": "2.10.3-preview-20250913210149",
50
- "@medusajs/framework": "2.10.3-preview-20250913210149",
51
- "@medusajs/icons": "2.10.3-preview-20250913210149",
52
- "@medusajs/test-utils": "2.10.3-preview-20250913210149",
53
- "@medusajs/types": "2.10.3-preview-20250913210149",
54
- "@medusajs/ui": "4.0.23-preview-20250913210149",
55
- "@medusajs/ui-preset": "2.10.3-preview-20250913210149",
48
+ "@medusajs/admin-sdk": "2.10.3-snapshot-20250913212755",
49
+ "@medusajs/cli": "2.10.3-snapshot-20250913212755",
50
+ "@medusajs/framework": "2.10.3-snapshot-20250913212755",
51
+ "@medusajs/icons": "2.10.3-snapshot-20250913212755",
52
+ "@medusajs/test-utils": "2.10.3-snapshot-20250913212755",
53
+ "@medusajs/types": "2.10.3-snapshot-20250913212755",
54
+ "@medusajs/ui": "4.0.23-snapshot-20250913212755",
55
+ "@medusajs/ui-preset": "2.10.3-snapshot-20250913212755",
56
56
  "@mikro-orm/cli": "6.4.3",
57
57
  "@mikro-orm/core": "6.4.3",
58
58
  "@mikro-orm/knex": "6.4.3",
@@ -76,12 +76,12 @@
76
76
  "yalc": "^1.0.0-pre.53"
77
77
  },
78
78
  "peerDependencies": {
79
- "@medusajs/admin-sdk": "2.10.3-preview-20250913210149",
80
- "@medusajs/cli": "2.10.3-preview-20250913210149",
81
- "@medusajs/framework": "2.10.3-preview-20250913210149",
82
- "@medusajs/icons": "2.10.3-preview-20250913210149",
83
- "@medusajs/test-utils": "2.10.3-preview-20250913210149",
84
- "@medusajs/ui": "4.0.23-preview-20250913210149",
79
+ "@medusajs/admin-sdk": "2.10.3-snapshot-20250913212755",
80
+ "@medusajs/cli": "2.10.3-snapshot-20250913212755",
81
+ "@medusajs/framework": "2.10.3-snapshot-20250913212755",
82
+ "@medusajs/icons": "2.10.3-snapshot-20250913212755",
83
+ "@medusajs/test-utils": "2.10.3-snapshot-20250913212755",
84
+ "@medusajs/ui": "4.0.23-snapshot-20250913212755",
85
85
  "@mikro-orm/cli": "6.4.3",
86
86
  "@mikro-orm/core": "6.4.3",
87
87
  "@mikro-orm/knex": "6.4.3",