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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9560,6 +9560,196 @@ 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;
9563
9753
  const CustomItems = () => {
9564
9754
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9565
9755
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9568,7 +9758,7 @@ const CustomItems = () => {
9568
9758
  };
9569
9759
  const CustomItemsForm = () => {
9570
9760
  const form = reactHookForm.useForm({
9571
- resolver: zod.zodResolver(schema$5)
9761
+ resolver: zod.zodResolver(schema$4)
9572
9762
  });
9573
9763
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9574
9764
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9578,7 +9768,7 @@ const CustomItemsForm = () => {
9578
9768
  ] }) })
9579
9769
  ] }) });
9580
9770
  };
9581
- const schema$5 = objectType({
9771
+ const schema$4 = objectType({
9582
9772
  email: stringType().email()
9583
9773
  });
9584
9774
  const NumberInput = React.forwardRef(
@@ -10555,10 +10745,54 @@ const customItemSchema = objectType({
10555
10745
  quantity: numberType(),
10556
10746
  unit_price: unionType([numberType(), stringType()])
10557
10747
  });
10558
- const Email = () => {
10748
+ const InlineTip = React.forwardRef(
10749
+ ({ variant = "tip", label, className, children, ...props }, ref) => {
10750
+ const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
10751
+ return /* @__PURE__ */ jsxRuntime.jsxs(
10752
+ "div",
10753
+ {
10754
+ ref,
10755
+ className: ui.clx(
10756
+ "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
10757
+ className
10758
+ ),
10759
+ ...props,
10760
+ children: [
10761
+ /* @__PURE__ */ jsxRuntime.jsx(
10762
+ "div",
10763
+ {
10764
+ role: "presentation",
10765
+ className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
10766
+ "bg-ui-tag-orange-icon": variant === "warning"
10767
+ })
10768
+ }
10769
+ ),
10770
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
10771
+ /* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
10772
+ labelValue,
10773
+ ":"
10774
+ ] }),
10775
+ " ",
10776
+ children
10777
+ ] })
10778
+ ]
10779
+ }
10780
+ );
10781
+ }
10782
+ );
10783
+ InlineTip.displayName = "InlineTip";
10784
+ const MetadataFieldSchema = objectType({
10785
+ key: stringType(),
10786
+ disabled: booleanType().optional(),
10787
+ value: anyType()
10788
+ });
10789
+ const MetadataSchema = objectType({
10790
+ metadata: arrayType(MetadataFieldSchema)
10791
+ });
10792
+ const Metadata = () => {
10559
10793
  const { id } = reactRouterDom.useParams();
10560
10794
  const { order, isPending, isError, error } = useOrder(id, {
10561
- fields: "+email"
10795
+ fields: "metadata"
10562
10796
  });
10563
10797
  if (isError) {
10564
10798
  throw error;
@@ -10566,323 +10800,21 @@ const Email = () => {
10566
10800
  const isReady = !isPending && !!order;
10567
10801
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10568
10802
  /* @__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" }) })
10803
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
10804
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
10571
10805
  ] }),
10572
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
10806
+ !isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
10573
10807
  ] });
10574
10808
  };
10575
- const EmailForm = ({ order }) => {
10809
+ const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
10810
+ const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
10811
+ const MetadataForm = ({ orderId, metadata }) => {
10812
+ const { handleSuccess } = useRouteModal();
10813
+ const hasUneditableRows = getHasUneditableRows(metadata);
10814
+ const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
10576
10815
  const form = reactHookForm.useForm({
10577
10816
  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
- const InlineTip = React.forwardRef(
10817
- ({ variant = "tip", label, className, children, ...props }, ref) => {
10818
- const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
10819
- return /* @__PURE__ */ jsxRuntime.jsxs(
10820
- "div",
10821
- {
10822
- ref,
10823
- className: ui.clx(
10824
- "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
10825
- className
10826
- ),
10827
- ...props,
10828
- children: [
10829
- /* @__PURE__ */ jsxRuntime.jsx(
10830
- "div",
10831
- {
10832
- role: "presentation",
10833
- className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
10834
- "bg-ui-tag-orange-icon": variant === "warning"
10835
- })
10836
- }
10837
- ),
10838
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
10839
- /* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
10840
- labelValue,
10841
- ":"
10842
- ] }),
10843
- " ",
10844
- children
10845
- ] })
10846
- ]
10847
- }
10848
- );
10849
- }
10850
- );
10851
- InlineTip.displayName = "InlineTip";
10852
- const MetadataFieldSchema = objectType({
10853
- key: stringType(),
10854
- disabled: booleanType().optional(),
10855
- value: anyType()
10856
- });
10857
- const MetadataSchema = objectType({
10858
- metadata: arrayType(MetadataFieldSchema)
10859
- });
10860
- const Metadata = () => {
10861
- const { id } = reactRouterDom.useParams();
10862
- const { order, isPending, isError, error } = useOrder(id, {
10863
- fields: "metadata"
10864
- });
10865
- if (isError) {
10866
- throw error;
10867
- }
10868
- const isReady = !isPending && !!order;
10869
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10870
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10871
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
10872
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
10873
- ] }),
10874
- !isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
10875
- ] });
10876
- };
10877
- const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
10878
- const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
10879
- const MetadataForm = ({ orderId, metadata }) => {
10880
- const { handleSuccess } = useRouteModal();
10881
- const hasUneditableRows = getHasUneditableRows(metadata);
10882
- const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
10883
- const form = reactHookForm.useForm({
10884
- defaultValues: {
10885
- metadata: getDefaultValues(metadata)
10817
+ metadata: getDefaultValues(metadata)
10886
10818
  },
10887
10819
  resolver: zod.zodResolver(MetadataSchema)
10888
10820
  });
@@ -11468,7 +11400,7 @@ const SalesChannelForm = ({ order }) => {
11468
11400
  defaultValues: {
11469
11401
  sales_channel_id: order.sales_channel_id || ""
11470
11402
  },
11471
- resolver: zod.zodResolver(schema$2)
11403
+ resolver: zod.zodResolver(schema$3)
11472
11404
  });
11473
11405
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11474
11406
  const { handleSuccess } = useRouteModal();
@@ -11543,7 +11475,7 @@ const SalesChannelField = ({ control, order }) => {
11543
11475
  }
11544
11476
  );
11545
11477
  };
11546
- const schema$2 = objectType({
11478
+ const schema$3 = objectType({
11547
11479
  sales_channel_id: stringType().min(1)
11548
11480
  });
11549
11481
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12339,20 +12271,223 @@ const CustomAmountField = ({
12339
12271
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12340
12272
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12341
12273
  ] }),
12342
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12343
- ui.CurrencyInput,
12274
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12275
+ ui.CurrencyInput,
12276
+ {
12277
+ ...field,
12278
+ onValueChange: (value) => onChange(value),
12279
+ symbol: getNativeSymbol(currencyCode),
12280
+ code: currencyCode
12281
+ }
12282
+ ) })
12283
+ ] });
12284
+ }
12285
+ }
12286
+ );
12287
+ };
12288
+ const ShippingAddress = () => {
12289
+ const { id } = reactRouterDom.useParams();
12290
+ const { order, isPending, isError, error } = useOrder(id, {
12291
+ fields: "+shipping_address"
12292
+ });
12293
+ if (isError) {
12294
+ throw error;
12295
+ }
12296
+ const isReady = !isPending && !!order;
12297
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12298
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12299
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12300
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12301
+ ] }),
12302
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12303
+ ] });
12304
+ };
12305
+ const ShippingAddressForm = ({ order }) => {
12306
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12307
+ const form = reactHookForm.useForm({
12308
+ defaultValues: {
12309
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12310
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12311
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12312
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12313
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12314
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12315
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12316
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12317
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12318
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12319
+ },
12320
+ resolver: zod.zodResolver(schema$2)
12321
+ });
12322
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12323
+ const { handleSuccess } = useRouteModal();
12324
+ const onSubmit = form.handleSubmit(async (data) => {
12325
+ await mutateAsync(
12326
+ {
12327
+ shipping_address: {
12328
+ first_name: data.first_name,
12329
+ last_name: data.last_name,
12330
+ company: data.company,
12331
+ address_1: data.address_1,
12332
+ address_2: data.address_2,
12333
+ city: data.city,
12334
+ province: data.province,
12335
+ country_code: data.country_code,
12336
+ postal_code: data.postal_code,
12337
+ phone: data.phone
12338
+ }
12339
+ },
12340
+ {
12341
+ onSuccess: () => {
12342
+ handleSuccess();
12343
+ },
12344
+ onError: (error) => {
12345
+ ui.toast.error(error.message);
12346
+ }
12347
+ }
12348
+ );
12349
+ });
12350
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12351
+ KeyboundForm,
12352
+ {
12353
+ className: "flex flex-1 flex-col overflow-hidden",
12354
+ onSubmit,
12355
+ children: [
12356
+ /* @__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: [
12357
+ /* @__PURE__ */ jsxRuntime.jsx(
12358
+ Form$2.Field,
12359
+ {
12360
+ control: form.control,
12361
+ name: "country_code",
12362
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12363
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12364
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12365
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12366
+ ] })
12367
+ }
12368
+ ),
12369
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12370
+ /* @__PURE__ */ jsxRuntime.jsx(
12371
+ Form$2.Field,
12372
+ {
12373
+ control: form.control,
12374
+ name: "first_name",
12375
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12376
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12377
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12378
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12379
+ ] })
12380
+ }
12381
+ ),
12382
+ /* @__PURE__ */ jsxRuntime.jsx(
12383
+ Form$2.Field,
12384
+ {
12385
+ control: form.control,
12386
+ name: "last_name",
12387
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12388
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12389
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12390
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12391
+ ] })
12392
+ }
12393
+ )
12394
+ ] }),
12395
+ /* @__PURE__ */ jsxRuntime.jsx(
12396
+ Form$2.Field,
12397
+ {
12398
+ control: form.control,
12399
+ name: "company",
12400
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12401
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12402
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12403
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12404
+ ] })
12405
+ }
12406
+ ),
12407
+ /* @__PURE__ */ jsxRuntime.jsx(
12408
+ Form$2.Field,
12409
+ {
12410
+ control: form.control,
12411
+ name: "address_1",
12412
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12413
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12414
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12415
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12416
+ ] })
12417
+ }
12418
+ ),
12419
+ /* @__PURE__ */ jsxRuntime.jsx(
12420
+ Form$2.Field,
12421
+ {
12422
+ control: form.control,
12423
+ name: "address_2",
12424
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12425
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12426
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12427
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12428
+ ] })
12429
+ }
12430
+ ),
12431
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12432
+ /* @__PURE__ */ jsxRuntime.jsx(
12433
+ Form$2.Field,
12434
+ {
12435
+ control: form.control,
12436
+ name: "postal_code",
12437
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12438
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12439
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12440
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12441
+ ] })
12442
+ }
12443
+ ),
12444
+ /* @__PURE__ */ jsxRuntime.jsx(
12445
+ Form$2.Field,
12446
+ {
12447
+ control: form.control,
12448
+ name: "city",
12449
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12450
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12451
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12452
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12453
+ ] })
12454
+ }
12455
+ )
12456
+ ] }),
12457
+ /* @__PURE__ */ jsxRuntime.jsx(
12458
+ Form$2.Field,
12344
12459
  {
12345
- ...field,
12346
- onValueChange: (value) => onChange(value),
12347
- symbol: getNativeSymbol(currencyCode),
12348
- code: currencyCode
12460
+ control: form.control,
12461
+ name: "province",
12462
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12463
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12464
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12465
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12466
+ ] })
12349
12467
  }
12350
- ) })
12351
- ] });
12352
- }
12468
+ ),
12469
+ /* @__PURE__ */ jsxRuntime.jsx(
12470
+ Form$2.Field,
12471
+ {
12472
+ control: form.control,
12473
+ name: "phone",
12474
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12475
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12476
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12477
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12478
+ ] })
12479
+ }
12480
+ )
12481
+ ] }) }),
12482
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12483
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12484
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12485
+ ] }) })
12486
+ ]
12353
12487
  }
12354
- );
12488
+ ) });
12355
12489
  };
12490
+ const schema$2 = addressSchema;
12356
12491
  const TransferOwnership = () => {
12357
12492
  const { id } = reactRouterDom.useParams();
12358
12493
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12829,10 +12964,10 @@ const Illustration = () => {
12829
12964
  const schema$1 = objectType({
12830
12965
  customer_id: stringType().min(1)
12831
12966
  });
12832
- const ShippingAddress = () => {
12967
+ const Email = () => {
12833
12968
  const { id } = reactRouterDom.useParams();
12834
12969
  const { order, isPending, isError, error } = useOrder(id, {
12835
- fields: "+shipping_address"
12970
+ fields: "+email"
12836
12971
  });
12837
12972
  if (isError) {
12838
12973
  throw error;
@@ -12840,26 +12975,16 @@ const ShippingAddress = () => {
12840
12975
  const isReady = !isPending && !!order;
12841
12976
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12842
12977
  /* @__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" }) })
12978
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
12979
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
12845
12980
  ] }),
12846
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12981
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
12847
12982
  ] });
12848
12983
  };
12849
- const ShippingAddressForm = ({ order }) => {
12850
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12984
+ const EmailForm = ({ order }) => {
12851
12985
  const form = reactHookForm.useForm({
12852
12986
  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) ?? ""
12987
+ email: order.email ?? ""
12863
12988
  },
12864
12989
  resolver: zod.zodResolver(schema)
12865
12990
  });
@@ -12867,20 +12992,7 @@ const ShippingAddressForm = ({ order }) => {
12867
12992
  const { handleSuccess } = useRouteModal();
12868
12993
  const onSubmit = form.handleSubmit(async (data) => {
12869
12994
  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
- },
12995
+ { email: data.email },
12884
12996
  {
12885
12997
  onSuccess: () => {
12886
12998
  handleSuccess();
@@ -12897,132 +13009,18 @@ const ShippingAddressForm = ({ order }) => {
12897
13009
  className: "flex flex-1 flex-col overflow-hidden",
12898
13010
  onSubmit,
12899
13011
  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
- ] }) }),
13012
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
13013
+ Form$2.Field,
13014
+ {
13015
+ control: form.control,
13016
+ name: "email",
13017
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13018
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
13019
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13020
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13021
+ ] })
13022
+ }
13023
+ ) }),
13026
13024
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13027
13025
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13028
13026
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -13031,7 +13029,9 @@ const ShippingAddressForm = ({ order }) => {
13031
13029
  }
13032
13030
  ) });
13033
13031
  };
13034
- const schema = addressSchema;
13032
+ const schema = objectType({
13033
+ email: stringType().email()
13034
+ });
13035
13035
  const widgetModule = { widgets: [] };
13036
13036
  const routeModule = {
13037
13037
  routes: [
@@ -13052,6 +13052,10 @@ const routeModule = {
13052
13052
  handle,
13053
13053
  loader,
13054
13054
  children: [
13055
+ {
13056
+ Component: BillingAddress,
13057
+ path: "/draft-orders/:id/billing-address"
13058
+ },
13055
13059
  {
13056
13060
  Component: CustomItems,
13057
13061
  path: "/draft-orders/:id/custom-items"
@@ -13060,14 +13064,6 @@ const routeModule = {
13060
13064
  Component: Items,
13061
13065
  path: "/draft-orders/:id/items"
13062
13066
  },
13063
- {
13064
- Component: Email,
13065
- path: "/draft-orders/:id/email"
13066
- },
13067
- {
13068
- Component: BillingAddress,
13069
- path: "/draft-orders/:id/billing-address"
13070
- },
13071
13067
  {
13072
13068
  Component: Metadata,
13073
13069
  path: "/draft-orders/:id/metadata"
@@ -13084,13 +13080,17 @@ const routeModule = {
13084
13080
  Component: Shipping,
13085
13081
  path: "/draft-orders/:id/shipping"
13086
13082
  },
13083
+ {
13084
+ Component: ShippingAddress,
13085
+ path: "/draft-orders/:id/shipping-address"
13086
+ },
13087
13087
  {
13088
13088
  Component: TransferOwnership,
13089
13089
  path: "/draft-orders/:id/transfer-ownership"
13090
13090
  },
13091
13091
  {
13092
- Component: ShippingAddress,
13093
- path: "/draft-orders/:id/shipping-address"
13092
+ Component: Email,
13093
+ path: "/draft-orders/:id/email"
13094
13094
  }
13095
13095
  ]
13096
13096
  }