@medusajs/draft-order 2.10.2-preview-20250903060148 → 2.10.2-preview-20250903090152

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.
@@ -9560,6 +9560,27 @@ const ID = () => {
9560
9560
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9561
9561
  ] });
9562
9562
  };
9563
+ const CustomItems = () => {
9564
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9565
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9566
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9567
+ ] });
9568
+ };
9569
+ const CustomItemsForm = () => {
9570
+ const form = reactHookForm.useForm({
9571
+ resolver: zod.zodResolver(schema$5)
9572
+ });
9573
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9574
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9575
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9576
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9577
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9578
+ ] }) })
9579
+ ] }) });
9580
+ };
9581
+ const schema$5 = objectType({
9582
+ email: stringType().email()
9583
+ });
9563
9584
  const Email = () => {
9564
9585
  const { id } = reactRouterDom.useParams();
9565
9586
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9582,7 +9603,7 @@ const EmailForm = ({ order }) => {
9582
9603
  defaultValues: {
9583
9604
  email: order.email ?? ""
9584
9605
  },
9585
- resolver: zod.zodResolver(schema$5)
9606
+ resolver: zod.zodResolver(schema$4)
9586
9607
  });
9587
9608
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9588
9609
  const { handleSuccess } = useRouteModal();
@@ -9625,7 +9646,7 @@ const EmailForm = ({ order }) => {
9625
9646
  }
9626
9647
  ) });
9627
9648
  };
9628
- const schema$5 = objectType({
9649
+ const schema$4 = objectType({
9629
9650
  email: stringType().email()
9630
9651
  });
9631
9652
  const NumberInput = React.forwardRef(
@@ -11229,112 +11250,6 @@ function getPromotionCodes(items, shippingMethods) {
11229
11250
  }
11230
11251
  return Array.from(codes);
11231
11252
  }
11232
- const SalesChannel = () => {
11233
- const { id } = reactRouterDom.useParams();
11234
- const { draft_order, isPending, isError, error } = useDraftOrder(
11235
- id,
11236
- {
11237
- fields: "+sales_channel_id"
11238
- },
11239
- {
11240
- enabled: !!id
11241
- }
11242
- );
11243
- if (isError) {
11244
- throw error;
11245
- }
11246
- const ISrEADY = !!draft_order && !isPending;
11247
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11248
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11249
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11250
- /* @__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" }) })
11251
- ] }),
11252
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11253
- ] });
11254
- };
11255
- const SalesChannelForm = ({ order }) => {
11256
- const form = reactHookForm.useForm({
11257
- defaultValues: {
11258
- sales_channel_id: order.sales_channel_id || ""
11259
- },
11260
- resolver: zod.zodResolver(schema$4)
11261
- });
11262
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11263
- const { handleSuccess } = useRouteModal();
11264
- const onSubmit = form.handleSubmit(async (data) => {
11265
- await mutateAsync(
11266
- {
11267
- sales_channel_id: data.sales_channel_id
11268
- },
11269
- {
11270
- onSuccess: () => {
11271
- ui.toast.success("Sales channel updated");
11272
- handleSuccess();
11273
- },
11274
- onError: (error) => {
11275
- ui.toast.error(error.message);
11276
- }
11277
- }
11278
- );
11279
- });
11280
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11281
- KeyboundForm,
11282
- {
11283
- className: "flex flex-1 flex-col overflow-hidden",
11284
- onSubmit,
11285
- children: [
11286
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11287
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11288
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11289
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11290
- ] }) })
11291
- ]
11292
- }
11293
- ) });
11294
- };
11295
- const SalesChannelField = ({ control, order }) => {
11296
- const salesChannels = useComboboxData({
11297
- queryFn: async (params) => {
11298
- return await sdk.admin.salesChannel.list(params);
11299
- },
11300
- queryKey: ["sales-channels"],
11301
- getOptions: (data) => {
11302
- return data.sales_channels.map((salesChannel) => ({
11303
- label: salesChannel.name,
11304
- value: salesChannel.id
11305
- }));
11306
- },
11307
- defaultValue: order.sales_channel_id || void 0
11308
- });
11309
- return /* @__PURE__ */ jsxRuntime.jsx(
11310
- Form$2.Field,
11311
- {
11312
- control,
11313
- name: "sales_channel_id",
11314
- render: ({ field }) => {
11315
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11316
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11317
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11318
- Combobox,
11319
- {
11320
- options: salesChannels.options,
11321
- fetchNextPage: salesChannels.fetchNextPage,
11322
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11323
- searchValue: salesChannels.searchValue,
11324
- onSearchValueChange: salesChannels.onSearchValueChange,
11325
- placeholder: "Select sales channel",
11326
- ...field
11327
- }
11328
- ) }),
11329
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11330
- ] });
11331
- }
11332
- }
11333
- );
11334
- };
11335
- const schema$4 = objectType({
11336
- sales_channel_id: stringType().min(1)
11337
- });
11338
11253
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11339
11254
  const Shipping = () => {
11340
11255
  var _a;
@@ -12142,6 +12057,112 @@ const CustomAmountField = ({
12142
12057
  }
12143
12058
  );
12144
12059
  };
12060
+ const SalesChannel = () => {
12061
+ const { id } = reactRouterDom.useParams();
12062
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12063
+ id,
12064
+ {
12065
+ fields: "+sales_channel_id"
12066
+ },
12067
+ {
12068
+ enabled: !!id
12069
+ }
12070
+ );
12071
+ if (isError) {
12072
+ throw error;
12073
+ }
12074
+ const ISrEADY = !!draft_order && !isPending;
12075
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12076
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12077
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12078
+ /* @__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" }) })
12079
+ ] }),
12080
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12081
+ ] });
12082
+ };
12083
+ const SalesChannelForm = ({ order }) => {
12084
+ const form = reactHookForm.useForm({
12085
+ defaultValues: {
12086
+ sales_channel_id: order.sales_channel_id || ""
12087
+ },
12088
+ resolver: zod.zodResolver(schema$3)
12089
+ });
12090
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12091
+ const { handleSuccess } = useRouteModal();
12092
+ const onSubmit = form.handleSubmit(async (data) => {
12093
+ await mutateAsync(
12094
+ {
12095
+ sales_channel_id: data.sales_channel_id
12096
+ },
12097
+ {
12098
+ onSuccess: () => {
12099
+ ui.toast.success("Sales channel updated");
12100
+ handleSuccess();
12101
+ },
12102
+ onError: (error) => {
12103
+ ui.toast.error(error.message);
12104
+ }
12105
+ }
12106
+ );
12107
+ });
12108
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12109
+ KeyboundForm,
12110
+ {
12111
+ className: "flex flex-1 flex-col overflow-hidden",
12112
+ onSubmit,
12113
+ children: [
12114
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12115
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12116
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12117
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12118
+ ] }) })
12119
+ ]
12120
+ }
12121
+ ) });
12122
+ };
12123
+ const SalesChannelField = ({ control, order }) => {
12124
+ const salesChannels = useComboboxData({
12125
+ queryFn: async (params) => {
12126
+ return await sdk.admin.salesChannel.list(params);
12127
+ },
12128
+ queryKey: ["sales-channels"],
12129
+ getOptions: (data) => {
12130
+ return data.sales_channels.map((salesChannel) => ({
12131
+ label: salesChannel.name,
12132
+ value: salesChannel.id
12133
+ }));
12134
+ },
12135
+ defaultValue: order.sales_channel_id || void 0
12136
+ });
12137
+ return /* @__PURE__ */ jsxRuntime.jsx(
12138
+ Form$2.Field,
12139
+ {
12140
+ control,
12141
+ name: "sales_channel_id",
12142
+ render: ({ field }) => {
12143
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12144
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12145
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12146
+ Combobox,
12147
+ {
12148
+ options: salesChannels.options,
12149
+ fetchNextPage: salesChannels.fetchNextPage,
12150
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12151
+ searchValue: salesChannels.searchValue,
12152
+ onSearchValueChange: salesChannels.onSearchValueChange,
12153
+ placeholder: "Select sales channel",
12154
+ ...field
12155
+ }
12156
+ ) }),
12157
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12158
+ ] });
12159
+ }
12160
+ }
12161
+ );
12162
+ };
12163
+ const schema$3 = objectType({
12164
+ sales_channel_id: stringType().min(1)
12165
+ });
12145
12166
  const ShippingAddress = () => {
12146
12167
  const { id } = reactRouterDom.useParams();
12147
12168
  const { order, isPending, isError, error } = useOrder(id, {
@@ -12174,7 +12195,7 @@ const ShippingAddressForm = ({ order }) => {
12174
12195
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12175
12196
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12176
12197
  },
12177
- resolver: zod.zodResolver(schema$3)
12198
+ resolver: zod.zodResolver(schema$2)
12178
12199
  });
12179
12200
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12180
12201
  const { handleSuccess } = useRouteModal();
@@ -12344,7 +12365,7 @@ const ShippingAddressForm = ({ order }) => {
12344
12365
  }
12345
12366
  ) });
12346
12367
  };
12347
- const schema$3 = addressSchema;
12368
+ const schema$2 = addressSchema;
12348
12369
  const TransferOwnership = () => {
12349
12370
  const { id } = reactRouterDom.useParams();
12350
12371
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12368,7 +12389,7 @@ const TransferOwnershipForm = ({ order }) => {
12368
12389
  defaultValues: {
12369
12390
  customer_id: order.customer_id || ""
12370
12391
  },
12371
- resolver: zod.zodResolver(schema$2)
12392
+ resolver: zod.zodResolver(schema$1)
12372
12393
  });
12373
12394
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12374
12395
  const { handleSuccess } = useRouteModal();
@@ -12818,29 +12839,8 @@ const Illustration = () => {
12818
12839
  }
12819
12840
  );
12820
12841
  };
12821
- const schema$2 = objectType({
12822
- customer_id: stringType().min(1)
12823
- });
12824
- const CustomItems = () => {
12825
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12826
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
12827
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
12828
- ] });
12829
- };
12830
- const CustomItemsForm = () => {
12831
- const form = reactHookForm.useForm({
12832
- resolver: zod.zodResolver(schema$1)
12833
- });
12834
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
12835
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
12836
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12837
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12838
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
12839
- ] }) })
12840
- ] }) });
12841
- };
12842
12842
  const schema$1 = objectType({
12843
- email: stringType().email()
12843
+ customer_id: stringType().min(1)
12844
12844
  });
12845
12845
  const BillingAddress = () => {
12846
12846
  const { id } = reactRouterDom.useParams();
@@ -13052,6 +13052,10 @@ const routeModule = {
13052
13052
  handle,
13053
13053
  loader,
13054
13054
  children: [
13055
+ {
13056
+ Component: CustomItems,
13057
+ path: "/draft-orders/:id/custom-items"
13058
+ },
13055
13059
  {
13056
13060
  Component: Email,
13057
13061
  path: "/draft-orders/:id/email"
@@ -13068,14 +13072,14 @@ const routeModule = {
13068
13072
  Component: Promotions,
13069
13073
  path: "/draft-orders/:id/promotions"
13070
13074
  },
13071
- {
13072
- Component: SalesChannel,
13073
- path: "/draft-orders/:id/sales-channel"
13074
- },
13075
13075
  {
13076
13076
  Component: Shipping,
13077
13077
  path: "/draft-orders/:id/shipping"
13078
13078
  },
13079
+ {
13080
+ Component: SalesChannel,
13081
+ path: "/draft-orders/:id/sales-channel"
13082
+ },
13079
13083
  {
13080
13084
  Component: ShippingAddress,
13081
13085
  path: "/draft-orders/:id/shipping-address"
@@ -13084,10 +13088,6 @@ const routeModule = {
13084
13088
  Component: TransferOwnership,
13085
13089
  path: "/draft-orders/:id/transfer-ownership"
13086
13090
  },
13087
- {
13088
- Component: CustomItems,
13089
- path: "/draft-orders/:id/custom-items"
13090
- },
13091
13091
  {
13092
13092
  Component: BillingAddress,
13093
13093
  path: "/draft-orders/:id/billing-address"
@@ -9554,6 +9554,27 @@ const ID = () => {
9554
9554
  /* @__PURE__ */ jsx(Outlet, {})
9555
9555
  ] });
9556
9556
  };
9557
+ const CustomItems = () => {
9558
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9559
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9560
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9561
+ ] });
9562
+ };
9563
+ const CustomItemsForm = () => {
9564
+ const form = useForm({
9565
+ resolver: zodResolver(schema$5)
9566
+ });
9567
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9568
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9569
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9570
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9571
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9572
+ ] }) })
9573
+ ] }) });
9574
+ };
9575
+ const schema$5 = objectType({
9576
+ email: stringType().email()
9577
+ });
9557
9578
  const Email = () => {
9558
9579
  const { id } = useParams();
9559
9580
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9576,7 +9597,7 @@ const EmailForm = ({ order }) => {
9576
9597
  defaultValues: {
9577
9598
  email: order.email ?? ""
9578
9599
  },
9579
- resolver: zodResolver(schema$5)
9600
+ resolver: zodResolver(schema$4)
9580
9601
  });
9581
9602
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9582
9603
  const { handleSuccess } = useRouteModal();
@@ -9619,7 +9640,7 @@ const EmailForm = ({ order }) => {
9619
9640
  }
9620
9641
  ) });
9621
9642
  };
9622
- const schema$5 = objectType({
9643
+ const schema$4 = objectType({
9623
9644
  email: stringType().email()
9624
9645
  });
9625
9646
  const NumberInput = forwardRef(
@@ -11223,112 +11244,6 @@ function getPromotionCodes(items, shippingMethods) {
11223
11244
  }
11224
11245
  return Array.from(codes);
11225
11246
  }
11226
- const SalesChannel = () => {
11227
- const { id } = useParams();
11228
- const { draft_order, isPending, isError, error } = useDraftOrder(
11229
- id,
11230
- {
11231
- fields: "+sales_channel_id"
11232
- },
11233
- {
11234
- enabled: !!id
11235
- }
11236
- );
11237
- if (isError) {
11238
- throw error;
11239
- }
11240
- const ISrEADY = !!draft_order && !isPending;
11241
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11242
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11243
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11244
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11245
- ] }),
11246
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11247
- ] });
11248
- };
11249
- const SalesChannelForm = ({ order }) => {
11250
- const form = useForm({
11251
- defaultValues: {
11252
- sales_channel_id: order.sales_channel_id || ""
11253
- },
11254
- resolver: zodResolver(schema$4)
11255
- });
11256
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11257
- const { handleSuccess } = useRouteModal();
11258
- const onSubmit = form.handleSubmit(async (data) => {
11259
- await mutateAsync(
11260
- {
11261
- sales_channel_id: data.sales_channel_id
11262
- },
11263
- {
11264
- onSuccess: () => {
11265
- toast.success("Sales channel updated");
11266
- handleSuccess();
11267
- },
11268
- onError: (error) => {
11269
- toast.error(error.message);
11270
- }
11271
- }
11272
- );
11273
- });
11274
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11275
- KeyboundForm,
11276
- {
11277
- className: "flex flex-1 flex-col overflow-hidden",
11278
- onSubmit,
11279
- children: [
11280
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11281
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11282
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11283
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11284
- ] }) })
11285
- ]
11286
- }
11287
- ) });
11288
- };
11289
- const SalesChannelField = ({ control, order }) => {
11290
- const salesChannels = useComboboxData({
11291
- queryFn: async (params) => {
11292
- return await sdk.admin.salesChannel.list(params);
11293
- },
11294
- queryKey: ["sales-channels"],
11295
- getOptions: (data) => {
11296
- return data.sales_channels.map((salesChannel) => ({
11297
- label: salesChannel.name,
11298
- value: salesChannel.id
11299
- }));
11300
- },
11301
- defaultValue: order.sales_channel_id || void 0
11302
- });
11303
- return /* @__PURE__ */ jsx(
11304
- Form$2.Field,
11305
- {
11306
- control,
11307
- name: "sales_channel_id",
11308
- render: ({ field }) => {
11309
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11310
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11311
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11312
- Combobox,
11313
- {
11314
- options: salesChannels.options,
11315
- fetchNextPage: salesChannels.fetchNextPage,
11316
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11317
- searchValue: salesChannels.searchValue,
11318
- onSearchValueChange: salesChannels.onSearchValueChange,
11319
- placeholder: "Select sales channel",
11320
- ...field
11321
- }
11322
- ) }),
11323
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11324
- ] });
11325
- }
11326
- }
11327
- );
11328
- };
11329
- const schema$4 = objectType({
11330
- sales_channel_id: stringType().min(1)
11331
- });
11332
11247
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11333
11248
  const Shipping = () => {
11334
11249
  var _a;
@@ -12136,6 +12051,112 @@ const CustomAmountField = ({
12136
12051
  }
12137
12052
  );
12138
12053
  };
12054
+ const SalesChannel = () => {
12055
+ const { id } = useParams();
12056
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12057
+ id,
12058
+ {
12059
+ fields: "+sales_channel_id"
12060
+ },
12061
+ {
12062
+ enabled: !!id
12063
+ }
12064
+ );
12065
+ if (isError) {
12066
+ throw error;
12067
+ }
12068
+ const ISrEADY = !!draft_order && !isPending;
12069
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12070
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12071
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12072
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12073
+ ] }),
12074
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12075
+ ] });
12076
+ };
12077
+ const SalesChannelForm = ({ order }) => {
12078
+ const form = useForm({
12079
+ defaultValues: {
12080
+ sales_channel_id: order.sales_channel_id || ""
12081
+ },
12082
+ resolver: zodResolver(schema$3)
12083
+ });
12084
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12085
+ const { handleSuccess } = useRouteModal();
12086
+ const onSubmit = form.handleSubmit(async (data) => {
12087
+ await mutateAsync(
12088
+ {
12089
+ sales_channel_id: data.sales_channel_id
12090
+ },
12091
+ {
12092
+ onSuccess: () => {
12093
+ toast.success("Sales channel updated");
12094
+ handleSuccess();
12095
+ },
12096
+ onError: (error) => {
12097
+ toast.error(error.message);
12098
+ }
12099
+ }
12100
+ );
12101
+ });
12102
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12103
+ KeyboundForm,
12104
+ {
12105
+ className: "flex flex-1 flex-col overflow-hidden",
12106
+ onSubmit,
12107
+ children: [
12108
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12109
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12110
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12111
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12112
+ ] }) })
12113
+ ]
12114
+ }
12115
+ ) });
12116
+ };
12117
+ const SalesChannelField = ({ control, order }) => {
12118
+ const salesChannels = useComboboxData({
12119
+ queryFn: async (params) => {
12120
+ return await sdk.admin.salesChannel.list(params);
12121
+ },
12122
+ queryKey: ["sales-channels"],
12123
+ getOptions: (data) => {
12124
+ return data.sales_channels.map((salesChannel) => ({
12125
+ label: salesChannel.name,
12126
+ value: salesChannel.id
12127
+ }));
12128
+ },
12129
+ defaultValue: order.sales_channel_id || void 0
12130
+ });
12131
+ return /* @__PURE__ */ jsx(
12132
+ Form$2.Field,
12133
+ {
12134
+ control,
12135
+ name: "sales_channel_id",
12136
+ render: ({ field }) => {
12137
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12138
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12139
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12140
+ Combobox,
12141
+ {
12142
+ options: salesChannels.options,
12143
+ fetchNextPage: salesChannels.fetchNextPage,
12144
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12145
+ searchValue: salesChannels.searchValue,
12146
+ onSearchValueChange: salesChannels.onSearchValueChange,
12147
+ placeholder: "Select sales channel",
12148
+ ...field
12149
+ }
12150
+ ) }),
12151
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12152
+ ] });
12153
+ }
12154
+ }
12155
+ );
12156
+ };
12157
+ const schema$3 = objectType({
12158
+ sales_channel_id: stringType().min(1)
12159
+ });
12139
12160
  const ShippingAddress = () => {
12140
12161
  const { id } = useParams();
12141
12162
  const { order, isPending, isError, error } = useOrder(id, {
@@ -12168,7 +12189,7 @@ const ShippingAddressForm = ({ order }) => {
12168
12189
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12169
12190
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12170
12191
  },
12171
- resolver: zodResolver(schema$3)
12192
+ resolver: zodResolver(schema$2)
12172
12193
  });
12173
12194
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12174
12195
  const { handleSuccess } = useRouteModal();
@@ -12338,7 +12359,7 @@ const ShippingAddressForm = ({ order }) => {
12338
12359
  }
12339
12360
  ) });
12340
12361
  };
12341
- const schema$3 = addressSchema;
12362
+ const schema$2 = addressSchema;
12342
12363
  const TransferOwnership = () => {
12343
12364
  const { id } = useParams();
12344
12365
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12362,7 +12383,7 @@ const TransferOwnershipForm = ({ order }) => {
12362
12383
  defaultValues: {
12363
12384
  customer_id: order.customer_id || ""
12364
12385
  },
12365
- resolver: zodResolver(schema$2)
12386
+ resolver: zodResolver(schema$1)
12366
12387
  });
12367
12388
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12368
12389
  const { handleSuccess } = useRouteModal();
@@ -12812,29 +12833,8 @@ const Illustration = () => {
12812
12833
  }
12813
12834
  );
12814
12835
  };
12815
- const schema$2 = objectType({
12816
- customer_id: stringType().min(1)
12817
- });
12818
- const CustomItems = () => {
12819
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12820
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
12821
- /* @__PURE__ */ jsx(CustomItemsForm, {})
12822
- ] });
12823
- };
12824
- const CustomItemsForm = () => {
12825
- const form = useForm({
12826
- resolver: zodResolver(schema$1)
12827
- });
12828
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
12829
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
12830
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12831
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12832
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
12833
- ] }) })
12834
- ] }) });
12835
- };
12836
12836
  const schema$1 = objectType({
12837
- email: stringType().email()
12837
+ customer_id: stringType().min(1)
12838
12838
  });
12839
12839
  const BillingAddress = () => {
12840
12840
  const { id } = useParams();
@@ -13046,6 +13046,10 @@ const routeModule = {
13046
13046
  handle,
13047
13047
  loader,
13048
13048
  children: [
13049
+ {
13050
+ Component: CustomItems,
13051
+ path: "/draft-orders/:id/custom-items"
13052
+ },
13049
13053
  {
13050
13054
  Component: Email,
13051
13055
  path: "/draft-orders/:id/email"
@@ -13062,14 +13066,14 @@ const routeModule = {
13062
13066
  Component: Promotions,
13063
13067
  path: "/draft-orders/:id/promotions"
13064
13068
  },
13065
- {
13066
- Component: SalesChannel,
13067
- path: "/draft-orders/:id/sales-channel"
13068
- },
13069
13069
  {
13070
13070
  Component: Shipping,
13071
13071
  path: "/draft-orders/:id/shipping"
13072
13072
  },
13073
+ {
13074
+ Component: SalesChannel,
13075
+ path: "/draft-orders/:id/sales-channel"
13076
+ },
13073
13077
  {
13074
13078
  Component: ShippingAddress,
13075
13079
  path: "/draft-orders/:id/shipping-address"
@@ -13078,10 +13082,6 @@ const routeModule = {
13078
13082
  Component: TransferOwnership,
13079
13083
  path: "/draft-orders/:id/transfer-ownership"
13080
13084
  },
13081
- {
13082
- Component: CustomItems,
13083
- path: "/draft-orders/:id/custom-items"
13084
- },
13085
13085
  {
13086
13086
  Component: BillingAddress,
13087
13087
  path: "/draft-orders/:id/billing-address"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.10.2-preview-20250903060148",
3
+ "version": "2.10.2-preview-20250903090152",
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.2-preview-20250903060148",
39
+ "@medusajs/js-sdk": "2.10.2-preview-20250903090152",
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.2-preview-20250903060148",
49
- "@medusajs/cli": "2.10.2-preview-20250903060148",
50
- "@medusajs/framework": "2.10.2-preview-20250903060148",
51
- "@medusajs/icons": "2.10.2-preview-20250903060148",
52
- "@medusajs/test-utils": "2.10.2-preview-20250903060148",
53
- "@medusajs/types": "2.10.2-preview-20250903060148",
54
- "@medusajs/ui": "4.0.22-preview-20250903060148",
55
- "@medusajs/ui-preset": "2.10.2-preview-20250903060148",
48
+ "@medusajs/admin-sdk": "2.10.2-preview-20250903090152",
49
+ "@medusajs/cli": "2.10.2-preview-20250903090152",
50
+ "@medusajs/framework": "2.10.2-preview-20250903090152",
51
+ "@medusajs/icons": "2.10.2-preview-20250903090152",
52
+ "@medusajs/test-utils": "2.10.2-preview-20250903090152",
53
+ "@medusajs/types": "2.10.2-preview-20250903090152",
54
+ "@medusajs/ui": "4.0.22-preview-20250903090152",
55
+ "@medusajs/ui-preset": "2.10.2-preview-20250903090152",
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.2-preview-20250903060148",
80
- "@medusajs/cli": "2.10.2-preview-20250903060148",
81
- "@medusajs/framework": "2.10.2-preview-20250903060148",
82
- "@medusajs/icons": "2.10.2-preview-20250903060148",
83
- "@medusajs/test-utils": "2.10.2-preview-20250903060148",
84
- "@medusajs/ui": "4.0.22-preview-20250903060148",
79
+ "@medusajs/admin-sdk": "2.10.2-preview-20250903090152",
80
+ "@medusajs/cli": "2.10.2-preview-20250903090152",
81
+ "@medusajs/framework": "2.10.2-preview-20250903090152",
82
+ "@medusajs/icons": "2.10.2-preview-20250903090152",
83
+ "@medusajs/test-utils": "2.10.2-preview-20250903090152",
84
+ "@medusajs/ui": "4.0.22-preview-20250903090152",
85
85
  "@mikro-orm/cli": "6.4.3",
86
86
  "@mikro-orm/core": "6.4.3",
87
87
  "@mikro-orm/knex": "6.4.3",