@medusajs/draft-order 2.11.0-preview-20251020180200 → 2.11.0-preview-20251021000332

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.
@@ -9571,6 +9571,27 @@ const ID = () => {
9571
9571
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9572
9572
  ] });
9573
9573
  };
9574
+ const CustomItems = () => {
9575
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9576
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9577
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9578
+ ] });
9579
+ };
9580
+ const CustomItemsForm = () => {
9581
+ const form = reactHookForm.useForm({
9582
+ resolver: zod.zodResolver(schema$5)
9583
+ });
9584
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9585
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9586
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9588
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9589
+ ] }) })
9590
+ ] }) });
9591
+ };
9592
+ const schema$5 = objectType({
9593
+ email: stringType().email()
9594
+ });
9574
9595
  const Email = () => {
9575
9596
  const { id } = reactRouterDom.useParams();
9576
9597
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9593,7 +9614,7 @@ const EmailForm = ({ order }) => {
9593
9614
  defaultValues: {
9594
9615
  email: order.email ?? ""
9595
9616
  },
9596
- resolver: zod.zodResolver(schema$5)
9617
+ resolver: zod.zodResolver(schema$4)
9597
9618
  });
9598
9619
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9599
9620
  const { handleSuccess } = useRouteModal();
@@ -9636,7 +9657,7 @@ const EmailForm = ({ order }) => {
9636
9657
  }
9637
9658
  ) });
9638
9659
  };
9639
- const schema$5 = objectType({
9660
+ const schema$4 = objectType({
9640
9661
  email: stringType().email()
9641
9662
  });
9642
9663
  const NumberInput = React.forwardRef(
@@ -11240,6 +11261,112 @@ function getPromotionIds(items, shippingMethods) {
11240
11261
  }
11241
11262
  return Array.from(promotionIds);
11242
11263
  }
11264
+ const SalesChannel = () => {
11265
+ const { id } = reactRouterDom.useParams();
11266
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11267
+ id,
11268
+ {
11269
+ fields: "+sales_channel_id"
11270
+ },
11271
+ {
11272
+ enabled: !!id
11273
+ }
11274
+ );
11275
+ if (isError) {
11276
+ throw error;
11277
+ }
11278
+ const ISrEADY = !!draft_order && !isPending;
11279
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11280
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11281
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11282
+ /* @__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" }) })
11283
+ ] }),
11284
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11285
+ ] });
11286
+ };
11287
+ const SalesChannelForm = ({ order }) => {
11288
+ const form = reactHookForm.useForm({
11289
+ defaultValues: {
11290
+ sales_channel_id: order.sales_channel_id || ""
11291
+ },
11292
+ resolver: zod.zodResolver(schema$3)
11293
+ });
11294
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11295
+ const { handleSuccess } = useRouteModal();
11296
+ const onSubmit = form.handleSubmit(async (data) => {
11297
+ await mutateAsync(
11298
+ {
11299
+ sales_channel_id: data.sales_channel_id
11300
+ },
11301
+ {
11302
+ onSuccess: () => {
11303
+ ui.toast.success("Sales channel updated");
11304
+ handleSuccess();
11305
+ },
11306
+ onError: (error) => {
11307
+ ui.toast.error(error.message);
11308
+ }
11309
+ }
11310
+ );
11311
+ });
11312
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11313
+ KeyboundForm,
11314
+ {
11315
+ className: "flex flex-1 flex-col overflow-hidden",
11316
+ onSubmit,
11317
+ children: [
11318
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11319
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11320
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11321
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11322
+ ] }) })
11323
+ ]
11324
+ }
11325
+ ) });
11326
+ };
11327
+ const SalesChannelField = ({ control, order }) => {
11328
+ const salesChannels = useComboboxData({
11329
+ queryFn: async (params) => {
11330
+ return await sdk.admin.salesChannel.list(params);
11331
+ },
11332
+ queryKey: ["sales-channels"],
11333
+ getOptions: (data) => {
11334
+ return data.sales_channels.map((salesChannel) => ({
11335
+ label: salesChannel.name,
11336
+ value: salesChannel.id
11337
+ }));
11338
+ },
11339
+ defaultValue: order.sales_channel_id || void 0
11340
+ });
11341
+ return /* @__PURE__ */ jsxRuntime.jsx(
11342
+ Form$2.Field,
11343
+ {
11344
+ control,
11345
+ name: "sales_channel_id",
11346
+ render: ({ field }) => {
11347
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11348
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11349
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11350
+ Combobox,
11351
+ {
11352
+ options: salesChannels.options,
11353
+ fetchNextPage: salesChannels.fetchNextPage,
11354
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11355
+ searchValue: salesChannels.searchValue,
11356
+ onSearchValueChange: salesChannels.onSearchValueChange,
11357
+ placeholder: "Select sales channel",
11358
+ ...field
11359
+ }
11360
+ ) }),
11361
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11362
+ ] });
11363
+ }
11364
+ }
11365
+ );
11366
+ };
11367
+ const schema$3 = objectType({
11368
+ sales_channel_id: stringType().min(1)
11369
+ });
11243
11370
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11244
11371
  const Shipping = () => {
11245
11372
  var _a;
@@ -12079,7 +12206,7 @@ const ShippingAddressForm = ({ order }) => {
12079
12206
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12080
12207
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12081
12208
  },
12082
- resolver: zod.zodResolver(schema$4)
12209
+ resolver: zod.zodResolver(schema$2)
12083
12210
  });
12084
12211
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12085
12212
  const { handleSuccess } = useRouteModal();
@@ -12249,113 +12376,7 @@ const ShippingAddressForm = ({ order }) => {
12249
12376
  }
12250
12377
  ) });
12251
12378
  };
12252
- const schema$4 = addressSchema;
12253
- const SalesChannel = () => {
12254
- const { id } = reactRouterDom.useParams();
12255
- const { draft_order, isPending, isError, error } = useDraftOrder(
12256
- id,
12257
- {
12258
- fields: "+sales_channel_id"
12259
- },
12260
- {
12261
- enabled: !!id
12262
- }
12263
- );
12264
- if (isError) {
12265
- throw error;
12266
- }
12267
- const ISrEADY = !!draft_order && !isPending;
12268
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12269
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12270
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12271
- /* @__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" }) })
12272
- ] }),
12273
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12274
- ] });
12275
- };
12276
- const SalesChannelForm = ({ order }) => {
12277
- const form = reactHookForm.useForm({
12278
- defaultValues: {
12279
- sales_channel_id: order.sales_channel_id || ""
12280
- },
12281
- resolver: zod.zodResolver(schema$3)
12282
- });
12283
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12284
- const { handleSuccess } = useRouteModal();
12285
- const onSubmit = form.handleSubmit(async (data) => {
12286
- await mutateAsync(
12287
- {
12288
- sales_channel_id: data.sales_channel_id
12289
- },
12290
- {
12291
- onSuccess: () => {
12292
- ui.toast.success("Sales channel updated");
12293
- handleSuccess();
12294
- },
12295
- onError: (error) => {
12296
- ui.toast.error(error.message);
12297
- }
12298
- }
12299
- );
12300
- });
12301
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12302
- KeyboundForm,
12303
- {
12304
- className: "flex flex-1 flex-col overflow-hidden",
12305
- onSubmit,
12306
- children: [
12307
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12308
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12309
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12310
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12311
- ] }) })
12312
- ]
12313
- }
12314
- ) });
12315
- };
12316
- const SalesChannelField = ({ control, order }) => {
12317
- const salesChannels = useComboboxData({
12318
- queryFn: async (params) => {
12319
- return await sdk.admin.salesChannel.list(params);
12320
- },
12321
- queryKey: ["sales-channels"],
12322
- getOptions: (data) => {
12323
- return data.sales_channels.map((salesChannel) => ({
12324
- label: salesChannel.name,
12325
- value: salesChannel.id
12326
- }));
12327
- },
12328
- defaultValue: order.sales_channel_id || void 0
12329
- });
12330
- return /* @__PURE__ */ jsxRuntime.jsx(
12331
- Form$2.Field,
12332
- {
12333
- control,
12334
- name: "sales_channel_id",
12335
- render: ({ field }) => {
12336
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12337
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12338
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12339
- Combobox,
12340
- {
12341
- options: salesChannels.options,
12342
- fetchNextPage: salesChannels.fetchNextPage,
12343
- isFetchingNextPage: salesChannels.isFetchingNextPage,
12344
- searchValue: salesChannels.searchValue,
12345
- onSearchValueChange: salesChannels.onSearchValueChange,
12346
- placeholder: "Select sales channel",
12347
- ...field
12348
- }
12349
- ) }),
12350
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12351
- ] });
12352
- }
12353
- }
12354
- );
12355
- };
12356
- const schema$3 = objectType({
12357
- sales_channel_id: stringType().min(1)
12358
- });
12379
+ const schema$2 = addressSchema;
12359
12380
  const TransferOwnership = () => {
12360
12381
  const { id } = reactRouterDom.useParams();
12361
12382
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12379,7 +12400,7 @@ const TransferOwnershipForm = ({ order }) => {
12379
12400
  defaultValues: {
12380
12401
  customer_id: order.customer_id || ""
12381
12402
  },
12382
- resolver: zod.zodResolver(schema$2)
12403
+ resolver: zod.zodResolver(schema$1)
12383
12404
  });
12384
12405
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12385
12406
  const { handleSuccess } = useRouteModal();
@@ -12829,7 +12850,7 @@ const Illustration = () => {
12829
12850
  }
12830
12851
  );
12831
12852
  };
12832
- const schema$2 = objectType({
12853
+ const schema$1 = objectType({
12833
12854
  customer_id: stringType().min(1)
12834
12855
  });
12835
12856
  const BillingAddress = () => {
@@ -12864,7 +12885,7 @@ const BillingAddressForm = ({ order }) => {
12864
12885
  postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12865
12886
  phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12866
12887
  },
12867
- resolver: zod.zodResolver(schema$1)
12888
+ resolver: zod.zodResolver(schema)
12868
12889
  });
12869
12890
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12870
12891
  const { handleSuccess } = useRouteModal();
@@ -13021,28 +13042,7 @@ const BillingAddressForm = ({ order }) => {
13021
13042
  }
13022
13043
  ) });
13023
13044
  };
13024
- const schema$1 = addressSchema;
13025
- const CustomItems = () => {
13026
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
13027
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
13028
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
13029
- ] });
13030
- };
13031
- const CustomItemsForm = () => {
13032
- const form = reactHookForm.useForm({
13033
- resolver: zod.zodResolver(schema)
13034
- });
13035
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13036
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
13037
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13038
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13039
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
13040
- ] }) })
13041
- ] }) });
13042
- };
13043
- const schema = objectType({
13044
- email: stringType().email()
13045
- });
13045
+ const schema = addressSchema;
13046
13046
  const widgetModule = { widgets: [] };
13047
13047
  const routeModule = {
13048
13048
  routes: [
@@ -13063,6 +13063,10 @@ const routeModule = {
13063
13063
  handle,
13064
13064
  loader,
13065
13065
  children: [
13066
+ {
13067
+ Component: CustomItems,
13068
+ path: "/draft-orders/:id/custom-items"
13069
+ },
13066
13070
  {
13067
13071
  Component: Email,
13068
13072
  path: "/draft-orders/:id/email"
@@ -13079,6 +13083,10 @@ const routeModule = {
13079
13083
  Component: Promotions,
13080
13084
  path: "/draft-orders/:id/promotions"
13081
13085
  },
13086
+ {
13087
+ Component: SalesChannel,
13088
+ path: "/draft-orders/:id/sales-channel"
13089
+ },
13082
13090
  {
13083
13091
  Component: Shipping,
13084
13092
  path: "/draft-orders/:id/shipping"
@@ -13087,10 +13095,6 @@ const routeModule = {
13087
13095
  Component: ShippingAddress,
13088
13096
  path: "/draft-orders/:id/shipping-address"
13089
13097
  },
13090
- {
13091
- Component: SalesChannel,
13092
- path: "/draft-orders/:id/sales-channel"
13093
- },
13094
13098
  {
13095
13099
  Component: TransferOwnership,
13096
13100
  path: "/draft-orders/:id/transfer-ownership"
@@ -13098,10 +13102,6 @@ const routeModule = {
13098
13102
  {
13099
13103
  Component: BillingAddress,
13100
13104
  path: "/draft-orders/:id/billing-address"
13101
- },
13102
- {
13103
- Component: CustomItems,
13104
- path: "/draft-orders/:id/custom-items"
13105
13105
  }
13106
13106
  ]
13107
13107
  }
@@ -9565,6 +9565,27 @@ const ID = () => {
9565
9565
  /* @__PURE__ */ jsx(Outlet, {})
9566
9566
  ] });
9567
9567
  };
9568
+ const CustomItems = () => {
9569
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9570
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9571
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9572
+ ] });
9573
+ };
9574
+ const CustomItemsForm = () => {
9575
+ const form = useForm({
9576
+ resolver: zodResolver(schema$5)
9577
+ });
9578
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9579
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9580
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9581
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9582
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9583
+ ] }) })
9584
+ ] }) });
9585
+ };
9586
+ const schema$5 = objectType({
9587
+ email: stringType().email()
9588
+ });
9568
9589
  const Email = () => {
9569
9590
  const { id } = useParams();
9570
9591
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9587,7 +9608,7 @@ const EmailForm = ({ order }) => {
9587
9608
  defaultValues: {
9588
9609
  email: order.email ?? ""
9589
9610
  },
9590
- resolver: zodResolver(schema$5)
9611
+ resolver: zodResolver(schema$4)
9591
9612
  });
9592
9613
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9593
9614
  const { handleSuccess } = useRouteModal();
@@ -9630,7 +9651,7 @@ const EmailForm = ({ order }) => {
9630
9651
  }
9631
9652
  ) });
9632
9653
  };
9633
- const schema$5 = objectType({
9654
+ const schema$4 = objectType({
9634
9655
  email: stringType().email()
9635
9656
  });
9636
9657
  const NumberInput = forwardRef(
@@ -11234,6 +11255,112 @@ function getPromotionIds(items, shippingMethods) {
11234
11255
  }
11235
11256
  return Array.from(promotionIds);
11236
11257
  }
11258
+ const SalesChannel = () => {
11259
+ const { id } = useParams();
11260
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11261
+ id,
11262
+ {
11263
+ fields: "+sales_channel_id"
11264
+ },
11265
+ {
11266
+ enabled: !!id
11267
+ }
11268
+ );
11269
+ if (isError) {
11270
+ throw error;
11271
+ }
11272
+ const ISrEADY = !!draft_order && !isPending;
11273
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11274
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11275
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11276
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11277
+ ] }),
11278
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11279
+ ] });
11280
+ };
11281
+ const SalesChannelForm = ({ order }) => {
11282
+ const form = useForm({
11283
+ defaultValues: {
11284
+ sales_channel_id: order.sales_channel_id || ""
11285
+ },
11286
+ resolver: zodResolver(schema$3)
11287
+ });
11288
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11289
+ const { handleSuccess } = useRouteModal();
11290
+ const onSubmit = form.handleSubmit(async (data) => {
11291
+ await mutateAsync(
11292
+ {
11293
+ sales_channel_id: data.sales_channel_id
11294
+ },
11295
+ {
11296
+ onSuccess: () => {
11297
+ toast.success("Sales channel updated");
11298
+ handleSuccess();
11299
+ },
11300
+ onError: (error) => {
11301
+ toast.error(error.message);
11302
+ }
11303
+ }
11304
+ );
11305
+ });
11306
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11307
+ KeyboundForm,
11308
+ {
11309
+ className: "flex flex-1 flex-col overflow-hidden",
11310
+ onSubmit,
11311
+ children: [
11312
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11313
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11314
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11315
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11316
+ ] }) })
11317
+ ]
11318
+ }
11319
+ ) });
11320
+ };
11321
+ const SalesChannelField = ({ control, order }) => {
11322
+ const salesChannels = useComboboxData({
11323
+ queryFn: async (params) => {
11324
+ return await sdk.admin.salesChannel.list(params);
11325
+ },
11326
+ queryKey: ["sales-channels"],
11327
+ getOptions: (data) => {
11328
+ return data.sales_channels.map((salesChannel) => ({
11329
+ label: salesChannel.name,
11330
+ value: salesChannel.id
11331
+ }));
11332
+ },
11333
+ defaultValue: order.sales_channel_id || void 0
11334
+ });
11335
+ return /* @__PURE__ */ jsx(
11336
+ Form$2.Field,
11337
+ {
11338
+ control,
11339
+ name: "sales_channel_id",
11340
+ render: ({ field }) => {
11341
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11342
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11343
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11344
+ Combobox,
11345
+ {
11346
+ options: salesChannels.options,
11347
+ fetchNextPage: salesChannels.fetchNextPage,
11348
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11349
+ searchValue: salesChannels.searchValue,
11350
+ onSearchValueChange: salesChannels.onSearchValueChange,
11351
+ placeholder: "Select sales channel",
11352
+ ...field
11353
+ }
11354
+ ) }),
11355
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11356
+ ] });
11357
+ }
11358
+ }
11359
+ );
11360
+ };
11361
+ const schema$3 = objectType({
11362
+ sales_channel_id: stringType().min(1)
11363
+ });
11237
11364
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11238
11365
  const Shipping = () => {
11239
11366
  var _a;
@@ -12073,7 +12200,7 @@ const ShippingAddressForm = ({ order }) => {
12073
12200
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12074
12201
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12075
12202
  },
12076
- resolver: zodResolver(schema$4)
12203
+ resolver: zodResolver(schema$2)
12077
12204
  });
12078
12205
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12079
12206
  const { handleSuccess } = useRouteModal();
@@ -12243,113 +12370,7 @@ const ShippingAddressForm = ({ order }) => {
12243
12370
  }
12244
12371
  ) });
12245
12372
  };
12246
- const schema$4 = addressSchema;
12247
- const SalesChannel = () => {
12248
- const { id } = useParams();
12249
- const { draft_order, isPending, isError, error } = useDraftOrder(
12250
- id,
12251
- {
12252
- fields: "+sales_channel_id"
12253
- },
12254
- {
12255
- enabled: !!id
12256
- }
12257
- );
12258
- if (isError) {
12259
- throw error;
12260
- }
12261
- const ISrEADY = !!draft_order && !isPending;
12262
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12263
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12264
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12265
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12266
- ] }),
12267
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12268
- ] });
12269
- };
12270
- const SalesChannelForm = ({ order }) => {
12271
- const form = useForm({
12272
- defaultValues: {
12273
- sales_channel_id: order.sales_channel_id || ""
12274
- },
12275
- resolver: zodResolver(schema$3)
12276
- });
12277
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12278
- const { handleSuccess } = useRouteModal();
12279
- const onSubmit = form.handleSubmit(async (data) => {
12280
- await mutateAsync(
12281
- {
12282
- sales_channel_id: data.sales_channel_id
12283
- },
12284
- {
12285
- onSuccess: () => {
12286
- toast.success("Sales channel updated");
12287
- handleSuccess();
12288
- },
12289
- onError: (error) => {
12290
- toast.error(error.message);
12291
- }
12292
- }
12293
- );
12294
- });
12295
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12296
- KeyboundForm,
12297
- {
12298
- className: "flex flex-1 flex-col overflow-hidden",
12299
- onSubmit,
12300
- children: [
12301
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12302
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12303
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12304
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12305
- ] }) })
12306
- ]
12307
- }
12308
- ) });
12309
- };
12310
- const SalesChannelField = ({ control, order }) => {
12311
- const salesChannels = useComboboxData({
12312
- queryFn: async (params) => {
12313
- return await sdk.admin.salesChannel.list(params);
12314
- },
12315
- queryKey: ["sales-channels"],
12316
- getOptions: (data) => {
12317
- return data.sales_channels.map((salesChannel) => ({
12318
- label: salesChannel.name,
12319
- value: salesChannel.id
12320
- }));
12321
- },
12322
- defaultValue: order.sales_channel_id || void 0
12323
- });
12324
- return /* @__PURE__ */ jsx(
12325
- Form$2.Field,
12326
- {
12327
- control,
12328
- name: "sales_channel_id",
12329
- render: ({ field }) => {
12330
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12331
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12332
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12333
- Combobox,
12334
- {
12335
- options: salesChannels.options,
12336
- fetchNextPage: salesChannels.fetchNextPage,
12337
- isFetchingNextPage: salesChannels.isFetchingNextPage,
12338
- searchValue: salesChannels.searchValue,
12339
- onSearchValueChange: salesChannels.onSearchValueChange,
12340
- placeholder: "Select sales channel",
12341
- ...field
12342
- }
12343
- ) }),
12344
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12345
- ] });
12346
- }
12347
- }
12348
- );
12349
- };
12350
- const schema$3 = objectType({
12351
- sales_channel_id: stringType().min(1)
12352
- });
12373
+ const schema$2 = addressSchema;
12353
12374
  const TransferOwnership = () => {
12354
12375
  const { id } = useParams();
12355
12376
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12373,7 +12394,7 @@ const TransferOwnershipForm = ({ order }) => {
12373
12394
  defaultValues: {
12374
12395
  customer_id: order.customer_id || ""
12375
12396
  },
12376
- resolver: zodResolver(schema$2)
12397
+ resolver: zodResolver(schema$1)
12377
12398
  });
12378
12399
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12379
12400
  const { handleSuccess } = useRouteModal();
@@ -12823,7 +12844,7 @@ const Illustration = () => {
12823
12844
  }
12824
12845
  );
12825
12846
  };
12826
- const schema$2 = objectType({
12847
+ const schema$1 = objectType({
12827
12848
  customer_id: stringType().min(1)
12828
12849
  });
12829
12850
  const BillingAddress = () => {
@@ -12858,7 +12879,7 @@ const BillingAddressForm = ({ order }) => {
12858
12879
  postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12859
12880
  phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12860
12881
  },
12861
- resolver: zodResolver(schema$1)
12882
+ resolver: zodResolver(schema)
12862
12883
  });
12863
12884
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12864
12885
  const { handleSuccess } = useRouteModal();
@@ -13015,28 +13036,7 @@ const BillingAddressForm = ({ order }) => {
13015
13036
  }
13016
13037
  ) });
13017
13038
  };
13018
- const schema$1 = addressSchema;
13019
- const CustomItems = () => {
13020
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13021
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
13022
- /* @__PURE__ */ jsx(CustomItemsForm, {})
13023
- ] });
13024
- };
13025
- const CustomItemsForm = () => {
13026
- const form = useForm({
13027
- resolver: zodResolver(schema)
13028
- });
13029
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13030
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
13031
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13032
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13033
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
13034
- ] }) })
13035
- ] }) });
13036
- };
13037
- const schema = objectType({
13038
- email: stringType().email()
13039
- });
13039
+ const schema = addressSchema;
13040
13040
  const widgetModule = { widgets: [] };
13041
13041
  const routeModule = {
13042
13042
  routes: [
@@ -13057,6 +13057,10 @@ const routeModule = {
13057
13057
  handle,
13058
13058
  loader,
13059
13059
  children: [
13060
+ {
13061
+ Component: CustomItems,
13062
+ path: "/draft-orders/:id/custom-items"
13063
+ },
13060
13064
  {
13061
13065
  Component: Email,
13062
13066
  path: "/draft-orders/:id/email"
@@ -13073,6 +13077,10 @@ const routeModule = {
13073
13077
  Component: Promotions,
13074
13078
  path: "/draft-orders/:id/promotions"
13075
13079
  },
13080
+ {
13081
+ Component: SalesChannel,
13082
+ path: "/draft-orders/:id/sales-channel"
13083
+ },
13076
13084
  {
13077
13085
  Component: Shipping,
13078
13086
  path: "/draft-orders/:id/shipping"
@@ -13081,10 +13089,6 @@ const routeModule = {
13081
13089
  Component: ShippingAddress,
13082
13090
  path: "/draft-orders/:id/shipping-address"
13083
13091
  },
13084
- {
13085
- Component: SalesChannel,
13086
- path: "/draft-orders/:id/sales-channel"
13087
- },
13088
13092
  {
13089
13093
  Component: TransferOwnership,
13090
13094
  path: "/draft-orders/:id/transfer-ownership"
@@ -13092,10 +13096,6 @@ const routeModule = {
13092
13096
  {
13093
13097
  Component: BillingAddress,
13094
13098
  path: "/draft-orders/:id/billing-address"
13095
- },
13096
- {
13097
- Component: CustomItems,
13098
- path: "/draft-orders/:id/custom-items"
13099
13099
  }
13100
13100
  ]
13101
13101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.11.0-preview-20251020180200",
3
+ "version": "2.11.0-preview-20251021000332",
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.11.0-preview-20251020180200",
39
+ "@medusajs/js-sdk": "2.11.0-preview-20251021000332",
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.11.0-preview-20251020180200",
49
- "@medusajs/cli": "2.11.0-preview-20251020180200",
50
- "@medusajs/framework": "2.11.0-preview-20251020180200",
51
- "@medusajs/icons": "2.11.0-preview-20251020180200",
52
- "@medusajs/test-utils": "2.11.0-preview-20251020180200",
53
- "@medusajs/types": "2.11.0-preview-20251020180200",
54
- "@medusajs/ui": "4.0.24-preview-20251020180200",
55
- "@medusajs/ui-preset": "2.11.0-preview-20251020180200",
48
+ "@medusajs/admin-sdk": "2.11.0-preview-20251021000332",
49
+ "@medusajs/cli": "2.11.0-preview-20251021000332",
50
+ "@medusajs/framework": "2.11.0-preview-20251021000332",
51
+ "@medusajs/icons": "2.11.0-preview-20251021000332",
52
+ "@medusajs/test-utils": "2.11.0-preview-20251021000332",
53
+ "@medusajs/types": "2.11.0-preview-20251021000332",
54
+ "@medusajs/ui": "4.0.24-preview-20251021000332",
55
+ "@medusajs/ui-preset": "2.11.0-preview-20251021000332",
56
56
  "@swc/core": "1.5.7",
57
57
  "@types/lodash": "^4.17.15",
58
58
  "@types/node": "^20.0.0",
@@ -69,12 +69,12 @@
69
69
  "yalc": "^1.0.0-pre.53"
70
70
  },
71
71
  "peerDependencies": {
72
- "@medusajs/admin-sdk": "2.11.0-preview-20251020180200",
73
- "@medusajs/cli": "2.11.0-preview-20251020180200",
74
- "@medusajs/framework": "2.11.0-preview-20251020180200",
75
- "@medusajs/icons": "2.11.0-preview-20251020180200",
76
- "@medusajs/test-utils": "2.11.0-preview-20251020180200",
77
- "@medusajs/ui": "4.0.24-preview-20251020180200",
72
+ "@medusajs/admin-sdk": "2.11.0-preview-20251021000332",
73
+ "@medusajs/cli": "2.11.0-preview-20251021000332",
74
+ "@medusajs/framework": "2.11.0-preview-20251021000332",
75
+ "@medusajs/icons": "2.11.0-preview-20251021000332",
76
+ "@medusajs/test-utils": "2.11.0-preview-20251021000332",
77
+ "@medusajs/ui": "4.0.24-preview-20251021000332",
78
78
  "lodash": "^4.17.21",
79
79
  "react-router-dom": "6.20.1"
80
80
  },