@medusajs/draft-order 3.0.0-snapshot-20251215083939 → 3.0.0-snapshot-20251215162333

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.
@@ -9572,31 +9572,10 @@ const ID = () => {
9572
9572
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9573
9573
  ] });
9574
9574
  };
9575
- const CustomItems = () => {
9576
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9577
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9578
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9579
- ] });
9580
- };
9581
- const CustomItemsForm = () => {
9582
- const form = reactHookForm.useForm({
9583
- resolver: zod.zodResolver(schema$5)
9584
- });
9585
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9586
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9587
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9588
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9589
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9590
- ] }) })
9591
- ] }) });
9592
- };
9593
- const schema$5 = objectType({
9594
- email: stringType().email()
9595
- });
9596
- const Email = () => {
9575
+ const BillingAddress = () => {
9597
9576
  const { id } = reactRouterDom.useParams();
9598
9577
  const { order, isPending, isError, error } = useOrder(id, {
9599
- fields: "+email"
9578
+ fields: "+billing_address"
9600
9579
  });
9601
9580
  if (isError) {
9602
9581
  throw error;
@@ -9604,24 +9583,34 @@ const Email = () => {
9604
9583
  const isReady = !isPending && !!order;
9605
9584
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9606
9585
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9607
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9608
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9586
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9609
9588
  ] }),
9610
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9589
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9611
9590
  ] });
9612
9591
  };
9613
- const EmailForm = ({ order }) => {
9592
+ const BillingAddressForm = ({ order }) => {
9593
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9614
9594
  const form = reactHookForm.useForm({
9615
9595
  defaultValues: {
9616
- email: order.email ?? ""
9596
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9597
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9598
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9599
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9600
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9601
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9602
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9603
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9604
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9605
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9617
9606
  },
9618
- resolver: zod.zodResolver(schema$4)
9607
+ resolver: zod.zodResolver(schema$5)
9619
9608
  });
9620
9609
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9621
9610
  const { handleSuccess } = useRouteModal();
9622
9611
  const onSubmit = form.handleSubmit(async (data) => {
9623
9612
  await mutateAsync(
9624
- { email: data.email },
9613
+ { billing_address: data },
9625
9614
  {
9626
9615
  onSuccess: () => {
9627
9616
  handleSuccess();
@@ -9638,18 +9627,132 @@ const EmailForm = ({ order }) => {
9638
9627
  className: "flex flex-1 flex-col overflow-hidden",
9639
9628
  onSubmit,
9640
9629
  children: [
9641
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9642
- Form$2.Field,
9643
- {
9644
- control: form.control,
9645
- name: "email",
9646
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9647
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9648
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9649
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9650
- ] })
9651
- }
9652
- ) }),
9630
+ /* @__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: [
9631
+ /* @__PURE__ */ jsxRuntime.jsx(
9632
+ Form$2.Field,
9633
+ {
9634
+ control: form.control,
9635
+ name: "country_code",
9636
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9637
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9638
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9639
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9640
+ ] })
9641
+ }
9642
+ ),
9643
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9644
+ /* @__PURE__ */ jsxRuntime.jsx(
9645
+ Form$2.Field,
9646
+ {
9647
+ control: form.control,
9648
+ name: "first_name",
9649
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9650
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9651
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9652
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9653
+ ] })
9654
+ }
9655
+ ),
9656
+ /* @__PURE__ */ jsxRuntime.jsx(
9657
+ Form$2.Field,
9658
+ {
9659
+ control: form.control,
9660
+ name: "last_name",
9661
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9662
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9663
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9664
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9665
+ ] })
9666
+ }
9667
+ )
9668
+ ] }),
9669
+ /* @__PURE__ */ jsxRuntime.jsx(
9670
+ Form$2.Field,
9671
+ {
9672
+ control: form.control,
9673
+ name: "company",
9674
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9675
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9676
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9677
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9678
+ ] })
9679
+ }
9680
+ ),
9681
+ /* @__PURE__ */ jsxRuntime.jsx(
9682
+ Form$2.Field,
9683
+ {
9684
+ control: form.control,
9685
+ name: "address_1",
9686
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9687
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9688
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9689
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9690
+ ] })
9691
+ }
9692
+ ),
9693
+ /* @__PURE__ */ jsxRuntime.jsx(
9694
+ Form$2.Field,
9695
+ {
9696
+ control: form.control,
9697
+ name: "address_2",
9698
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9699
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9701
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9702
+ ] })
9703
+ }
9704
+ ),
9705
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9706
+ /* @__PURE__ */ jsxRuntime.jsx(
9707
+ Form$2.Field,
9708
+ {
9709
+ control: form.control,
9710
+ name: "postal_code",
9711
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9712
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9714
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9715
+ ] })
9716
+ }
9717
+ ),
9718
+ /* @__PURE__ */ jsxRuntime.jsx(
9719
+ Form$2.Field,
9720
+ {
9721
+ control: form.control,
9722
+ name: "city",
9723
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9724
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9727
+ ] })
9728
+ }
9729
+ )
9730
+ ] }),
9731
+ /* @__PURE__ */ jsxRuntime.jsx(
9732
+ Form$2.Field,
9733
+ {
9734
+ control: form.control,
9735
+ name: "province",
9736
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9737
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9739
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9740
+ ] })
9741
+ }
9742
+ ),
9743
+ /* @__PURE__ */ jsxRuntime.jsx(
9744
+ Form$2.Field,
9745
+ {
9746
+ control: form.control,
9747
+ name: "phone",
9748
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9749
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9751
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9752
+ ] })
9753
+ }
9754
+ )
9755
+ ] }) }),
9653
9756
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9654
9757
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9655
9758
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -9658,6 +9761,25 @@ const EmailForm = ({ order }) => {
9658
9761
  }
9659
9762
  ) });
9660
9763
  };
9764
+ const schema$5 = addressSchema;
9765
+ const CustomItems = () => {
9766
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9767
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9768
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9769
+ ] });
9770
+ };
9771
+ const CustomItemsForm = () => {
9772
+ const form = reactHookForm.useForm({
9773
+ resolver: zod.zodResolver(schema$4)
9774
+ });
9775
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9776
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9777
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9778
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9779
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9780
+ ] }) })
9781
+ ] }) });
9782
+ };
9661
9783
  const schema$4 = objectType({
9662
9784
  email: stringType().email()
9663
9785
  });
@@ -10635,6 +10757,74 @@ const customItemSchema = objectType({
10635
10757
  quantity: numberType(),
10636
10758
  unit_price: unionType([numberType(), stringType()])
10637
10759
  });
10760
+ const Email = () => {
10761
+ const { id } = reactRouterDom.useParams();
10762
+ const { order, isPending, isError, error } = useOrder(id, {
10763
+ fields: "+email"
10764
+ });
10765
+ if (isError) {
10766
+ throw error;
10767
+ }
10768
+ const isReady = !isPending && !!order;
10769
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10770
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10771
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
10772
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
10773
+ ] }),
10774
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
10775
+ ] });
10776
+ };
10777
+ const EmailForm = ({ order }) => {
10778
+ const form = reactHookForm.useForm({
10779
+ defaultValues: {
10780
+ email: order.email ?? ""
10781
+ },
10782
+ resolver: zod.zodResolver(schema$3)
10783
+ });
10784
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10785
+ const { handleSuccess } = useRouteModal();
10786
+ const onSubmit = form.handleSubmit(async (data) => {
10787
+ await mutateAsync(
10788
+ { email: data.email },
10789
+ {
10790
+ onSuccess: () => {
10791
+ handleSuccess();
10792
+ },
10793
+ onError: (error) => {
10794
+ ui.toast.error(error.message);
10795
+ }
10796
+ }
10797
+ );
10798
+ });
10799
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10800
+ KeyboundForm,
10801
+ {
10802
+ className: "flex flex-1 flex-col overflow-hidden",
10803
+ onSubmit,
10804
+ children: [
10805
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
10806
+ Form$2.Field,
10807
+ {
10808
+ control: form.control,
10809
+ name: "email",
10810
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10811
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
10812
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10813
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10814
+ ] })
10815
+ }
10816
+ ) }),
10817
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10818
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10819
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10820
+ ] }) })
10821
+ ]
10822
+ }
10823
+ ) });
10824
+ };
10825
+ const schema$3 = objectType({
10826
+ email: stringType().email()
10827
+ });
10638
10828
  const InlineTip = React.forwardRef(
10639
10829
  ({ variant = "tip", label, className, children, ...props }, ref) => {
10640
10830
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -11262,196 +11452,6 @@ function getPromotionIds(items, shippingMethods) {
11262
11452
  }
11263
11453
  return Array.from(promotionIds);
11264
11454
  }
11265
- const BillingAddress = () => {
11266
- const { id } = reactRouterDom.useParams();
11267
- const { order, isPending, isError, error } = useOrder(id, {
11268
- fields: "+billing_address"
11269
- });
11270
- if (isError) {
11271
- throw error;
11272
- }
11273
- const isReady = !isPending && !!order;
11274
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11275
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11276
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
11277
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
11278
- ] }),
11279
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
11280
- ] });
11281
- };
11282
- const BillingAddressForm = ({ order }) => {
11283
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11284
- const form = reactHookForm.useForm({
11285
- defaultValues: {
11286
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
11287
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
11288
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
11289
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
11290
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
11291
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
11292
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
11293
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
11294
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
11295
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
11296
- },
11297
- resolver: zod.zodResolver(schema$3)
11298
- });
11299
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11300
- const { handleSuccess } = useRouteModal();
11301
- const onSubmit = form.handleSubmit(async (data) => {
11302
- await mutateAsync(
11303
- { billing_address: data },
11304
- {
11305
- onSuccess: () => {
11306
- handleSuccess();
11307
- },
11308
- onError: (error) => {
11309
- ui.toast.error(error.message);
11310
- }
11311
- }
11312
- );
11313
- });
11314
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11315
- KeyboundForm,
11316
- {
11317
- className: "flex flex-1 flex-col overflow-hidden",
11318
- onSubmit,
11319
- children: [
11320
- /* @__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: [
11321
- /* @__PURE__ */ jsxRuntime.jsx(
11322
- Form$2.Field,
11323
- {
11324
- control: form.control,
11325
- name: "country_code",
11326
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11327
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11328
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11329
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11330
- ] })
11331
- }
11332
- ),
11333
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11334
- /* @__PURE__ */ jsxRuntime.jsx(
11335
- Form$2.Field,
11336
- {
11337
- control: form.control,
11338
- name: "first_name",
11339
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11340
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11341
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11342
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11343
- ] })
11344
- }
11345
- ),
11346
- /* @__PURE__ */ jsxRuntime.jsx(
11347
- Form$2.Field,
11348
- {
11349
- control: form.control,
11350
- name: "last_name",
11351
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11352
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11353
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11354
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11355
- ] })
11356
- }
11357
- )
11358
- ] }),
11359
- /* @__PURE__ */ jsxRuntime.jsx(
11360
- Form$2.Field,
11361
- {
11362
- control: form.control,
11363
- name: "company",
11364
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11365
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11366
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11367
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11368
- ] })
11369
- }
11370
- ),
11371
- /* @__PURE__ */ jsxRuntime.jsx(
11372
- Form$2.Field,
11373
- {
11374
- control: form.control,
11375
- name: "address_1",
11376
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11377
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11378
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11379
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11380
- ] })
11381
- }
11382
- ),
11383
- /* @__PURE__ */ jsxRuntime.jsx(
11384
- Form$2.Field,
11385
- {
11386
- control: form.control,
11387
- name: "address_2",
11388
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11389
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11390
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11391
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11392
- ] })
11393
- }
11394
- ),
11395
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11396
- /* @__PURE__ */ jsxRuntime.jsx(
11397
- Form$2.Field,
11398
- {
11399
- control: form.control,
11400
- name: "postal_code",
11401
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11402
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11403
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11404
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11405
- ] })
11406
- }
11407
- ),
11408
- /* @__PURE__ */ jsxRuntime.jsx(
11409
- Form$2.Field,
11410
- {
11411
- control: form.control,
11412
- name: "city",
11413
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11414
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11415
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11416
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11417
- ] })
11418
- }
11419
- )
11420
- ] }),
11421
- /* @__PURE__ */ jsxRuntime.jsx(
11422
- Form$2.Field,
11423
- {
11424
- control: form.control,
11425
- name: "province",
11426
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11427
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11428
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11429
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11430
- ] })
11431
- }
11432
- ),
11433
- /* @__PURE__ */ jsxRuntime.jsx(
11434
- Form$2.Field,
11435
- {
11436
- control: form.control,
11437
- name: "phone",
11438
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11439
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11440
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11441
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11442
- ] })
11443
- }
11444
- )
11445
- ] }) }),
11446
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11447
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11448
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11449
- ] }) })
11450
- ]
11451
- }
11452
- ) });
11453
- };
11454
- const schema$3 = addressSchema;
11455
11455
  const SalesChannel = () => {
11456
11456
  const { id } = reactRouterDom.useParams();
11457
11457
  const { draft_order, isPending, isError, error } = useDraftOrder(
@@ -13065,17 +13065,21 @@ const routeModule = {
13065
13065
  loader,
13066
13066
  children: [
13067
13067
  {
13068
- Component: CustomItems,
13069
- path: "/draft-orders/:id/custom-items"
13068
+ Component: BillingAddress,
13069
+ path: "/draft-orders/:id/billing-address"
13070
13070
  },
13071
13071
  {
13072
- Component: Email,
13073
- path: "/draft-orders/:id/email"
13072
+ Component: CustomItems,
13073
+ path: "/draft-orders/:id/custom-items"
13074
13074
  },
13075
13075
  {
13076
13076
  Component: Items,
13077
13077
  path: "/draft-orders/:id/items"
13078
13078
  },
13079
+ {
13080
+ Component: Email,
13081
+ path: "/draft-orders/:id/email"
13082
+ },
13079
13083
  {
13080
13084
  Component: Metadata,
13081
13085
  path: "/draft-orders/:id/metadata"
@@ -13084,10 +13088,6 @@ const routeModule = {
13084
13088
  Component: Promotions,
13085
13089
  path: "/draft-orders/:id/promotions"
13086
13090
  },
13087
- {
13088
- Component: BillingAddress,
13089
- path: "/draft-orders/:id/billing-address"
13090
- },
13091
13091
  {
13092
13092
  Component: SalesChannel,
13093
13093
  path: "/draft-orders/:id/sales-channel"
@@ -9565,31 +9565,10 @@ 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
- });
9589
- const Email = () => {
9568
+ const BillingAddress = () => {
9590
9569
  const { id } = useParams();
9591
9570
  const { order, isPending, isError, error } = useOrder(id, {
9592
- fields: "+email"
9571
+ fields: "+billing_address"
9593
9572
  });
9594
9573
  if (isError) {
9595
9574
  throw error;
@@ -9597,24 +9576,34 @@ const Email = () => {
9597
9576
  const isReady = !isPending && !!order;
9598
9577
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9599
9578
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9600
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
9601
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9579
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9580
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9602
9581
  ] }),
9603
- isReady && /* @__PURE__ */ jsx(EmailForm, { order })
9582
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9604
9583
  ] });
9605
9584
  };
9606
- const EmailForm = ({ order }) => {
9585
+ const BillingAddressForm = ({ order }) => {
9586
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9607
9587
  const form = useForm({
9608
9588
  defaultValues: {
9609
- email: order.email ?? ""
9589
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9590
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9591
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9592
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9593
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9594
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9595
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9596
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9597
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9598
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9610
9599
  },
9611
- resolver: zodResolver(schema$4)
9600
+ resolver: zodResolver(schema$5)
9612
9601
  });
9613
9602
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9614
9603
  const { handleSuccess } = useRouteModal();
9615
9604
  const onSubmit = form.handleSubmit(async (data) => {
9616
9605
  await mutateAsync(
9617
- { email: data.email },
9606
+ { billing_address: data },
9618
9607
  {
9619
9608
  onSuccess: () => {
9620
9609
  handleSuccess();
@@ -9631,18 +9620,132 @@ const EmailForm = ({ order }) => {
9631
9620
  className: "flex flex-1 flex-col overflow-hidden",
9632
9621
  onSubmit,
9633
9622
  children: [
9634
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
9635
- Form$2.Field,
9636
- {
9637
- control: form.control,
9638
- name: "email",
9639
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9640
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
9641
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9642
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9643
- ] })
9644
- }
9645
- ) }),
9623
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
9624
+ /* @__PURE__ */ jsx(
9625
+ Form$2.Field,
9626
+ {
9627
+ control: form.control,
9628
+ name: "country_code",
9629
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9630
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9631
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9632
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9633
+ ] })
9634
+ }
9635
+ ),
9636
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9637
+ /* @__PURE__ */ jsx(
9638
+ Form$2.Field,
9639
+ {
9640
+ control: form.control,
9641
+ name: "first_name",
9642
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9643
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9644
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9645
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9646
+ ] })
9647
+ }
9648
+ ),
9649
+ /* @__PURE__ */ jsx(
9650
+ Form$2.Field,
9651
+ {
9652
+ control: form.control,
9653
+ name: "last_name",
9654
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9655
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9656
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9657
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9658
+ ] })
9659
+ }
9660
+ )
9661
+ ] }),
9662
+ /* @__PURE__ */ jsx(
9663
+ Form$2.Field,
9664
+ {
9665
+ control: form.control,
9666
+ name: "company",
9667
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9668
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9669
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9670
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9671
+ ] })
9672
+ }
9673
+ ),
9674
+ /* @__PURE__ */ jsx(
9675
+ Form$2.Field,
9676
+ {
9677
+ control: form.control,
9678
+ name: "address_1",
9679
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9680
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9681
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9682
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9683
+ ] })
9684
+ }
9685
+ ),
9686
+ /* @__PURE__ */ jsx(
9687
+ Form$2.Field,
9688
+ {
9689
+ control: form.control,
9690
+ name: "address_2",
9691
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9692
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9693
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9694
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9695
+ ] })
9696
+ }
9697
+ ),
9698
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9699
+ /* @__PURE__ */ jsx(
9700
+ Form$2.Field,
9701
+ {
9702
+ control: form.control,
9703
+ name: "postal_code",
9704
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9705
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9706
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9707
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9708
+ ] })
9709
+ }
9710
+ ),
9711
+ /* @__PURE__ */ jsx(
9712
+ Form$2.Field,
9713
+ {
9714
+ control: form.control,
9715
+ name: "city",
9716
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9717
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9718
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9719
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9720
+ ] })
9721
+ }
9722
+ )
9723
+ ] }),
9724
+ /* @__PURE__ */ jsx(
9725
+ Form$2.Field,
9726
+ {
9727
+ control: form.control,
9728
+ name: "province",
9729
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9730
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9731
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9732
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9733
+ ] })
9734
+ }
9735
+ ),
9736
+ /* @__PURE__ */ jsx(
9737
+ Form$2.Field,
9738
+ {
9739
+ control: form.control,
9740
+ name: "phone",
9741
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9742
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9743
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9744
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9745
+ ] })
9746
+ }
9747
+ )
9748
+ ] }) }),
9646
9749
  /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9647
9750
  /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9648
9751
  /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -9651,6 +9754,25 @@ const EmailForm = ({ order }) => {
9651
9754
  }
9652
9755
  ) });
9653
9756
  };
9757
+ const schema$5 = addressSchema;
9758
+ const CustomItems = () => {
9759
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9760
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9761
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9762
+ ] });
9763
+ };
9764
+ const CustomItemsForm = () => {
9765
+ const form = useForm({
9766
+ resolver: zodResolver(schema$4)
9767
+ });
9768
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9769
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9770
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9771
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9772
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9773
+ ] }) })
9774
+ ] }) });
9775
+ };
9654
9776
  const schema$4 = objectType({
9655
9777
  email: stringType().email()
9656
9778
  });
@@ -10628,6 +10750,74 @@ const customItemSchema = objectType({
10628
10750
  quantity: numberType(),
10629
10751
  unit_price: unionType([numberType(), stringType()])
10630
10752
  });
10753
+ const Email = () => {
10754
+ const { id } = useParams();
10755
+ const { order, isPending, isError, error } = useOrder(id, {
10756
+ fields: "+email"
10757
+ });
10758
+ if (isError) {
10759
+ throw error;
10760
+ }
10761
+ const isReady = !isPending && !!order;
10762
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
10763
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
10764
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
10765
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
10766
+ ] }),
10767
+ isReady && /* @__PURE__ */ jsx(EmailForm, { order })
10768
+ ] });
10769
+ };
10770
+ const EmailForm = ({ order }) => {
10771
+ const form = useForm({
10772
+ defaultValues: {
10773
+ email: order.email ?? ""
10774
+ },
10775
+ resolver: zodResolver(schema$3)
10776
+ });
10777
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10778
+ const { handleSuccess } = useRouteModal();
10779
+ const onSubmit = form.handleSubmit(async (data) => {
10780
+ await mutateAsync(
10781
+ { email: data.email },
10782
+ {
10783
+ onSuccess: () => {
10784
+ handleSuccess();
10785
+ },
10786
+ onError: (error) => {
10787
+ toast.error(error.message);
10788
+ }
10789
+ }
10790
+ );
10791
+ });
10792
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
10793
+ KeyboundForm,
10794
+ {
10795
+ className: "flex flex-1 flex-col overflow-hidden",
10796
+ onSubmit,
10797
+ children: [
10798
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
10799
+ Form$2.Field,
10800
+ {
10801
+ control: form.control,
10802
+ name: "email",
10803
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10804
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
10805
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10806
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10807
+ ] })
10808
+ }
10809
+ ) }),
10810
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
10811
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10812
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10813
+ ] }) })
10814
+ ]
10815
+ }
10816
+ ) });
10817
+ };
10818
+ const schema$3 = objectType({
10819
+ email: stringType().email()
10820
+ });
10631
10821
  const InlineTip = forwardRef(
10632
10822
  ({ variant = "tip", label, className, children, ...props }, ref) => {
10633
10823
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -11255,196 +11445,6 @@ function getPromotionIds(items, shippingMethods) {
11255
11445
  }
11256
11446
  return Array.from(promotionIds);
11257
11447
  }
11258
- const BillingAddress = () => {
11259
- const { id } = useParams();
11260
- const { order, isPending, isError, error } = useOrder(id, {
11261
- fields: "+billing_address"
11262
- });
11263
- if (isError) {
11264
- throw error;
11265
- }
11266
- const isReady = !isPending && !!order;
11267
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11268
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11269
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
11270
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
11271
- ] }),
11272
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
11273
- ] });
11274
- };
11275
- const BillingAddressForm = ({ order }) => {
11276
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11277
- const form = useForm({
11278
- defaultValues: {
11279
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
11280
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
11281
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
11282
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
11283
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
11284
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
11285
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
11286
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
11287
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
11288
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
11289
- },
11290
- resolver: zodResolver(schema$3)
11291
- });
11292
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11293
- const { handleSuccess } = useRouteModal();
11294
- const onSubmit = form.handleSubmit(async (data) => {
11295
- await mutateAsync(
11296
- { billing_address: data },
11297
- {
11298
- onSuccess: () => {
11299
- handleSuccess();
11300
- },
11301
- onError: (error) => {
11302
- toast.error(error.message);
11303
- }
11304
- }
11305
- );
11306
- });
11307
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11308
- KeyboundForm,
11309
- {
11310
- className: "flex flex-1 flex-col overflow-hidden",
11311
- onSubmit,
11312
- children: [
11313
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
11314
- /* @__PURE__ */ jsx(
11315
- Form$2.Field,
11316
- {
11317
- control: form.control,
11318
- name: "country_code",
11319
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11320
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11321
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11322
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11323
- ] })
11324
- }
11325
- ),
11326
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11327
- /* @__PURE__ */ jsx(
11328
- Form$2.Field,
11329
- {
11330
- control: form.control,
11331
- name: "first_name",
11332
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11333
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11334
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11335
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11336
- ] })
11337
- }
11338
- ),
11339
- /* @__PURE__ */ jsx(
11340
- Form$2.Field,
11341
- {
11342
- control: form.control,
11343
- name: "last_name",
11344
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11345
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11346
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11347
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11348
- ] })
11349
- }
11350
- )
11351
- ] }),
11352
- /* @__PURE__ */ jsx(
11353
- Form$2.Field,
11354
- {
11355
- control: form.control,
11356
- name: "company",
11357
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11358
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11359
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11360
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11361
- ] })
11362
- }
11363
- ),
11364
- /* @__PURE__ */ jsx(
11365
- Form$2.Field,
11366
- {
11367
- control: form.control,
11368
- name: "address_1",
11369
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11370
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11371
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11372
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11373
- ] })
11374
- }
11375
- ),
11376
- /* @__PURE__ */ jsx(
11377
- Form$2.Field,
11378
- {
11379
- control: form.control,
11380
- name: "address_2",
11381
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11382
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11383
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11384
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11385
- ] })
11386
- }
11387
- ),
11388
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11389
- /* @__PURE__ */ jsx(
11390
- Form$2.Field,
11391
- {
11392
- control: form.control,
11393
- name: "postal_code",
11394
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11395
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11396
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11397
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11398
- ] })
11399
- }
11400
- ),
11401
- /* @__PURE__ */ jsx(
11402
- Form$2.Field,
11403
- {
11404
- control: form.control,
11405
- name: "city",
11406
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11407
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11408
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11409
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11410
- ] })
11411
- }
11412
- )
11413
- ] }),
11414
- /* @__PURE__ */ jsx(
11415
- Form$2.Field,
11416
- {
11417
- control: form.control,
11418
- name: "province",
11419
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11420
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11421
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11422
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11423
- ] })
11424
- }
11425
- ),
11426
- /* @__PURE__ */ jsx(
11427
- Form$2.Field,
11428
- {
11429
- control: form.control,
11430
- name: "phone",
11431
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11432
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11433
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11434
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11435
- ] })
11436
- }
11437
- )
11438
- ] }) }),
11439
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11440
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11441
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11442
- ] }) })
11443
- ]
11444
- }
11445
- ) });
11446
- };
11447
- const schema$3 = addressSchema;
11448
11448
  const SalesChannel = () => {
11449
11449
  const { id } = useParams();
11450
11450
  const { draft_order, isPending, isError, error } = useDraftOrder(
@@ -13058,17 +13058,21 @@ const routeModule = {
13058
13058
  loader,
13059
13059
  children: [
13060
13060
  {
13061
- Component: CustomItems,
13062
- path: "/draft-orders/:id/custom-items"
13061
+ Component: BillingAddress,
13062
+ path: "/draft-orders/:id/billing-address"
13063
13063
  },
13064
13064
  {
13065
- Component: Email,
13066
- path: "/draft-orders/:id/email"
13065
+ Component: CustomItems,
13066
+ path: "/draft-orders/:id/custom-items"
13067
13067
  },
13068
13068
  {
13069
13069
  Component: Items,
13070
13070
  path: "/draft-orders/:id/items"
13071
13071
  },
13072
+ {
13073
+ Component: Email,
13074
+ path: "/draft-orders/:id/email"
13075
+ },
13072
13076
  {
13073
13077
  Component: Metadata,
13074
13078
  path: "/draft-orders/:id/metadata"
@@ -13077,10 +13081,6 @@ const routeModule = {
13077
13081
  Component: Promotions,
13078
13082
  path: "/draft-orders/:id/promotions"
13079
13083
  },
13080
- {
13081
- Component: BillingAddress,
13082
- path: "/draft-orders/:id/billing-address"
13083
- },
13084
13084
  {
13085
13085
  Component: SalesChannel,
13086
13086
  path: "/draft-orders/:id/sales-channel"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "3.0.0-snapshot-20251215083939",
3
+ "version": "3.0.0-snapshot-20251215162333",
4
4
  "description": "A draft order plugin for Medusa.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "@ariakit/react": "^0.4.15",
43
43
  "@babel/runtime": "^7.26.10",
44
44
  "@hookform/resolvers": "3.4.2",
45
- "@medusajs/js-sdk": "3.0.0-snapshot-20251215083939",
45
+ "@medusajs/js-sdk": "3.0.0-snapshot-20251215162333",
46
46
  "@tanstack/react-query": "5.64.2",
47
47
  "@uiw/react-json-view": "^2.0.0-alpha.17",
48
48
  "date-fns": "^3.6.0",
@@ -53,22 +53,22 @@
53
53
  "react-hook-form": "7.49.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@medusajs/admin-sdk": "3.0.0-snapshot-20251215083939",
57
- "@medusajs/cli": "3.0.0-snapshot-20251215083939",
58
- "@medusajs/framework": "3.0.0-snapshot-20251215083939",
59
- "@medusajs/icons": "3.0.0-snapshot-20251215083939",
60
- "@medusajs/test-utils": "3.0.0-snapshot-20251215083939",
61
- "@medusajs/types": "3.0.0-snapshot-20251215083939",
62
- "@medusajs/ui": "4.0.31-snapshot-20251215083939",
63
- "@medusajs/ui-preset": "3.0.0-snapshot-20251215083939"
56
+ "@medusajs/admin-sdk": "3.0.0-snapshot-20251215162333",
57
+ "@medusajs/cli": "3.0.0-snapshot-20251215162333",
58
+ "@medusajs/framework": "3.0.0-snapshot-20251215162333",
59
+ "@medusajs/icons": "3.0.0-snapshot-20251215162333",
60
+ "@medusajs/test-utils": "3.0.0-snapshot-20251215162333",
61
+ "@medusajs/types": "3.0.0-snapshot-20251215162333",
62
+ "@medusajs/ui": "4.0.31-snapshot-20251215162333",
63
+ "@medusajs/ui-preset": "3.0.0-snapshot-20251215162333"
64
64
  },
65
65
  "peerDependencies": {
66
- "@medusajs/admin-sdk": "3.0.0-snapshot-20251215083939",
67
- "@medusajs/cli": "3.0.0-snapshot-20251215083939",
68
- "@medusajs/framework": "3.0.0-snapshot-20251215083939",
69
- "@medusajs/icons": "3.0.0-snapshot-20251215083939",
70
- "@medusajs/test-utils": "3.0.0-snapshot-20251215083939",
71
- "@medusajs/ui": "4.0.31-snapshot-20251215083939",
66
+ "@medusajs/admin-sdk": "3.0.0-snapshot-20251215162333",
67
+ "@medusajs/cli": "3.0.0-snapshot-20251215162333",
68
+ "@medusajs/framework": "3.0.0-snapshot-20251215162333",
69
+ "@medusajs/icons": "3.0.0-snapshot-20251215162333",
70
+ "@medusajs/test-utils": "3.0.0-snapshot-20251215162333",
71
+ "@medusajs/ui": "4.0.31-snapshot-20251215162333",
72
72
  "react": "^18.3.1",
73
73
  "react-dom": "^18.3.1",
74
74
  "react-router-dom": "6.20.1"