@medusajs/draft-order 2.10.2-preview-20250908180200 → 2.10.2-preview-20250908210158

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.
@@ -9573,6 +9573,196 @@ const ID = () => {
9573
9573
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9574
9574
  ] });
9575
9575
  };
9576
+ const BillingAddress = () => {
9577
+ const { id } = reactRouterDom.useParams();
9578
+ const { order, isPending, isError, error } = useOrder(id, {
9579
+ fields: "+billing_address"
9580
+ });
9581
+ if (isError) {
9582
+ throw error;
9583
+ }
9584
+ const isReady = !isPending && !!order;
9585
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9586
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9588
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9589
+ ] }),
9590
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9591
+ ] });
9592
+ };
9593
+ const BillingAddressForm = ({ order }) => {
9594
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9595
+ const form = reactHookForm.useForm({
9596
+ defaultValues: {
9597
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9598
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9599
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9600
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9601
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9602
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9603
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9604
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9605
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9606
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9607
+ },
9608
+ resolver: zod.zodResolver(schema$5)
9609
+ });
9610
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9611
+ const { handleSuccess } = useRouteModal();
9612
+ const onSubmit = form.handleSubmit(async (data) => {
9613
+ await mutateAsync(
9614
+ { billing_address: data },
9615
+ {
9616
+ onSuccess: () => {
9617
+ handleSuccess();
9618
+ },
9619
+ onError: (error) => {
9620
+ ui.toast.error(error.message);
9621
+ }
9622
+ }
9623
+ );
9624
+ });
9625
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9626
+ KeyboundForm,
9627
+ {
9628
+ className: "flex flex-1 flex-col overflow-hidden",
9629
+ onSubmit,
9630
+ children: [
9631
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
9632
+ /* @__PURE__ */ jsxRuntime.jsx(
9633
+ Form$2.Field,
9634
+ {
9635
+ control: form.control,
9636
+ name: "country_code",
9637
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9638
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9639
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9640
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9641
+ ] })
9642
+ }
9643
+ ),
9644
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9645
+ /* @__PURE__ */ jsxRuntime.jsx(
9646
+ Form$2.Field,
9647
+ {
9648
+ control: form.control,
9649
+ name: "first_name",
9650
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9651
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9652
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9653
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9654
+ ] })
9655
+ }
9656
+ ),
9657
+ /* @__PURE__ */ jsxRuntime.jsx(
9658
+ Form$2.Field,
9659
+ {
9660
+ control: form.control,
9661
+ name: "last_name",
9662
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9663
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9664
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9665
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9666
+ ] })
9667
+ }
9668
+ )
9669
+ ] }),
9670
+ /* @__PURE__ */ jsxRuntime.jsx(
9671
+ Form$2.Field,
9672
+ {
9673
+ control: form.control,
9674
+ name: "company",
9675
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9676
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9677
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9678
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9679
+ ] })
9680
+ }
9681
+ ),
9682
+ /* @__PURE__ */ jsxRuntime.jsx(
9683
+ Form$2.Field,
9684
+ {
9685
+ control: form.control,
9686
+ name: "address_1",
9687
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9688
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9689
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9690
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9691
+ ] })
9692
+ }
9693
+ ),
9694
+ /* @__PURE__ */ jsxRuntime.jsx(
9695
+ Form$2.Field,
9696
+ {
9697
+ control: form.control,
9698
+ name: "address_2",
9699
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9701
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9702
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9703
+ ] })
9704
+ }
9705
+ ),
9706
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9707
+ /* @__PURE__ */ jsxRuntime.jsx(
9708
+ Form$2.Field,
9709
+ {
9710
+ control: form.control,
9711
+ name: "postal_code",
9712
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9714
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9715
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9716
+ ] })
9717
+ }
9718
+ ),
9719
+ /* @__PURE__ */ jsxRuntime.jsx(
9720
+ Form$2.Field,
9721
+ {
9722
+ control: form.control,
9723
+ name: "city",
9724
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9727
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9728
+ ] })
9729
+ }
9730
+ )
9731
+ ] }),
9732
+ /* @__PURE__ */ jsxRuntime.jsx(
9733
+ Form$2.Field,
9734
+ {
9735
+ control: form.control,
9736
+ name: "province",
9737
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9739
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9740
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9741
+ ] })
9742
+ }
9743
+ ),
9744
+ /* @__PURE__ */ jsxRuntime.jsx(
9745
+ Form$2.Field,
9746
+ {
9747
+ control: form.control,
9748
+ name: "phone",
9749
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9751
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9752
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9753
+ ] })
9754
+ }
9755
+ )
9756
+ ] }) }),
9757
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9758
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9759
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9760
+ ] }) })
9761
+ ]
9762
+ }
9763
+ ) });
9764
+ };
9765
+ const schema$5 = addressSchema;
9576
9766
  const Email = () => {
9577
9767
  const { id } = reactRouterDom.useParams();
9578
9768
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9595,7 +9785,7 @@ const EmailForm = ({ order }) => {
9595
9785
  defaultValues: {
9596
9786
  email: order.email ?? ""
9597
9787
  },
9598
- resolver: zod.zodResolver(schema$5)
9788
+ resolver: zod.zodResolver(schema$4)
9599
9789
  });
9600
9790
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9601
9791
  const { handleSuccess } = useRouteModal();
@@ -9638,7 +9828,28 @@ const EmailForm = ({ order }) => {
9638
9828
  }
9639
9829
  ) });
9640
9830
  };
9641
- const schema$5 = objectType({
9831
+ const schema$4 = objectType({
9832
+ email: stringType().email()
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({
9642
9853
  email: stringType().email()
9643
9854
  });
9644
9855
  const NumberInput = React.forwardRef(
@@ -11242,127 +11453,21 @@ function getPromotionIds(items, shippingMethods) {
11242
11453
  }
11243
11454
  return Array.from(promotionIds);
11244
11455
  }
11245
- const SalesChannel = () => {
11456
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11457
+ const Shipping = () => {
11458
+ var _a;
11246
11459
  const { id } = reactRouterDom.useParams();
11247
- const { draft_order, isPending, isError, error } = useDraftOrder(
11248
- id,
11249
- {
11250
- fields: "+sales_channel_id"
11251
- },
11252
- {
11253
- enabled: !!id
11254
- }
11255
- );
11256
- if (isError) {
11257
- throw error;
11258
- }
11259
- const ISrEADY = !!draft_order && !isPending;
11260
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11261
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11262
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11263
- /* @__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" }) })
11264
- ] }),
11265
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11266
- ] });
11267
- };
11268
- const SalesChannelForm = ({ order }) => {
11269
- const form = reactHookForm.useForm({
11270
- defaultValues: {
11271
- sales_channel_id: order.sales_channel_id || ""
11272
- },
11273
- resolver: zod.zodResolver(schema$4)
11274
- });
11275
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11276
- const { handleSuccess } = useRouteModal();
11277
- const onSubmit = form.handleSubmit(async (data) => {
11278
- await mutateAsync(
11279
- {
11280
- sales_channel_id: data.sales_channel_id
11281
- },
11282
- {
11283
- onSuccess: () => {
11284
- ui.toast.success("Sales channel updated");
11285
- handleSuccess();
11286
- },
11287
- onError: (error) => {
11288
- ui.toast.error(error.message);
11289
- }
11290
- }
11291
- );
11292
- });
11293
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11294
- KeyboundForm,
11295
- {
11296
- className: "flex flex-1 flex-col overflow-hidden",
11297
- onSubmit,
11298
- children: [
11299
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11300
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11301
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11302
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11303
- ] }) })
11304
- ]
11305
- }
11306
- ) });
11307
- };
11308
- const SalesChannelField = ({ control, order }) => {
11309
- const salesChannels = useComboboxData({
11310
- queryFn: async (params) => {
11311
- return await sdk.admin.salesChannel.list(params);
11312
- },
11313
- queryKey: ["sales-channels"],
11314
- getOptions: (data) => {
11315
- return data.sales_channels.map((salesChannel) => ({
11316
- label: salesChannel.name,
11317
- value: salesChannel.id
11318
- }));
11319
- },
11320
- defaultValue: order.sales_channel_id || void 0
11321
- });
11322
- return /* @__PURE__ */ jsxRuntime.jsx(
11323
- Form$2.Field,
11324
- {
11325
- control,
11326
- name: "sales_channel_id",
11327
- render: ({ field }) => {
11328
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11329
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11330
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11331
- Combobox,
11332
- {
11333
- options: salesChannels.options,
11334
- fetchNextPage: salesChannels.fetchNextPage,
11335
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11336
- searchValue: salesChannels.searchValue,
11337
- onSearchValueChange: salesChannels.onSearchValueChange,
11338
- placeholder: "Select sales channel",
11339
- ...field
11340
- }
11341
- ) }),
11342
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11343
- ] });
11344
- }
11345
- }
11346
- );
11347
- };
11348
- const schema$4 = objectType({
11349
- sales_channel_id: stringType().min(1)
11350
- });
11351
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11352
- const Shipping = () => {
11353
- var _a;
11354
- const { id } = reactRouterDom.useParams();
11355
- const { order, isPending, isError, error } = useOrder(id, {
11356
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11357
- });
11358
- const {
11359
- order: preview,
11360
- isPending: isPreviewPending,
11361
- isError: isPreviewError,
11362
- error: previewError
11363
- } = useOrderPreview(id);
11364
- useInitiateOrderEdit({ preview });
11365
- const { onCancel } = useCancelOrderEdit({ preview });
11460
+ const { order, isPending, isError, error } = useOrder(id, {
11461
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11462
+ });
11463
+ const {
11464
+ order: preview,
11465
+ isPending: isPreviewPending,
11466
+ isError: isPreviewError,
11467
+ error: previewError
11468
+ } = useOrderPreview(id);
11469
+ useInitiateOrderEdit({ preview });
11470
+ const { onCancel } = useCancelOrderEdit({ preview });
11366
11471
  if (isError) {
11367
11472
  throw error;
11368
11473
  }
@@ -12187,7 +12292,7 @@ const ShippingAddressForm = ({ order }) => {
12187
12292
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12188
12293
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12189
12294
  },
12190
- resolver: zod.zodResolver(schema$3)
12295
+ resolver: zod.zodResolver(schema$2)
12191
12296
  });
12192
12297
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12193
12298
  const { handleSuccess } = useRouteModal();
@@ -12357,7 +12462,113 @@ const ShippingAddressForm = ({ order }) => {
12357
12462
  }
12358
12463
  ) });
12359
12464
  };
12360
- const schema$3 = addressSchema;
12465
+ const schema$2 = addressSchema;
12466
+ const SalesChannel = () => {
12467
+ const { id } = reactRouterDom.useParams();
12468
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12469
+ id,
12470
+ {
12471
+ fields: "+sales_channel_id"
12472
+ },
12473
+ {
12474
+ enabled: !!id
12475
+ }
12476
+ );
12477
+ if (isError) {
12478
+ throw error;
12479
+ }
12480
+ const ISrEADY = !!draft_order && !isPending;
12481
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12482
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12483
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12484
+ /* @__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" }) })
12485
+ ] }),
12486
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12487
+ ] });
12488
+ };
12489
+ const SalesChannelForm = ({ order }) => {
12490
+ const form = reactHookForm.useForm({
12491
+ defaultValues: {
12492
+ sales_channel_id: order.sales_channel_id || ""
12493
+ },
12494
+ resolver: zod.zodResolver(schema$1)
12495
+ });
12496
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12497
+ const { handleSuccess } = useRouteModal();
12498
+ const onSubmit = form.handleSubmit(async (data) => {
12499
+ await mutateAsync(
12500
+ {
12501
+ sales_channel_id: data.sales_channel_id
12502
+ },
12503
+ {
12504
+ onSuccess: () => {
12505
+ ui.toast.success("Sales channel updated");
12506
+ handleSuccess();
12507
+ },
12508
+ onError: (error) => {
12509
+ ui.toast.error(error.message);
12510
+ }
12511
+ }
12512
+ );
12513
+ });
12514
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12515
+ KeyboundForm,
12516
+ {
12517
+ className: "flex flex-1 flex-col overflow-hidden",
12518
+ onSubmit,
12519
+ children: [
12520
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12521
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12522
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12523
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12524
+ ] }) })
12525
+ ]
12526
+ }
12527
+ ) });
12528
+ };
12529
+ const SalesChannelField = ({ control, order }) => {
12530
+ const salesChannels = useComboboxData({
12531
+ queryFn: async (params) => {
12532
+ return await sdk.admin.salesChannel.list(params);
12533
+ },
12534
+ queryKey: ["sales-channels"],
12535
+ getOptions: (data) => {
12536
+ return data.sales_channels.map((salesChannel) => ({
12537
+ label: salesChannel.name,
12538
+ value: salesChannel.id
12539
+ }));
12540
+ },
12541
+ defaultValue: order.sales_channel_id || void 0
12542
+ });
12543
+ return /* @__PURE__ */ jsxRuntime.jsx(
12544
+ Form$2.Field,
12545
+ {
12546
+ control,
12547
+ name: "sales_channel_id",
12548
+ render: ({ field }) => {
12549
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12550
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12551
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12552
+ Combobox,
12553
+ {
12554
+ options: salesChannels.options,
12555
+ fetchNextPage: salesChannels.fetchNextPage,
12556
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12557
+ searchValue: salesChannels.searchValue,
12558
+ onSearchValueChange: salesChannels.onSearchValueChange,
12559
+ placeholder: "Select sales channel",
12560
+ ...field
12561
+ }
12562
+ ) }),
12563
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12564
+ ] });
12565
+ }
12566
+ }
12567
+ );
12568
+ };
12569
+ const schema$1 = objectType({
12570
+ sales_channel_id: stringType().min(1)
12571
+ });
12361
12572
  const TransferOwnership = () => {
12362
12573
  const { id } = reactRouterDom.useParams();
12363
12574
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12381,7 +12592,7 @@ const TransferOwnershipForm = ({ order }) => {
12381
12592
  defaultValues: {
12382
12593
  customer_id: order.customer_id || ""
12383
12594
  },
12384
- resolver: zod.zodResolver(schema$2)
12595
+ resolver: zod.zodResolver(schema)
12385
12596
  });
12386
12597
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12387
12598
  const { handleSuccess } = useRouteModal();
@@ -12831,219 +13042,8 @@ const Illustration = () => {
12831
13042
  }
12832
13043
  );
12833
13044
  };
12834
- const schema$2 = objectType({
12835
- customer_id: stringType().min(1)
12836
- });
12837
- const BillingAddress = () => {
12838
- const { id } = reactRouterDom.useParams();
12839
- const { order, isPending, isError, error } = useOrder(id, {
12840
- fields: "+billing_address"
12841
- });
12842
- if (isError) {
12843
- throw error;
12844
- }
12845
- const isReady = !isPending && !!order;
12846
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12847
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12848
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12849
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12850
- ] }),
12851
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12852
- ] });
12853
- };
12854
- const BillingAddressForm = ({ order }) => {
12855
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12856
- const form = reactHookForm.useForm({
12857
- defaultValues: {
12858
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12859
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12860
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12861
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12862
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12863
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12864
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12865
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12866
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12867
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12868
- },
12869
- resolver: zod.zodResolver(schema$1)
12870
- });
12871
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12872
- const { handleSuccess } = useRouteModal();
12873
- const onSubmit = form.handleSubmit(async (data) => {
12874
- await mutateAsync(
12875
- { billing_address: data },
12876
- {
12877
- onSuccess: () => {
12878
- handleSuccess();
12879
- },
12880
- onError: (error) => {
12881
- ui.toast.error(error.message);
12882
- }
12883
- }
12884
- );
12885
- });
12886
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12887
- KeyboundForm,
12888
- {
12889
- className: "flex flex-1 flex-col overflow-hidden",
12890
- onSubmit,
12891
- children: [
12892
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
12893
- /* @__PURE__ */ jsxRuntime.jsx(
12894
- Form$2.Field,
12895
- {
12896
- control: form.control,
12897
- name: "country_code",
12898
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12899
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12900
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12901
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12902
- ] })
12903
- }
12904
- ),
12905
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12906
- /* @__PURE__ */ jsxRuntime.jsx(
12907
- Form$2.Field,
12908
- {
12909
- control: form.control,
12910
- name: "first_name",
12911
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12912
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12913
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12914
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12915
- ] })
12916
- }
12917
- ),
12918
- /* @__PURE__ */ jsxRuntime.jsx(
12919
- Form$2.Field,
12920
- {
12921
- control: form.control,
12922
- name: "last_name",
12923
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12924
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12925
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12926
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12927
- ] })
12928
- }
12929
- )
12930
- ] }),
12931
- /* @__PURE__ */ jsxRuntime.jsx(
12932
- Form$2.Field,
12933
- {
12934
- control: form.control,
12935
- name: "company",
12936
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12937
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12938
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12939
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12940
- ] })
12941
- }
12942
- ),
12943
- /* @__PURE__ */ jsxRuntime.jsx(
12944
- Form$2.Field,
12945
- {
12946
- control: form.control,
12947
- name: "address_1",
12948
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12949
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12950
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12951
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12952
- ] })
12953
- }
12954
- ),
12955
- /* @__PURE__ */ jsxRuntime.jsx(
12956
- Form$2.Field,
12957
- {
12958
- control: form.control,
12959
- name: "address_2",
12960
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12961
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12962
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12963
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12964
- ] })
12965
- }
12966
- ),
12967
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12968
- /* @__PURE__ */ jsxRuntime.jsx(
12969
- Form$2.Field,
12970
- {
12971
- control: form.control,
12972
- name: "postal_code",
12973
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12974
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12975
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12976
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12977
- ] })
12978
- }
12979
- ),
12980
- /* @__PURE__ */ jsxRuntime.jsx(
12981
- Form$2.Field,
12982
- {
12983
- control: form.control,
12984
- name: "city",
12985
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12986
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12987
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12988
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12989
- ] })
12990
- }
12991
- )
12992
- ] }),
12993
- /* @__PURE__ */ jsxRuntime.jsx(
12994
- Form$2.Field,
12995
- {
12996
- control: form.control,
12997
- name: "province",
12998
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12999
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13000
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13001
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13002
- ] })
13003
- }
13004
- ),
13005
- /* @__PURE__ */ jsxRuntime.jsx(
13006
- Form$2.Field,
13007
- {
13008
- control: form.control,
13009
- name: "phone",
13010
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13011
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13012
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13013
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13014
- ] })
13015
- }
13016
- )
13017
- ] }) }),
13018
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13019
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13020
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13021
- ] }) })
13022
- ]
13023
- }
13024
- ) });
13025
- };
13026
- const schema$1 = addressSchema;
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 = {
@@ -13065,10 +13065,18 @@ const routeModule = {
13065
13065
  handle,
13066
13066
  loader,
13067
13067
  children: [
13068
+ {
13069
+ Component: BillingAddress,
13070
+ path: "/draft-orders/:id/billing-address"
13071
+ },
13068
13072
  {
13069
13073
  Component: Email,
13070
13074
  path: "/draft-orders/:id/email"
13071
13075
  },
13076
+ {
13077
+ Component: CustomItems,
13078
+ path: "/draft-orders/:id/custom-items"
13079
+ },
13072
13080
  {
13073
13081
  Component: Items,
13074
13082
  path: "/draft-orders/:id/items"
@@ -13081,10 +13089,6 @@ const routeModule = {
13081
13089
  Component: Promotions,
13082
13090
  path: "/draft-orders/:id/promotions"
13083
13091
  },
13084
- {
13085
- Component: SalesChannel,
13086
- path: "/draft-orders/:id/sales-channel"
13087
- },
13088
13092
  {
13089
13093
  Component: Shipping,
13090
13094
  path: "/draft-orders/:id/shipping"
@@ -13094,16 +13098,12 @@ const routeModule = {
13094
13098
  path: "/draft-orders/:id/shipping-address"
13095
13099
  },
13096
13100
  {
13097
- Component: TransferOwnership,
13098
- path: "/draft-orders/:id/transfer-ownership"
13099
- },
13100
- {
13101
- Component: BillingAddress,
13102
- path: "/draft-orders/:id/billing-address"
13101
+ Component: SalesChannel,
13102
+ path: "/draft-orders/:id/sales-channel"
13103
13103
  },
13104
13104
  {
13105
- Component: CustomItems,
13106
- path: "/draft-orders/:id/custom-items"
13105
+ Component: TransferOwnership,
13106
+ path: "/draft-orders/:id/transfer-ownership"
13107
13107
  }
13108
13108
  ]
13109
13109
  }