@medusajs/draft-order 2.11.3-preview-20251103032410 → 2.11.3-preview-20251103090143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9572,196 +9572,6 @@ const ID = () => {
9572
9572
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9573
9573
  ] });
9574
9574
  };
9575
- const BillingAddress = () => {
9576
- const { id } = reactRouterDom.useParams();
9577
- const { order, isPending, isError, error } = useOrder(id, {
9578
- fields: "+billing_address"
9579
- });
9580
- if (isError) {
9581
- throw error;
9582
- }
9583
- const isReady = !isPending && !!order;
9584
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9585
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9586
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9587
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9588
- ] }),
9589
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9590
- ] });
9591
- };
9592
- const BillingAddressForm = ({ order }) => {
9593
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9594
- const form = reactHookForm.useForm({
9595
- defaultValues: {
9596
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9597
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9598
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9599
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9600
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9601
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9602
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9603
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9604
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9605
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9606
- },
9607
- resolver: zod.zodResolver(schema$5)
9608
- });
9609
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9610
- const { handleSuccess } = useRouteModal();
9611
- const onSubmit = form.handleSubmit(async (data) => {
9612
- await mutateAsync(
9613
- { billing_address: data },
9614
- {
9615
- onSuccess: () => {
9616
- handleSuccess();
9617
- },
9618
- onError: (error) => {
9619
- ui.toast.error(error.message);
9620
- }
9621
- }
9622
- );
9623
- });
9624
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9625
- KeyboundForm,
9626
- {
9627
- className: "flex flex-1 flex-col overflow-hidden",
9628
- onSubmit,
9629
- children: [
9630
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
9631
- /* @__PURE__ */ jsxRuntime.jsx(
9632
- Form$2.Field,
9633
- {
9634
- control: form.control,
9635
- name: "country_code",
9636
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9637
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9638
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9639
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9640
- ] })
9641
- }
9642
- ),
9643
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9644
- /* @__PURE__ */ jsxRuntime.jsx(
9645
- Form$2.Field,
9646
- {
9647
- control: form.control,
9648
- name: "first_name",
9649
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9650
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9651
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9652
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9653
- ] })
9654
- }
9655
- ),
9656
- /* @__PURE__ */ jsxRuntime.jsx(
9657
- Form$2.Field,
9658
- {
9659
- control: form.control,
9660
- name: "last_name",
9661
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9662
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9663
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9664
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9665
- ] })
9666
- }
9667
- )
9668
- ] }),
9669
- /* @__PURE__ */ jsxRuntime.jsx(
9670
- Form$2.Field,
9671
- {
9672
- control: form.control,
9673
- name: "company",
9674
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9675
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9676
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9677
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9678
- ] })
9679
- }
9680
- ),
9681
- /* @__PURE__ */ jsxRuntime.jsx(
9682
- Form$2.Field,
9683
- {
9684
- control: form.control,
9685
- name: "address_1",
9686
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9687
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9688
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9689
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9690
- ] })
9691
- }
9692
- ),
9693
- /* @__PURE__ */ jsxRuntime.jsx(
9694
- Form$2.Field,
9695
- {
9696
- control: form.control,
9697
- name: "address_2",
9698
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9699
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9700
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9701
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9702
- ] })
9703
- }
9704
- ),
9705
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9706
- /* @__PURE__ */ jsxRuntime.jsx(
9707
- Form$2.Field,
9708
- {
9709
- control: form.control,
9710
- name: "postal_code",
9711
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9712
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9713
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9714
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9715
- ] })
9716
- }
9717
- ),
9718
- /* @__PURE__ */ jsxRuntime.jsx(
9719
- Form$2.Field,
9720
- {
9721
- control: form.control,
9722
- name: "city",
9723
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9724
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9725
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9726
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9727
- ] })
9728
- }
9729
- )
9730
- ] }),
9731
- /* @__PURE__ */ jsxRuntime.jsx(
9732
- Form$2.Field,
9733
- {
9734
- control: form.control,
9735
- name: "province",
9736
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9737
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9738
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9739
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9740
- ] })
9741
- }
9742
- ),
9743
- /* @__PURE__ */ jsxRuntime.jsx(
9744
- Form$2.Field,
9745
- {
9746
- control: form.control,
9747
- name: "phone",
9748
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9749
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9750
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9751
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9752
- ] })
9753
- }
9754
- )
9755
- ] }) }),
9756
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9757
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9758
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9759
- ] }) })
9760
- ]
9761
- }
9762
- ) });
9763
- };
9764
- const schema$5 = addressSchema;
9765
9575
  const CustomItems = () => {
9766
9576
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9767
9577
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9770,7 +9580,7 @@ const CustomItems = () => {
9770
9580
  };
9771
9581
  const CustomItemsForm = () => {
9772
9582
  const form = reactHookForm.useForm({
9773
- resolver: zod.zodResolver(schema$4)
9583
+ resolver: zod.zodResolver(schema$5)
9774
9584
  });
9775
9585
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9776
9586
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9780,7 +9590,7 @@ const CustomItemsForm = () => {
9780
9590
  ] }) })
9781
9591
  ] }) });
9782
9592
  };
9783
- const schema$4 = objectType({
9593
+ const schema$5 = objectType({
9784
9594
  email: stringType().email()
9785
9595
  });
9786
9596
  const Email = () => {
@@ -9805,7 +9615,7 @@ const EmailForm = ({ order }) => {
9805
9615
  defaultValues: {
9806
9616
  email: order.email ?? ""
9807
9617
  },
9808
- resolver: zod.zodResolver(schema$3)
9618
+ resolver: zod.zodResolver(schema$4)
9809
9619
  });
9810
9620
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9811
9621
  const { handleSuccess } = useRouteModal();
@@ -9848,7 +9658,7 @@ const EmailForm = ({ order }) => {
9848
9658
  }
9849
9659
  ) });
9850
9660
  };
9851
- const schema$3 = objectType({
9661
+ const schema$4 = objectType({
9852
9662
  email: stringType().email()
9853
9663
  });
9854
9664
  const NumberInput = React.forwardRef(
@@ -10825,54 +10635,10 @@ const customItemSchema = objectType({
10825
10635
  quantity: numberType(),
10826
10636
  unit_price: unionType([numberType(), stringType()])
10827
10637
  });
10828
- const InlineTip = React.forwardRef(
10829
- ({ variant = "tip", label, className, children, ...props }, ref) => {
10830
- const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
10831
- return /* @__PURE__ */ jsxRuntime.jsxs(
10832
- "div",
10833
- {
10834
- ref,
10835
- className: ui.clx(
10836
- "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
10837
- className
10838
- ),
10839
- ...props,
10840
- children: [
10841
- /* @__PURE__ */ jsxRuntime.jsx(
10842
- "div",
10843
- {
10844
- role: "presentation",
10845
- className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
10846
- "bg-ui-tag-orange-icon": variant === "warning"
10847
- })
10848
- }
10849
- ),
10850
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
10851
- /* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
10852
- labelValue,
10853
- ":"
10854
- ] }),
10855
- " ",
10856
- children
10857
- ] })
10858
- ]
10859
- }
10860
- );
10861
- }
10862
- );
10863
- InlineTip.displayName = "InlineTip";
10864
- const MetadataFieldSchema = objectType({
10865
- key: stringType(),
10866
- disabled: booleanType().optional(),
10867
- value: anyType()
10868
- });
10869
- const MetadataSchema = objectType({
10870
- metadata: arrayType(MetadataFieldSchema)
10871
- });
10872
- const Metadata = () => {
10638
+ const BillingAddress = () => {
10873
10639
  const { id } = reactRouterDom.useParams();
10874
10640
  const { order, isPending, isError, error } = useOrder(id, {
10875
- fields: "metadata"
10641
+ fields: "+billing_address"
10876
10642
  });
10877
10643
  if (isError) {
10878
10644
  throw error;
@@ -10880,19 +10646,253 @@ const Metadata = () => {
10880
10646
  const isReady = !isPending && !!order;
10881
10647
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10882
10648
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10883
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
10884
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
10649
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
10650
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
10885
10651
  ] }),
10886
- !isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
10652
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
10887
10653
  ] });
10888
10654
  };
10889
- const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
10890
- const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
10891
- const MetadataForm = ({ orderId, metadata }) => {
10892
- const { handleSuccess } = useRouteModal();
10893
- const hasUneditableRows = getHasUneditableRows(metadata);
10894
- const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
10895
- const form = reactHookForm.useForm({
10655
+ const BillingAddressForm = ({ order }) => {
10656
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
10657
+ const form = reactHookForm.useForm({
10658
+ defaultValues: {
10659
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
10660
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
10661
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
10662
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
10663
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
10664
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
10665
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
10666
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
10667
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
10668
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
10669
+ },
10670
+ resolver: zod.zodResolver(schema$3)
10671
+ });
10672
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10673
+ const { handleSuccess } = useRouteModal();
10674
+ const onSubmit = form.handleSubmit(async (data) => {
10675
+ await mutateAsync(
10676
+ { billing_address: data },
10677
+ {
10678
+ onSuccess: () => {
10679
+ handleSuccess();
10680
+ },
10681
+ onError: (error) => {
10682
+ ui.toast.error(error.message);
10683
+ }
10684
+ }
10685
+ );
10686
+ });
10687
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10688
+ KeyboundForm,
10689
+ {
10690
+ className: "flex flex-1 flex-col overflow-hidden",
10691
+ onSubmit,
10692
+ children: [
10693
+ /* @__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: [
10694
+ /* @__PURE__ */ jsxRuntime.jsx(
10695
+ Form$2.Field,
10696
+ {
10697
+ control: form.control,
10698
+ name: "country_code",
10699
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
10701
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
10702
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10703
+ ] })
10704
+ }
10705
+ ),
10706
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10707
+ /* @__PURE__ */ jsxRuntime.jsx(
10708
+ Form$2.Field,
10709
+ {
10710
+ control: form.control,
10711
+ name: "first_name",
10712
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First 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
+ /* @__PURE__ */ jsxRuntime.jsx(
10720
+ Form$2.Field,
10721
+ {
10722
+ control: form.control,
10723
+ name: "last_name",
10724
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
10726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10727
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10728
+ ] })
10729
+ }
10730
+ )
10731
+ ] }),
10732
+ /* @__PURE__ */ jsxRuntime.jsx(
10733
+ Form$2.Field,
10734
+ {
10735
+ control: form.control,
10736
+ name: "company",
10737
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
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_1",
10749
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
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.jsx(
10757
+ Form$2.Field,
10758
+ {
10759
+ control: form.control,
10760
+ name: "address_2",
10761
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10762
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
10763
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10764
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10765
+ ] })
10766
+ }
10767
+ ),
10768
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10769
+ /* @__PURE__ */ jsxRuntime.jsx(
10770
+ Form$2.Field,
10771
+ {
10772
+ control: form.control,
10773
+ name: "postal_code",
10774
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10775
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
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
+ /* @__PURE__ */ jsxRuntime.jsx(
10782
+ Form$2.Field,
10783
+ {
10784
+ control: form.control,
10785
+ name: "city",
10786
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10787
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
10788
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10789
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10790
+ ] })
10791
+ }
10792
+ )
10793
+ ] }),
10794
+ /* @__PURE__ */ jsxRuntime.jsx(
10795
+ Form$2.Field,
10796
+ {
10797
+ control: form.control,
10798
+ name: "province",
10799
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10800
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
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
+ /* @__PURE__ */ jsxRuntime.jsx(
10807
+ Form$2.Field,
10808
+ {
10809
+ control: form.control,
10810
+ name: "phone",
10811
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10812
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
10813
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10814
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10815
+ ] })
10816
+ }
10817
+ )
10818
+ ] }) }),
10819
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10820
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10821
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10822
+ ] }) })
10823
+ ]
10824
+ }
10825
+ ) });
10826
+ };
10827
+ const schema$3 = addressSchema;
10828
+ const InlineTip = React.forwardRef(
10829
+ ({ variant = "tip", label, className, children, ...props }, ref) => {
10830
+ const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
10831
+ return /* @__PURE__ */ jsxRuntime.jsxs(
10832
+ "div",
10833
+ {
10834
+ ref,
10835
+ className: ui.clx(
10836
+ "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
10837
+ className
10838
+ ),
10839
+ ...props,
10840
+ children: [
10841
+ /* @__PURE__ */ jsxRuntime.jsx(
10842
+ "div",
10843
+ {
10844
+ role: "presentation",
10845
+ className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
10846
+ "bg-ui-tag-orange-icon": variant === "warning"
10847
+ })
10848
+ }
10849
+ ),
10850
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
10851
+ /* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
10852
+ labelValue,
10853
+ ":"
10854
+ ] }),
10855
+ " ",
10856
+ children
10857
+ ] })
10858
+ ]
10859
+ }
10860
+ );
10861
+ }
10862
+ );
10863
+ InlineTip.displayName = "InlineTip";
10864
+ const MetadataFieldSchema = objectType({
10865
+ key: stringType(),
10866
+ disabled: booleanType().optional(),
10867
+ value: anyType()
10868
+ });
10869
+ const MetadataSchema = objectType({
10870
+ metadata: arrayType(MetadataFieldSchema)
10871
+ });
10872
+ const Metadata = () => {
10873
+ const { id } = reactRouterDom.useParams();
10874
+ const { order, isPending, isError, error } = useOrder(id, {
10875
+ fields: "metadata"
10876
+ });
10877
+ if (isError) {
10878
+ throw error;
10879
+ }
10880
+ const isReady = !isPending && !!order;
10881
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10882
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10883
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
10884
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
10885
+ ] }),
10886
+ !isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
10887
+ ] });
10888
+ };
10889
+ const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
10890
+ const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
10891
+ const MetadataForm = ({ orderId, metadata }) => {
10892
+ const { handleSuccess } = useRouteModal();
10893
+ const hasUneditableRows = getHasUneditableRows(metadata);
10894
+ const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
10895
+ const form = reactHookForm.useForm({
10896
10896
  defaultValues: {
10897
10897
  metadata: getDefaultValues(metadata)
10898
10898
  },
@@ -12365,33 +12365,236 @@ const CustomAmountField = ({
12365
12365
  }
12366
12366
  );
12367
12367
  };
12368
- const TransferOwnership = () => {
12368
+ const ShippingAddress = () => {
12369
12369
  const { id } = reactRouterDom.useParams();
12370
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12371
- fields: "id,customer_id,customer.*"
12370
+ const { order, isPending, isError, error } = useOrder(id, {
12371
+ fields: "+shipping_address"
12372
12372
  });
12373
12373
  if (isError) {
12374
12374
  throw error;
12375
12375
  }
12376
- const isReady = !isPending && !!draft_order;
12376
+ const isReady = !isPending && !!order;
12377
12377
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12378
12378
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12379
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12380
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12379
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12380
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12381
12381
  ] }),
12382
- isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12382
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12383
12383
  ] });
12384
12384
  };
12385
- const TransferOwnershipForm = ({ order }) => {
12386
- var _a, _b;
12385
+ const ShippingAddressForm = ({ order }) => {
12386
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12387
12387
  const form = reactHookForm.useForm({
12388
12388
  defaultValues: {
12389
- customer_id: order.customer_id || ""
12389
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12390
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12391
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12392
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12393
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12394
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12395
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12396
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12397
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12398
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12390
12399
  },
12391
12400
  resolver: zod.zodResolver(schema$1)
12392
12401
  });
12393
12402
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12394
12403
  const { handleSuccess } = useRouteModal();
12404
+ const onSubmit = form.handleSubmit(async (data) => {
12405
+ await mutateAsync(
12406
+ {
12407
+ shipping_address: {
12408
+ first_name: data.first_name,
12409
+ last_name: data.last_name,
12410
+ company: data.company,
12411
+ address_1: data.address_1,
12412
+ address_2: data.address_2,
12413
+ city: data.city,
12414
+ province: data.province,
12415
+ country_code: data.country_code,
12416
+ postal_code: data.postal_code,
12417
+ phone: data.phone
12418
+ }
12419
+ },
12420
+ {
12421
+ onSuccess: () => {
12422
+ handleSuccess();
12423
+ },
12424
+ onError: (error) => {
12425
+ ui.toast.error(error.message);
12426
+ }
12427
+ }
12428
+ );
12429
+ });
12430
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12431
+ KeyboundForm,
12432
+ {
12433
+ className: "flex flex-1 flex-col overflow-hidden",
12434
+ onSubmit,
12435
+ children: [
12436
+ /* @__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: [
12437
+ /* @__PURE__ */ jsxRuntime.jsx(
12438
+ Form$2.Field,
12439
+ {
12440
+ control: form.control,
12441
+ name: "country_code",
12442
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12443
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12444
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12445
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12446
+ ] })
12447
+ }
12448
+ ),
12449
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12450
+ /* @__PURE__ */ jsxRuntime.jsx(
12451
+ Form$2.Field,
12452
+ {
12453
+ control: form.control,
12454
+ name: "first_name",
12455
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12456
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12457
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12458
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12459
+ ] })
12460
+ }
12461
+ ),
12462
+ /* @__PURE__ */ jsxRuntime.jsx(
12463
+ Form$2.Field,
12464
+ {
12465
+ control: form.control,
12466
+ name: "last_name",
12467
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12468
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12469
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12470
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12471
+ ] })
12472
+ }
12473
+ )
12474
+ ] }),
12475
+ /* @__PURE__ */ jsxRuntime.jsx(
12476
+ Form$2.Field,
12477
+ {
12478
+ control: form.control,
12479
+ name: "company",
12480
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12481
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12482
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12483
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12484
+ ] })
12485
+ }
12486
+ ),
12487
+ /* @__PURE__ */ jsxRuntime.jsx(
12488
+ Form$2.Field,
12489
+ {
12490
+ control: form.control,
12491
+ name: "address_1",
12492
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12493
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12494
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12495
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12496
+ ] })
12497
+ }
12498
+ ),
12499
+ /* @__PURE__ */ jsxRuntime.jsx(
12500
+ Form$2.Field,
12501
+ {
12502
+ control: form.control,
12503
+ name: "address_2",
12504
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12505
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12506
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12507
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12508
+ ] })
12509
+ }
12510
+ ),
12511
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12512
+ /* @__PURE__ */ jsxRuntime.jsx(
12513
+ Form$2.Field,
12514
+ {
12515
+ control: form.control,
12516
+ name: "postal_code",
12517
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12518
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12519
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12520
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12521
+ ] })
12522
+ }
12523
+ ),
12524
+ /* @__PURE__ */ jsxRuntime.jsx(
12525
+ Form$2.Field,
12526
+ {
12527
+ control: form.control,
12528
+ name: "city",
12529
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12530
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12531
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12532
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12533
+ ] })
12534
+ }
12535
+ )
12536
+ ] }),
12537
+ /* @__PURE__ */ jsxRuntime.jsx(
12538
+ Form$2.Field,
12539
+ {
12540
+ control: form.control,
12541
+ name: "province",
12542
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12543
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12544
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12545
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12546
+ ] })
12547
+ }
12548
+ ),
12549
+ /* @__PURE__ */ jsxRuntime.jsx(
12550
+ Form$2.Field,
12551
+ {
12552
+ control: form.control,
12553
+ name: "phone",
12554
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12555
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12556
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12557
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12558
+ ] })
12559
+ }
12560
+ )
12561
+ ] }) }),
12562
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12563
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12564
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12565
+ ] }) })
12566
+ ]
12567
+ }
12568
+ ) });
12569
+ };
12570
+ const schema$1 = addressSchema;
12571
+ const TransferOwnership = () => {
12572
+ const { id } = reactRouterDom.useParams();
12573
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12574
+ fields: "id,customer_id,customer.*"
12575
+ });
12576
+ if (isError) {
12577
+ throw error;
12578
+ }
12579
+ const isReady = !isPending && !!draft_order;
12580
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12581
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12582
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12583
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12584
+ ] }),
12585
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12586
+ ] });
12587
+ };
12588
+ const TransferOwnershipForm = ({ order }) => {
12589
+ var _a, _b;
12590
+ const form = reactHookForm.useForm({
12591
+ defaultValues: {
12592
+ customer_id: order.customer_id || ""
12593
+ },
12594
+ resolver: zod.zodResolver(schema)
12595
+ });
12596
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12597
+ const { handleSuccess } = useRouteModal();
12395
12598
  const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12396
12599
  const currentCustomer = order.customer ? {
12397
12600
  label: name ? `${name} (${order.customer.email})` : order.customer.email,
@@ -12838,212 +13041,9 @@ const Illustration = () => {
12838
13041
  }
12839
13042
  );
12840
13043
  };
12841
- const schema$1 = objectType({
13044
+ const schema = objectType({
12842
13045
  customer_id: stringType().min(1)
12843
13046
  });
12844
- const ShippingAddress = () => {
12845
- const { id } = reactRouterDom.useParams();
12846
- const { order, isPending, isError, error } = useOrder(id, {
12847
- fields: "+shipping_address"
12848
- });
12849
- if (isError) {
12850
- throw error;
12851
- }
12852
- const isReady = !isPending && !!order;
12853
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12854
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12855
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12856
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12857
- ] }),
12858
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12859
- ] });
12860
- };
12861
- const ShippingAddressForm = ({ order }) => {
12862
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12863
- const form = reactHookForm.useForm({
12864
- defaultValues: {
12865
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12866
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12867
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12868
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12869
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12870
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12871
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12872
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12873
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12874
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12875
- },
12876
- resolver: zod.zodResolver(schema)
12877
- });
12878
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12879
- const { handleSuccess } = useRouteModal();
12880
- const onSubmit = form.handleSubmit(async (data) => {
12881
- await mutateAsync(
12882
- {
12883
- shipping_address: {
12884
- first_name: data.first_name,
12885
- last_name: data.last_name,
12886
- company: data.company,
12887
- address_1: data.address_1,
12888
- address_2: data.address_2,
12889
- city: data.city,
12890
- province: data.province,
12891
- country_code: data.country_code,
12892
- postal_code: data.postal_code,
12893
- phone: data.phone
12894
- }
12895
- },
12896
- {
12897
- onSuccess: () => {
12898
- handleSuccess();
12899
- },
12900
- onError: (error) => {
12901
- ui.toast.error(error.message);
12902
- }
12903
- }
12904
- );
12905
- });
12906
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12907
- KeyboundForm,
12908
- {
12909
- className: "flex flex-1 flex-col overflow-hidden",
12910
- onSubmit,
12911
- children: [
12912
- /* @__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: [
12913
- /* @__PURE__ */ jsxRuntime.jsx(
12914
- Form$2.Field,
12915
- {
12916
- control: form.control,
12917
- name: "country_code",
12918
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12919
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12920
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12921
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12922
- ] })
12923
- }
12924
- ),
12925
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12926
- /* @__PURE__ */ jsxRuntime.jsx(
12927
- Form$2.Field,
12928
- {
12929
- control: form.control,
12930
- name: "first_name",
12931
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12932
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First 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
- /* @__PURE__ */ jsxRuntime.jsx(
12939
- Form$2.Field,
12940
- {
12941
- control: form.control,
12942
- name: "last_name",
12943
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12944
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12945
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12946
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12947
- ] })
12948
- }
12949
- )
12950
- ] }),
12951
- /* @__PURE__ */ jsxRuntime.jsx(
12952
- Form$2.Field,
12953
- {
12954
- control: form.control,
12955
- name: "company",
12956
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12957
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
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_1",
12968
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12969
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
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.jsx(
12976
- Form$2.Field,
12977
- {
12978
- control: form.control,
12979
- name: "address_2",
12980
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12981
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12982
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12983
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12984
- ] })
12985
- }
12986
- ),
12987
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12988
- /* @__PURE__ */ jsxRuntime.jsx(
12989
- Form$2.Field,
12990
- {
12991
- control: form.control,
12992
- name: "postal_code",
12993
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12994
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
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
- /* @__PURE__ */ jsxRuntime.jsx(
13001
- Form$2.Field,
13002
- {
13003
- control: form.control,
13004
- name: "city",
13005
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13006
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
13007
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13008
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13009
- ] })
13010
- }
13011
- )
13012
- ] }),
13013
- /* @__PURE__ */ jsxRuntime.jsx(
13014
- Form$2.Field,
13015
- {
13016
- control: form.control,
13017
- name: "province",
13018
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13019
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
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
- /* @__PURE__ */ jsxRuntime.jsx(
13026
- Form$2.Field,
13027
- {
13028
- control: form.control,
13029
- name: "phone",
13030
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13031
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13032
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13033
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13034
- ] })
13035
- }
13036
- )
13037
- ] }) }),
13038
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13039
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13040
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13041
- ] }) })
13042
- ]
13043
- }
13044
- ) });
13045
- };
13046
- const schema = addressSchema;
13047
13047
  const widgetModule = { widgets: [] };
13048
13048
  const routeModule = {
13049
13049
  routes: [
@@ -13064,10 +13064,6 @@ const routeModule = {
13064
13064
  handle,
13065
13065
  loader,
13066
13066
  children: [
13067
- {
13068
- Component: BillingAddress,
13069
- path: "/draft-orders/:id/billing-address"
13070
- },
13071
13067
  {
13072
13068
  Component: CustomItems,
13073
13069
  path: "/draft-orders/:id/custom-items"
@@ -13080,6 +13076,10 @@ const routeModule = {
13080
13076
  Component: Items,
13081
13077
  path: "/draft-orders/:id/items"
13082
13078
  },
13079
+ {
13080
+ Component: BillingAddress,
13081
+ path: "/draft-orders/:id/billing-address"
13082
+ },
13083
13083
  {
13084
13084
  Component: Metadata,
13085
13085
  path: "/draft-orders/:id/metadata"
@@ -13096,13 +13096,13 @@ const routeModule = {
13096
13096
  Component: Shipping,
13097
13097
  path: "/draft-orders/:id/shipping"
13098
13098
  },
13099
- {
13100
- Component: TransferOwnership,
13101
- path: "/draft-orders/:id/transfer-ownership"
13102
- },
13103
13099
  {
13104
13100
  Component: ShippingAddress,
13105
13101
  path: "/draft-orders/:id/shipping-address"
13102
+ },
13103
+ {
13104
+ Component: TransferOwnership,
13105
+ path: "/draft-orders/:id/transfer-ownership"
13106
13106
  }
13107
13107
  ]
13108
13108
  }