@medusajs/draft-order 2.10.0-preview-20250828060153 → 2.10.0-preview-20250828120155

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,264 +9560,6 @@ const ID = () => {
9560
9560
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9561
9561
  ] });
9562
9562
  };
9563
- const BillingAddress = () => {
9564
- const { id } = reactRouterDom.useParams();
9565
- const { order, isPending, isError, error } = useOrder(id, {
9566
- fields: "+billing_address"
9567
- });
9568
- if (isError) {
9569
- throw error;
9570
- }
9571
- const isReady = !isPending && !!order;
9572
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9573
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9574
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9575
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9576
- ] }),
9577
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9578
- ] });
9579
- };
9580
- const BillingAddressForm = ({ order }) => {
9581
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9582
- const form = reactHookForm.useForm({
9583
- defaultValues: {
9584
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9585
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9586
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9587
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9588
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9589
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9590
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9591
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9592
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9593
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9594
- },
9595
- resolver: zod.zodResolver(schema$5)
9596
- });
9597
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9598
- const { handleSuccess } = useRouteModal();
9599
- const onSubmit = form.handleSubmit(async (data) => {
9600
- await mutateAsync(
9601
- { billing_address: data },
9602
- {
9603
- onSuccess: () => {
9604
- handleSuccess();
9605
- },
9606
- onError: (error) => {
9607
- ui.toast.error(error.message);
9608
- }
9609
- }
9610
- );
9611
- });
9612
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9613
- KeyboundForm,
9614
- {
9615
- className: "flex flex-1 flex-col overflow-hidden",
9616
- onSubmit,
9617
- children: [
9618
- /* @__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: [
9619
- /* @__PURE__ */ jsxRuntime.jsx(
9620
- Form$2.Field,
9621
- {
9622
- control: form.control,
9623
- name: "country_code",
9624
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9625
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9626
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9627
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9628
- ] })
9629
- }
9630
- ),
9631
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9632
- /* @__PURE__ */ jsxRuntime.jsx(
9633
- Form$2.Field,
9634
- {
9635
- control: form.control,
9636
- name: "first_name",
9637
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9638
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9639
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9640
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9641
- ] })
9642
- }
9643
- ),
9644
- /* @__PURE__ */ jsxRuntime.jsx(
9645
- Form$2.Field,
9646
- {
9647
- control: form.control,
9648
- name: "last_name",
9649
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9650
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last 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
- ] }),
9657
- /* @__PURE__ */ jsxRuntime.jsx(
9658
- Form$2.Field,
9659
- {
9660
- control: form.control,
9661
- name: "company",
9662
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9663
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
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
- /* @__PURE__ */ jsxRuntime.jsx(
9670
- Form$2.Field,
9671
- {
9672
- control: form.control,
9673
- name: "address_1",
9674
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9675
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
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_2",
9686
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9687
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
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.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9694
- /* @__PURE__ */ jsxRuntime.jsx(
9695
- Form$2.Field,
9696
- {
9697
- control: form.control,
9698
- name: "postal_code",
9699
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9700
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
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.jsx(
9707
- Form$2.Field,
9708
- {
9709
- control: form.control,
9710
- name: "city",
9711
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9712
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
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
- ] }),
9719
- /* @__PURE__ */ jsxRuntime.jsx(
9720
- Form$2.Field,
9721
- {
9722
- control: form.control,
9723
- name: "province",
9724
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9725
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
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
- /* @__PURE__ */ jsxRuntime.jsx(
9732
- Form$2.Field,
9733
- {
9734
- control: form.control,
9735
- name: "phone",
9736
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9737
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
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
- ] }) }),
9744
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9745
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9746
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9747
- ] }) })
9748
- ]
9749
- }
9750
- ) });
9751
- };
9752
- const schema$5 = addressSchema;
9753
- const Email = () => {
9754
- const { id } = reactRouterDom.useParams();
9755
- const { order, isPending, isError, error } = useOrder(id, {
9756
- fields: "+email"
9757
- });
9758
- if (isError) {
9759
- throw error;
9760
- }
9761
- const isReady = !isPending && !!order;
9762
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9763
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9764
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9765
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9766
- ] }),
9767
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9768
- ] });
9769
- };
9770
- const EmailForm = ({ order }) => {
9771
- const form = reactHookForm.useForm({
9772
- defaultValues: {
9773
- email: order.email ?? ""
9774
- },
9775
- resolver: zod.zodResolver(schema$4)
9776
- });
9777
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9778
- const { handleSuccess } = useRouteModal();
9779
- const onSubmit = form.handleSubmit(async (data) => {
9780
- await mutateAsync(
9781
- { email: data.email },
9782
- {
9783
- onSuccess: () => {
9784
- handleSuccess();
9785
- },
9786
- onError: (error) => {
9787
- ui.toast.error(error.message);
9788
- }
9789
- }
9790
- );
9791
- });
9792
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9793
- KeyboundForm,
9794
- {
9795
- className: "flex flex-1 flex-col overflow-hidden",
9796
- onSubmit,
9797
- children: [
9798
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9799
- Form$2.Field,
9800
- {
9801
- control: form.control,
9802
- name: "email",
9803
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9804
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9805
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9806
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9807
- ] })
9808
- }
9809
- ) }),
9810
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9811
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9812
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9813
- ] }) })
9814
- ]
9815
- }
9816
- ) });
9817
- };
9818
- const schema$4 = objectType({
9819
- email: stringType().email()
9820
- });
9821
9563
  const CustomItems = () => {
9822
9564
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9823
9565
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9826,7 +9568,7 @@ const CustomItems = () => {
9826
9568
  };
9827
9569
  const CustomItemsForm = () => {
9828
9570
  const form = reactHookForm.useForm({
9829
- resolver: zod.zodResolver(schema$3)
9571
+ resolver: zod.zodResolver(schema$5)
9830
9572
  });
9831
9573
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9832
9574
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9836,7 +9578,7 @@ const CustomItemsForm = () => {
9836
9578
  ] }) })
9837
9579
  ] }) });
9838
9580
  };
9839
- const schema$3 = objectType({
9581
+ const schema$5 = objectType({
9840
9582
  email: stringType().email()
9841
9583
  });
9842
9584
  const NumberInput = React.forwardRef(
@@ -10808,11 +10550,269 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
10808
10550
  ] }) })
10809
10551
  ] }) }) });
10810
10552
  };
10811
- const customItemSchema = objectType({
10812
- title: stringType().min(1),
10813
- quantity: numberType(),
10814
- unit_price: unionType([numberType(), stringType()])
10815
- });
10553
+ const customItemSchema = objectType({
10554
+ title: stringType().min(1),
10555
+ quantity: numberType(),
10556
+ unit_price: unionType([numberType(), stringType()])
10557
+ });
10558
+ const Email = () => {
10559
+ const { id } = reactRouterDom.useParams();
10560
+ const { order, isPending, isError, error } = useOrder(id, {
10561
+ fields: "+email"
10562
+ });
10563
+ if (isError) {
10564
+ throw error;
10565
+ }
10566
+ const isReady = !isPending && !!order;
10567
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10568
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10569
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
10570
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
10571
+ ] }),
10572
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
10573
+ ] });
10574
+ };
10575
+ const EmailForm = ({ order }) => {
10576
+ const form = reactHookForm.useForm({
10577
+ defaultValues: {
10578
+ email: order.email ?? ""
10579
+ },
10580
+ resolver: zod.zodResolver(schema$4)
10581
+ });
10582
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10583
+ const { handleSuccess } = useRouteModal();
10584
+ const onSubmit = form.handleSubmit(async (data) => {
10585
+ await mutateAsync(
10586
+ { email: data.email },
10587
+ {
10588
+ onSuccess: () => {
10589
+ handleSuccess();
10590
+ },
10591
+ onError: (error) => {
10592
+ ui.toast.error(error.message);
10593
+ }
10594
+ }
10595
+ );
10596
+ });
10597
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10598
+ KeyboundForm,
10599
+ {
10600
+ className: "flex flex-1 flex-col overflow-hidden",
10601
+ onSubmit,
10602
+ children: [
10603
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
10604
+ Form$2.Field,
10605
+ {
10606
+ control: form.control,
10607
+ name: "email",
10608
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10609
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
10610
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10611
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10612
+ ] })
10613
+ }
10614
+ ) }),
10615
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10616
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10617
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10618
+ ] }) })
10619
+ ]
10620
+ }
10621
+ ) });
10622
+ };
10623
+ const schema$4 = objectType({
10624
+ email: stringType().email()
10625
+ });
10626
+ const BillingAddress = () => {
10627
+ const { id } = reactRouterDom.useParams();
10628
+ const { order, isPending, isError, error } = useOrder(id, {
10629
+ fields: "+billing_address"
10630
+ });
10631
+ if (isError) {
10632
+ throw error;
10633
+ }
10634
+ const isReady = !isPending && !!order;
10635
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10636
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10637
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
10638
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
10639
+ ] }),
10640
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
10641
+ ] });
10642
+ };
10643
+ const BillingAddressForm = ({ order }) => {
10644
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
10645
+ const form = reactHookForm.useForm({
10646
+ defaultValues: {
10647
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
10648
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
10649
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
10650
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
10651
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
10652
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
10653
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
10654
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
10655
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
10656
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
10657
+ },
10658
+ resolver: zod.zodResolver(schema$3)
10659
+ });
10660
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10661
+ const { handleSuccess } = useRouteModal();
10662
+ const onSubmit = form.handleSubmit(async (data) => {
10663
+ await mutateAsync(
10664
+ { billing_address: data },
10665
+ {
10666
+ onSuccess: () => {
10667
+ handleSuccess();
10668
+ },
10669
+ onError: (error) => {
10670
+ ui.toast.error(error.message);
10671
+ }
10672
+ }
10673
+ );
10674
+ });
10675
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10676
+ KeyboundForm,
10677
+ {
10678
+ className: "flex flex-1 flex-col overflow-hidden",
10679
+ onSubmit,
10680
+ children: [
10681
+ /* @__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: [
10682
+ /* @__PURE__ */ jsxRuntime.jsx(
10683
+ Form$2.Field,
10684
+ {
10685
+ control: form.control,
10686
+ name: "country_code",
10687
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10688
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
10689
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
10690
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10691
+ ] })
10692
+ }
10693
+ ),
10694
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10695
+ /* @__PURE__ */ jsxRuntime.jsx(
10696
+ Form$2.Field,
10697
+ {
10698
+ control: form.control,
10699
+ name: "first_name",
10700
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10701
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
10702
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10703
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10704
+ ] })
10705
+ }
10706
+ ),
10707
+ /* @__PURE__ */ jsxRuntime.jsx(
10708
+ Form$2.Field,
10709
+ {
10710
+ control: form.control,
10711
+ name: "last_name",
10712
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
10714
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10715
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10716
+ ] })
10717
+ }
10718
+ )
10719
+ ] }),
10720
+ /* @__PURE__ */ jsxRuntime.jsx(
10721
+ Form$2.Field,
10722
+ {
10723
+ control: form.control,
10724
+ name: "company",
10725
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
10727
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10728
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10729
+ ] })
10730
+ }
10731
+ ),
10732
+ /* @__PURE__ */ jsxRuntime.jsx(
10733
+ Form$2.Field,
10734
+ {
10735
+ control: form.control,
10736
+ name: "address_1",
10737
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
10739
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10740
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10741
+ ] })
10742
+ }
10743
+ ),
10744
+ /* @__PURE__ */ jsxRuntime.jsx(
10745
+ Form$2.Field,
10746
+ {
10747
+ control: form.control,
10748
+ name: "address_2",
10749
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
10751
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10752
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10753
+ ] })
10754
+ }
10755
+ ),
10756
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10757
+ /* @__PURE__ */ jsxRuntime.jsx(
10758
+ Form$2.Field,
10759
+ {
10760
+ control: form.control,
10761
+ name: "postal_code",
10762
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10763
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
10764
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10765
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10766
+ ] })
10767
+ }
10768
+ ),
10769
+ /* @__PURE__ */ jsxRuntime.jsx(
10770
+ Form$2.Field,
10771
+ {
10772
+ control: form.control,
10773
+ name: "city",
10774
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10775
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
10776
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10777
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10778
+ ] })
10779
+ }
10780
+ )
10781
+ ] }),
10782
+ /* @__PURE__ */ jsxRuntime.jsx(
10783
+ Form$2.Field,
10784
+ {
10785
+ control: form.control,
10786
+ name: "province",
10787
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10788
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
10789
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10790
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10791
+ ] })
10792
+ }
10793
+ ),
10794
+ /* @__PURE__ */ jsxRuntime.jsx(
10795
+ Form$2.Field,
10796
+ {
10797
+ control: form.control,
10798
+ name: "phone",
10799
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10800
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
10801
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10802
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10803
+ ] })
10804
+ }
10805
+ )
10806
+ ] }) }),
10807
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10808
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10809
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10810
+ ] }) })
10811
+ ]
10812
+ }
10813
+ ) });
10814
+ };
10815
+ const schema$3 = addressSchema;
10816
10816
  const InlineTip = React.forwardRef(
10817
10817
  ({ variant = "tip", label, className, children, ...props }, ref) => {
10818
10818
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -11523,232 +11523,29 @@ const SalesChannelField = ({ control, order }) => {
11523
11523
  control,
11524
11524
  name: "sales_channel_id",
11525
11525
  render: ({ field }) => {
11526
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11527
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11528
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11529
- Combobox,
11530
- {
11531
- options: salesChannels.options,
11532
- fetchNextPage: salesChannels.fetchNextPage,
11533
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11534
- searchValue: salesChannels.searchValue,
11535
- onSearchValueChange: salesChannels.onSearchValueChange,
11536
- placeholder: "Select sales channel",
11537
- ...field
11538
- }
11539
- ) }),
11540
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11541
- ] });
11542
- }
11543
- }
11544
- );
11545
- };
11546
- const schema$2 = objectType({
11547
- sales_channel_id: stringType().min(1)
11548
- });
11549
- const ShippingAddress = () => {
11550
- const { id } = reactRouterDom.useParams();
11551
- const { order, isPending, isError, error } = useOrder(id, {
11552
- fields: "+shipping_address"
11553
- });
11554
- if (isError) {
11555
- throw error;
11556
- }
11557
- const isReady = !isPending && !!order;
11558
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11559
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11560
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
11561
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11562
- ] }),
11563
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
11564
- ] });
11565
- };
11566
- const ShippingAddressForm = ({ order }) => {
11567
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11568
- const form = reactHookForm.useForm({
11569
- defaultValues: {
11570
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11571
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11572
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11573
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11574
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11575
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11576
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11577
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11578
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11579
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11580
- },
11581
- resolver: zod.zodResolver(schema$1)
11582
- });
11583
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11584
- const { handleSuccess } = useRouteModal();
11585
- const onSubmit = form.handleSubmit(async (data) => {
11586
- await mutateAsync(
11587
- {
11588
- shipping_address: {
11589
- first_name: data.first_name,
11590
- last_name: data.last_name,
11591
- company: data.company,
11592
- address_1: data.address_1,
11593
- address_2: data.address_2,
11594
- city: data.city,
11595
- province: data.province,
11596
- country_code: data.country_code,
11597
- postal_code: data.postal_code,
11598
- phone: data.phone
11599
- }
11600
- },
11601
- {
11602
- onSuccess: () => {
11603
- handleSuccess();
11604
- },
11605
- onError: (error) => {
11606
- ui.toast.error(error.message);
11607
- }
11608
- }
11609
- );
11610
- });
11611
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11612
- KeyboundForm,
11613
- {
11614
- className: "flex flex-1 flex-col overflow-hidden",
11615
- onSubmit,
11616
- children: [
11617
- /* @__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: [
11618
- /* @__PURE__ */ jsxRuntime.jsx(
11619
- Form$2.Field,
11620
- {
11621
- control: form.control,
11622
- name: "country_code",
11623
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11624
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11625
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11626
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11627
- ] })
11628
- }
11629
- ),
11630
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11631
- /* @__PURE__ */ jsxRuntime.jsx(
11632
- Form$2.Field,
11633
- {
11634
- control: form.control,
11635
- name: "first_name",
11636
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11637
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11638
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11639
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11640
- ] })
11641
- }
11642
- ),
11643
- /* @__PURE__ */ jsxRuntime.jsx(
11644
- Form$2.Field,
11645
- {
11646
- control: form.control,
11647
- name: "last_name",
11648
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11649
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11650
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11651
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11652
- ] })
11653
- }
11654
- )
11655
- ] }),
11656
- /* @__PURE__ */ jsxRuntime.jsx(
11657
- Form$2.Field,
11658
- {
11659
- control: form.control,
11660
- name: "company",
11661
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11662
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11663
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11664
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11665
- ] })
11666
- }
11667
- ),
11668
- /* @__PURE__ */ jsxRuntime.jsx(
11669
- Form$2.Field,
11670
- {
11671
- control: form.control,
11672
- name: "address_1",
11673
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11674
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11675
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11676
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11677
- ] })
11678
- }
11679
- ),
11680
- /* @__PURE__ */ jsxRuntime.jsx(
11681
- Form$2.Field,
11682
- {
11683
- control: form.control,
11684
- name: "address_2",
11685
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11686
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11687
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11688
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11689
- ] })
11690
- }
11691
- ),
11692
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11693
- /* @__PURE__ */ jsxRuntime.jsx(
11694
- Form$2.Field,
11695
- {
11696
- control: form.control,
11697
- name: "postal_code",
11698
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11699
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11700
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11701
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11702
- ] })
11703
- }
11704
- ),
11705
- /* @__PURE__ */ jsxRuntime.jsx(
11706
- Form$2.Field,
11707
- {
11708
- control: form.control,
11709
- name: "city",
11710
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11711
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11712
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11713
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11714
- ] })
11715
- }
11716
- )
11717
- ] }),
11718
- /* @__PURE__ */ jsxRuntime.jsx(
11719
- Form$2.Field,
11720
- {
11721
- control: form.control,
11722
- name: "province",
11723
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11724
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11725
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11726
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11727
- ] })
11728
- }
11729
- ),
11730
- /* @__PURE__ */ jsxRuntime.jsx(
11731
- Form$2.Field,
11732
- {
11733
- control: form.control,
11734
- name: "phone",
11735
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11736
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11737
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11738
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11739
- ] })
11526
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11527
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11528
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11529
+ Combobox,
11530
+ {
11531
+ options: salesChannels.options,
11532
+ fetchNextPage: salesChannels.fetchNextPage,
11533
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11534
+ searchValue: salesChannels.searchValue,
11535
+ onSearchValueChange: salesChannels.onSearchValueChange,
11536
+ placeholder: "Select sales channel",
11537
+ ...field
11740
11538
  }
11741
- )
11742
- ] }) }),
11743
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11744
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11745
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11746
- ] }) })
11747
- ]
11539
+ ) }),
11540
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11541
+ ] });
11542
+ }
11748
11543
  }
11749
- ) });
11544
+ );
11750
11545
  };
11751
- const schema$1 = addressSchema;
11546
+ const schema$2 = objectType({
11547
+ sales_channel_id: stringType().min(1)
11548
+ });
11752
11549
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11753
11550
  const Shipping = () => {
11754
11551
  var _a;
@@ -12579,7 +12376,7 @@ const TransferOwnershipForm = ({ order }) => {
12579
12376
  defaultValues: {
12580
12377
  customer_id: order.customer_id || ""
12581
12378
  },
12582
- resolver: zod.zodResolver(schema)
12379
+ resolver: zod.zodResolver(schema$1)
12583
12380
  });
12584
12381
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12585
12382
  const { handleSuccess } = useRouteModal();
@@ -13029,9 +12826,212 @@ const Illustration = () => {
13029
12826
  }
13030
12827
  );
13031
12828
  };
13032
- const schema = objectType({
12829
+ const schema$1 = objectType({
13033
12830
  customer_id: stringType().min(1)
13034
12831
  });
12832
+ const ShippingAddress = () => {
12833
+ const { id } = reactRouterDom.useParams();
12834
+ const { order, isPending, isError, error } = useOrder(id, {
12835
+ fields: "+shipping_address"
12836
+ });
12837
+ if (isError) {
12838
+ throw error;
12839
+ }
12840
+ const isReady = !isPending && !!order;
12841
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12842
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12843
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12844
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12845
+ ] }),
12846
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12847
+ ] });
12848
+ };
12849
+ const ShippingAddressForm = ({ order }) => {
12850
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12851
+ const form = reactHookForm.useForm({
12852
+ defaultValues: {
12853
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12854
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12855
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12856
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12857
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12858
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12859
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12860
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12861
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12862
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12863
+ },
12864
+ resolver: zod.zodResolver(schema)
12865
+ });
12866
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12867
+ const { handleSuccess } = useRouteModal();
12868
+ const onSubmit = form.handleSubmit(async (data) => {
12869
+ await mutateAsync(
12870
+ {
12871
+ shipping_address: {
12872
+ first_name: data.first_name,
12873
+ last_name: data.last_name,
12874
+ company: data.company,
12875
+ address_1: data.address_1,
12876
+ address_2: data.address_2,
12877
+ city: data.city,
12878
+ province: data.province,
12879
+ country_code: data.country_code,
12880
+ postal_code: data.postal_code,
12881
+ phone: data.phone
12882
+ }
12883
+ },
12884
+ {
12885
+ onSuccess: () => {
12886
+ handleSuccess();
12887
+ },
12888
+ onError: (error) => {
12889
+ ui.toast.error(error.message);
12890
+ }
12891
+ }
12892
+ );
12893
+ });
12894
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12895
+ KeyboundForm,
12896
+ {
12897
+ className: "flex flex-1 flex-col overflow-hidden",
12898
+ onSubmit,
12899
+ children: [
12900
+ /* @__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: [
12901
+ /* @__PURE__ */ jsxRuntime.jsx(
12902
+ Form$2.Field,
12903
+ {
12904
+ control: form.control,
12905
+ name: "country_code",
12906
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12907
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12908
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12909
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12910
+ ] })
12911
+ }
12912
+ ),
12913
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12914
+ /* @__PURE__ */ jsxRuntime.jsx(
12915
+ Form$2.Field,
12916
+ {
12917
+ control: form.control,
12918
+ name: "first_name",
12919
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12920
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12921
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12922
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12923
+ ] })
12924
+ }
12925
+ ),
12926
+ /* @__PURE__ */ jsxRuntime.jsx(
12927
+ Form$2.Field,
12928
+ {
12929
+ control: form.control,
12930
+ name: "last_name",
12931
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12932
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12933
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12934
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12935
+ ] })
12936
+ }
12937
+ )
12938
+ ] }),
12939
+ /* @__PURE__ */ jsxRuntime.jsx(
12940
+ Form$2.Field,
12941
+ {
12942
+ control: form.control,
12943
+ name: "company",
12944
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12945
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12946
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12947
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12948
+ ] })
12949
+ }
12950
+ ),
12951
+ /* @__PURE__ */ jsxRuntime.jsx(
12952
+ Form$2.Field,
12953
+ {
12954
+ control: form.control,
12955
+ name: "address_1",
12956
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12957
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12958
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12959
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12960
+ ] })
12961
+ }
12962
+ ),
12963
+ /* @__PURE__ */ jsxRuntime.jsx(
12964
+ Form$2.Field,
12965
+ {
12966
+ control: form.control,
12967
+ name: "address_2",
12968
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12969
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12970
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12971
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12972
+ ] })
12973
+ }
12974
+ ),
12975
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12976
+ /* @__PURE__ */ jsxRuntime.jsx(
12977
+ Form$2.Field,
12978
+ {
12979
+ control: form.control,
12980
+ name: "postal_code",
12981
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12982
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12983
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12984
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12985
+ ] })
12986
+ }
12987
+ ),
12988
+ /* @__PURE__ */ jsxRuntime.jsx(
12989
+ Form$2.Field,
12990
+ {
12991
+ control: form.control,
12992
+ name: "city",
12993
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12994
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12995
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12996
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12997
+ ] })
12998
+ }
12999
+ )
13000
+ ] }),
13001
+ /* @__PURE__ */ jsxRuntime.jsx(
13002
+ Form$2.Field,
13003
+ {
13004
+ control: form.control,
13005
+ name: "province",
13006
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13007
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13008
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13009
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13010
+ ] })
13011
+ }
13012
+ ),
13013
+ /* @__PURE__ */ jsxRuntime.jsx(
13014
+ Form$2.Field,
13015
+ {
13016
+ control: form.control,
13017
+ name: "phone",
13018
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13019
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13020
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13021
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13022
+ ] })
13023
+ }
13024
+ )
13025
+ ] }) }),
13026
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13027
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13028
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13029
+ ] }) })
13030
+ ]
13031
+ }
13032
+ ) });
13033
+ };
13034
+ const schema = addressSchema;
13035
13035
  const widgetModule = { widgets: [] };
13036
13036
  const routeModule = {
13037
13037
  routes: [
@@ -13052,14 +13052,6 @@ const routeModule = {
13052
13052
  handle,
13053
13053
  loader,
13054
13054
  children: [
13055
- {
13056
- Component: BillingAddress,
13057
- path: "/draft-orders/:id/billing-address"
13058
- },
13059
- {
13060
- Component: Email,
13061
- path: "/draft-orders/:id/email"
13062
- },
13063
13055
  {
13064
13056
  Component: CustomItems,
13065
13057
  path: "/draft-orders/:id/custom-items"
@@ -13068,6 +13060,14 @@ const routeModule = {
13068
13060
  Component: Items,
13069
13061
  path: "/draft-orders/:id/items"
13070
13062
  },
13063
+ {
13064
+ Component: Email,
13065
+ path: "/draft-orders/:id/email"
13066
+ },
13067
+ {
13068
+ Component: BillingAddress,
13069
+ path: "/draft-orders/:id/billing-address"
13070
+ },
13071
13071
  {
13072
13072
  Component: Metadata,
13073
13073
  path: "/draft-orders/:id/metadata"
@@ -13080,10 +13080,6 @@ const routeModule = {
13080
13080
  Component: SalesChannel,
13081
13081
  path: "/draft-orders/:id/sales-channel"
13082
13082
  },
13083
- {
13084
- Component: ShippingAddress,
13085
- path: "/draft-orders/:id/shipping-address"
13086
- },
13087
13083
  {
13088
13084
  Component: Shipping,
13089
13085
  path: "/draft-orders/:id/shipping"
@@ -13091,6 +13087,10 @@ const routeModule = {
13091
13087
  {
13092
13088
  Component: TransferOwnership,
13093
13089
  path: "/draft-orders/:id/transfer-ownership"
13090
+ },
13091
+ {
13092
+ Component: ShippingAddress,
13093
+ path: "/draft-orders/:id/shipping-address"
13094
13094
  }
13095
13095
  ]
13096
13096
  }