@medusajs/draft-order 2.10.4-snapshot-20251006181454 → 2.10.4-snapshot-20251007081528

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.
@@ -9594,10 +9594,10 @@ const CustomItemsForm = () => {
9594
9594
  const schema$5 = objectType({
9595
9595
  email: stringType().email()
9596
9596
  });
9597
- const BillingAddress = () => {
9597
+ const Email = () => {
9598
9598
  const { id } = reactRouterDom.useParams();
9599
9599
  const { order, isPending, isError, error } = useOrder(id, {
9600
- fields: "+billing_address"
9600
+ fields: "+email"
9601
9601
  });
9602
9602
  if (isError) {
9603
9603
  throw error;
@@ -9605,26 +9605,16 @@ const BillingAddress = () => {
9605
9605
  const isReady = !isPending && !!order;
9606
9606
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9607
9607
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9608
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9609
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9608
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9609
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9610
9610
  ] }),
9611
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9611
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9612
9612
  ] });
9613
9613
  };
9614
- const BillingAddressForm = ({ order }) => {
9615
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9614
+ const EmailForm = ({ order }) => {
9616
9615
  const form = reactHookForm.useForm({
9617
9616
  defaultValues: {
9618
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9619
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9620
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9621
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9622
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9623
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9624
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9625
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9626
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9627
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9617
+ email: order.email ?? ""
9628
9618
  },
9629
9619
  resolver: zod.zodResolver(schema$4)
9630
9620
  });
@@ -9632,7 +9622,7 @@ const BillingAddressForm = ({ order }) => {
9632
9622
  const { handleSuccess } = useRouteModal();
9633
9623
  const onSubmit = form.handleSubmit(async (data) => {
9634
9624
  await mutateAsync(
9635
- { billing_address: data },
9625
+ { email: data.email },
9636
9626
  {
9637
9627
  onSuccess: () => {
9638
9628
  handleSuccess();
@@ -9649,132 +9639,18 @@ const BillingAddressForm = ({ order }) => {
9649
9639
  className: "flex flex-1 flex-col overflow-hidden",
9650
9640
  onSubmit,
9651
9641
  children: [
9652
- /* @__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: [
9653
- /* @__PURE__ */ jsxRuntime.jsx(
9654
- Form$2.Field,
9655
- {
9656
- control: form.control,
9657
- name: "country_code",
9658
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9659
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9660
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9661
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9662
- ] })
9663
- }
9664
- ),
9665
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9666
- /* @__PURE__ */ jsxRuntime.jsx(
9667
- Form$2.Field,
9668
- {
9669
- control: form.control,
9670
- name: "first_name",
9671
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9672
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9673
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9674
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9675
- ] })
9676
- }
9677
- ),
9678
- /* @__PURE__ */ jsxRuntime.jsx(
9679
- Form$2.Field,
9680
- {
9681
- control: form.control,
9682
- name: "last_name",
9683
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9684
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9685
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9686
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9687
- ] })
9688
- }
9689
- )
9690
- ] }),
9691
- /* @__PURE__ */ jsxRuntime.jsx(
9692
- Form$2.Field,
9693
- {
9694
- control: form.control,
9695
- name: "company",
9696
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9697
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9698
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9699
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9700
- ] })
9701
- }
9702
- ),
9703
- /* @__PURE__ */ jsxRuntime.jsx(
9704
- Form$2.Field,
9705
- {
9706
- control: form.control,
9707
- name: "address_1",
9708
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9709
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9710
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9711
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9712
- ] })
9713
- }
9714
- ),
9715
- /* @__PURE__ */ jsxRuntime.jsx(
9716
- Form$2.Field,
9717
- {
9718
- control: form.control,
9719
- name: "address_2",
9720
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9721
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9722
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9723
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9724
- ] })
9725
- }
9726
- ),
9727
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9728
- /* @__PURE__ */ jsxRuntime.jsx(
9729
- Form$2.Field,
9730
- {
9731
- control: form.control,
9732
- name: "postal_code",
9733
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9734
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9735
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9736
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9737
- ] })
9738
- }
9739
- ),
9740
- /* @__PURE__ */ jsxRuntime.jsx(
9741
- Form$2.Field,
9742
- {
9743
- control: form.control,
9744
- name: "city",
9745
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9746
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9747
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9748
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9749
- ] })
9750
- }
9751
- )
9752
- ] }),
9753
- /* @__PURE__ */ jsxRuntime.jsx(
9754
- Form$2.Field,
9755
- {
9756
- control: form.control,
9757
- name: "province",
9758
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9759
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9760
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9761
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9762
- ] })
9763
- }
9764
- ),
9765
- /* @__PURE__ */ jsxRuntime.jsx(
9766
- Form$2.Field,
9767
- {
9768
- control: form.control,
9769
- name: "phone",
9770
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9771
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9772
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9773
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9774
- ] })
9775
- }
9776
- )
9777
- ] }) }),
9642
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9643
+ Form$2.Field,
9644
+ {
9645
+ control: form.control,
9646
+ name: "email",
9647
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9648
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9649
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9650
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9651
+ ] })
9652
+ }
9653
+ ) }),
9778
9654
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9779
9655
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9780
9656
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -9783,7 +9659,9 @@ const BillingAddressForm = ({ order }) => {
9783
9659
  }
9784
9660
  ) });
9785
9661
  };
9786
- const schema$4 = addressSchema;
9662
+ const schema$4 = objectType({
9663
+ email: stringType().email()
9664
+ });
9787
9665
  const NumberInput = React.forwardRef(
9788
9666
  ({
9789
9667
  value,
@@ -10758,74 +10636,6 @@ const customItemSchema = objectType({
10758
10636
  quantity: numberType(),
10759
10637
  unit_price: unionType([numberType(), stringType()])
10760
10638
  });
10761
- const Email = () => {
10762
- const { id } = reactRouterDom.useParams();
10763
- const { order, isPending, isError, error } = useOrder(id, {
10764
- fields: "+email"
10765
- });
10766
- if (isError) {
10767
- throw error;
10768
- }
10769
- const isReady = !isPending && !!order;
10770
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10771
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10772
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
10773
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
10774
- ] }),
10775
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
10776
- ] });
10777
- };
10778
- const EmailForm = ({ order }) => {
10779
- const form = reactHookForm.useForm({
10780
- defaultValues: {
10781
- email: order.email ?? ""
10782
- },
10783
- resolver: zod.zodResolver(schema$3)
10784
- });
10785
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10786
- const { handleSuccess } = useRouteModal();
10787
- const onSubmit = form.handleSubmit(async (data) => {
10788
- await mutateAsync(
10789
- { email: data.email },
10790
- {
10791
- onSuccess: () => {
10792
- handleSuccess();
10793
- },
10794
- onError: (error) => {
10795
- ui.toast.error(error.message);
10796
- }
10797
- }
10798
- );
10799
- });
10800
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10801
- KeyboundForm,
10802
- {
10803
- className: "flex flex-1 flex-col overflow-hidden",
10804
- onSubmit,
10805
- children: [
10806
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
10807
- Form$2.Field,
10808
- {
10809
- control: form.control,
10810
- name: "email",
10811
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10812
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
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
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10819
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10820
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10821
- ] }) })
10822
- ]
10823
- }
10824
- ) });
10825
- };
10826
- const schema$3 = objectType({
10827
- email: stringType().email()
10828
- });
10829
10639
  const InlineTip = React.forwardRef(
10830
10640
  ({ variant = "tip", label, className, children, ...props }, ref) => {
10831
10641
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -11481,7 +11291,7 @@ const SalesChannelForm = ({ order }) => {
11481
11291
  defaultValues: {
11482
11292
  sales_channel_id: order.sales_channel_id || ""
11483
11293
  },
11484
- resolver: zod.zodResolver(schema$2)
11294
+ resolver: zod.zodResolver(schema$3)
11485
11295
  });
11486
11296
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11487
11297
  const { handleSuccess } = useRouteModal();
@@ -11556,32 +11366,235 @@ const SalesChannelField = ({ control, order }) => {
11556
11366
  }
11557
11367
  );
11558
11368
  };
11559
- const schema$2 = objectType({
11369
+ const schema$3 = objectType({
11560
11370
  sales_channel_id: stringType().min(1)
11561
11371
  });
11562
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11563
- const Shipping = () => {
11564
- var _a;
11372
+ const ShippingAddress = () => {
11565
11373
  const { id } = reactRouterDom.useParams();
11566
11374
  const { order, isPending, isError, error } = useOrder(id, {
11567
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11375
+ fields: "+shipping_address"
11568
11376
  });
11569
- const {
11570
- order: preview,
11571
- isPending: isPreviewPending,
11572
- isError: isPreviewError,
11573
- error: previewError
11574
- } = useOrderPreview(id);
11575
- useInitiateOrderEdit({ preview });
11576
- const { onCancel } = useCancelOrderEdit({ preview });
11577
11377
  if (isError) {
11578
11378
  throw error;
11579
11379
  }
11580
- if (isPreviewError) {
11581
- throw previewError;
11582
- }
11583
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11584
- const isReady = preview && !isPreviewPending && order && !isPending;
11380
+ const isReady = !isPending && !!order;
11381
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11382
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11383
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
11384
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11385
+ ] }),
11386
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
11387
+ ] });
11388
+ };
11389
+ const ShippingAddressForm = ({ order }) => {
11390
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11391
+ const form = reactHookForm.useForm({
11392
+ defaultValues: {
11393
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11394
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11395
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11396
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11397
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11398
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11399
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11400
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11401
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11402
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11403
+ },
11404
+ resolver: zod.zodResolver(schema$2)
11405
+ });
11406
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11407
+ const { handleSuccess } = useRouteModal();
11408
+ const onSubmit = form.handleSubmit(async (data) => {
11409
+ await mutateAsync(
11410
+ {
11411
+ shipping_address: {
11412
+ first_name: data.first_name,
11413
+ last_name: data.last_name,
11414
+ company: data.company,
11415
+ address_1: data.address_1,
11416
+ address_2: data.address_2,
11417
+ city: data.city,
11418
+ province: data.province,
11419
+ country_code: data.country_code,
11420
+ postal_code: data.postal_code,
11421
+ phone: data.phone
11422
+ }
11423
+ },
11424
+ {
11425
+ onSuccess: () => {
11426
+ handleSuccess();
11427
+ },
11428
+ onError: (error) => {
11429
+ ui.toast.error(error.message);
11430
+ }
11431
+ }
11432
+ );
11433
+ });
11434
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11435
+ KeyboundForm,
11436
+ {
11437
+ className: "flex flex-1 flex-col overflow-hidden",
11438
+ onSubmit,
11439
+ children: [
11440
+ /* @__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: [
11441
+ /* @__PURE__ */ jsxRuntime.jsx(
11442
+ Form$2.Field,
11443
+ {
11444
+ control: form.control,
11445
+ name: "country_code",
11446
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11447
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11448
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11449
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11450
+ ] })
11451
+ }
11452
+ ),
11453
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11454
+ /* @__PURE__ */ jsxRuntime.jsx(
11455
+ Form$2.Field,
11456
+ {
11457
+ control: form.control,
11458
+ name: "first_name",
11459
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11460
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11461
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11462
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11463
+ ] })
11464
+ }
11465
+ ),
11466
+ /* @__PURE__ */ jsxRuntime.jsx(
11467
+ Form$2.Field,
11468
+ {
11469
+ control: form.control,
11470
+ name: "last_name",
11471
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11472
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11473
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11474
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11475
+ ] })
11476
+ }
11477
+ )
11478
+ ] }),
11479
+ /* @__PURE__ */ jsxRuntime.jsx(
11480
+ Form$2.Field,
11481
+ {
11482
+ control: form.control,
11483
+ name: "company",
11484
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11485
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11486
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11487
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11488
+ ] })
11489
+ }
11490
+ ),
11491
+ /* @__PURE__ */ jsxRuntime.jsx(
11492
+ Form$2.Field,
11493
+ {
11494
+ control: form.control,
11495
+ name: "address_1",
11496
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11497
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11498
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11499
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11500
+ ] })
11501
+ }
11502
+ ),
11503
+ /* @__PURE__ */ jsxRuntime.jsx(
11504
+ Form$2.Field,
11505
+ {
11506
+ control: form.control,
11507
+ name: "address_2",
11508
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11509
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11510
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11511
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11512
+ ] })
11513
+ }
11514
+ ),
11515
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11516
+ /* @__PURE__ */ jsxRuntime.jsx(
11517
+ Form$2.Field,
11518
+ {
11519
+ control: form.control,
11520
+ name: "postal_code",
11521
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11522
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11523
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11524
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11525
+ ] })
11526
+ }
11527
+ ),
11528
+ /* @__PURE__ */ jsxRuntime.jsx(
11529
+ Form$2.Field,
11530
+ {
11531
+ control: form.control,
11532
+ name: "city",
11533
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11534
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11535
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11536
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11537
+ ] })
11538
+ }
11539
+ )
11540
+ ] }),
11541
+ /* @__PURE__ */ jsxRuntime.jsx(
11542
+ Form$2.Field,
11543
+ {
11544
+ control: form.control,
11545
+ name: "province",
11546
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11547
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11548
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11549
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11550
+ ] })
11551
+ }
11552
+ ),
11553
+ /* @__PURE__ */ jsxRuntime.jsx(
11554
+ Form$2.Field,
11555
+ {
11556
+ control: form.control,
11557
+ name: "phone",
11558
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11559
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11560
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11561
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11562
+ ] })
11563
+ }
11564
+ )
11565
+ ] }) }),
11566
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11567
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11568
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11569
+ ] }) })
11570
+ ]
11571
+ }
11572
+ ) });
11573
+ };
11574
+ const schema$2 = addressSchema;
11575
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11576
+ const Shipping = () => {
11577
+ var _a;
11578
+ const { id } = reactRouterDom.useParams();
11579
+ const { order, isPending, isError, error } = useOrder(id, {
11580
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11581
+ });
11582
+ const {
11583
+ order: preview,
11584
+ isPending: isPreviewPending,
11585
+ isError: isPreviewError,
11586
+ error: previewError
11587
+ } = useOrderPreview(id);
11588
+ useInitiateOrderEdit({ preview });
11589
+ const { onCancel } = useCancelOrderEdit({ preview });
11590
+ if (isError) {
11591
+ throw error;
11592
+ }
11593
+ if (isPreviewError) {
11594
+ throw previewError;
11595
+ }
11596
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11597
+ const isReady = preview && !isPreviewPending && order && !isPending;
11585
11598
  return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11586
11599
  /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11587
11600
  /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
@@ -12366,244 +12379,41 @@ const CustomAmountField = ({
12366
12379
  }
12367
12380
  );
12368
12381
  };
12369
- const ShippingAddress = () => {
12382
+ const TransferOwnership = () => {
12370
12383
  const { id } = reactRouterDom.useParams();
12371
- const { order, isPending, isError, error } = useOrder(id, {
12372
- fields: "+shipping_address"
12384
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12385
+ fields: "id,customer_id,customer.*"
12373
12386
  });
12374
12387
  if (isError) {
12375
12388
  throw error;
12376
12389
  }
12377
- const isReady = !isPending && !!order;
12390
+ const isReady = !isPending && !!draft_order;
12378
12391
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12379
12392
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12380
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12381
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12393
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12394
+ /* @__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" }) })
12382
12395
  ] }),
12383
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12396
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12384
12397
  ] });
12385
12398
  };
12386
- const ShippingAddressForm = ({ order }) => {
12387
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12399
+ const TransferOwnershipForm = ({ order }) => {
12400
+ var _a, _b;
12388
12401
  const form = reactHookForm.useForm({
12389
12402
  defaultValues: {
12390
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12391
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12392
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12393
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12394
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12395
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12396
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12397
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12398
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12399
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12403
+ customer_id: order.customer_id || ""
12400
12404
  },
12401
12405
  resolver: zod.zodResolver(schema$1)
12402
12406
  });
12403
12407
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12404
12408
  const { handleSuccess } = useRouteModal();
12409
+ const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12410
+ const currentCustomer = order.customer ? {
12411
+ label: name ? `${name} (${order.customer.email})` : order.customer.email,
12412
+ value: order.customer.id
12413
+ } : null;
12405
12414
  const onSubmit = form.handleSubmit(async (data) => {
12406
12415
  await mutateAsync(
12407
- {
12408
- shipping_address: {
12409
- first_name: data.first_name,
12410
- last_name: data.last_name,
12411
- company: data.company,
12412
- address_1: data.address_1,
12413
- address_2: data.address_2,
12414
- city: data.city,
12415
- province: data.province,
12416
- country_code: data.country_code,
12417
- postal_code: data.postal_code,
12418
- phone: data.phone
12419
- }
12420
- },
12421
- {
12422
- onSuccess: () => {
12423
- handleSuccess();
12424
- },
12425
- onError: (error) => {
12426
- ui.toast.error(error.message);
12427
- }
12428
- }
12429
- );
12430
- });
12431
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12432
- KeyboundForm,
12433
- {
12434
- className: "flex flex-1 flex-col overflow-hidden",
12435
- onSubmit,
12436
- children: [
12437
- /* @__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: [
12438
- /* @__PURE__ */ jsxRuntime.jsx(
12439
- Form$2.Field,
12440
- {
12441
- control: form.control,
12442
- name: "country_code",
12443
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12444
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12445
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12446
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12447
- ] })
12448
- }
12449
- ),
12450
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12451
- /* @__PURE__ */ jsxRuntime.jsx(
12452
- Form$2.Field,
12453
- {
12454
- control: form.control,
12455
- name: "first_name",
12456
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12457
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12458
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12459
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12460
- ] })
12461
- }
12462
- ),
12463
- /* @__PURE__ */ jsxRuntime.jsx(
12464
- Form$2.Field,
12465
- {
12466
- control: form.control,
12467
- name: "last_name",
12468
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12469
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12470
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12471
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12472
- ] })
12473
- }
12474
- )
12475
- ] }),
12476
- /* @__PURE__ */ jsxRuntime.jsx(
12477
- Form$2.Field,
12478
- {
12479
- control: form.control,
12480
- name: "company",
12481
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12482
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12483
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12484
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12485
- ] })
12486
- }
12487
- ),
12488
- /* @__PURE__ */ jsxRuntime.jsx(
12489
- Form$2.Field,
12490
- {
12491
- control: form.control,
12492
- name: "address_1",
12493
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12494
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12495
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12496
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12497
- ] })
12498
- }
12499
- ),
12500
- /* @__PURE__ */ jsxRuntime.jsx(
12501
- Form$2.Field,
12502
- {
12503
- control: form.control,
12504
- name: "address_2",
12505
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12506
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12507
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12508
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12509
- ] })
12510
- }
12511
- ),
12512
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12513
- /* @__PURE__ */ jsxRuntime.jsx(
12514
- Form$2.Field,
12515
- {
12516
- control: form.control,
12517
- name: "postal_code",
12518
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12519
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12520
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12521
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12522
- ] })
12523
- }
12524
- ),
12525
- /* @__PURE__ */ jsxRuntime.jsx(
12526
- Form$2.Field,
12527
- {
12528
- control: form.control,
12529
- name: "city",
12530
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12531
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12532
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12533
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12534
- ] })
12535
- }
12536
- )
12537
- ] }),
12538
- /* @__PURE__ */ jsxRuntime.jsx(
12539
- Form$2.Field,
12540
- {
12541
- control: form.control,
12542
- name: "province",
12543
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12544
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12545
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12546
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12547
- ] })
12548
- }
12549
- ),
12550
- /* @__PURE__ */ jsxRuntime.jsx(
12551
- Form$2.Field,
12552
- {
12553
- control: form.control,
12554
- name: "phone",
12555
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12556
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12557
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12558
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12559
- ] })
12560
- }
12561
- )
12562
- ] }) }),
12563
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12564
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12565
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12566
- ] }) })
12567
- ]
12568
- }
12569
- ) });
12570
- };
12571
- const schema$1 = addressSchema;
12572
- const TransferOwnership = () => {
12573
- const { id } = reactRouterDom.useParams();
12574
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12575
- fields: "id,customer_id,customer.*"
12576
- });
12577
- if (isError) {
12578
- throw error;
12579
- }
12580
- const isReady = !isPending && !!draft_order;
12581
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12582
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12583
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12584
- /* @__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" }) })
12585
- ] }),
12586
- isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12587
- ] });
12588
- };
12589
- const TransferOwnershipForm = ({ order }) => {
12590
- var _a, _b;
12591
- const form = reactHookForm.useForm({
12592
- defaultValues: {
12593
- customer_id: order.customer_id || ""
12594
- },
12595
- resolver: zod.zodResolver(schema)
12596
- });
12597
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12598
- const { handleSuccess } = useRouteModal();
12599
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12600
- const currentCustomer = order.customer ? {
12601
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
12602
- value: order.customer.id
12603
- } : null;
12604
- const onSubmit = form.handleSubmit(async (data) => {
12605
- await mutateAsync(
12606
- { customer_id: data.customer_id },
12416
+ { customer_id: data.customer_id },
12607
12417
  {
12608
12418
  onSuccess: () => {
12609
12419
  ui.toast.success("Customer updated");
@@ -13042,9 +12852,199 @@ const Illustration = () => {
13042
12852
  }
13043
12853
  );
13044
12854
  };
13045
- const schema = objectType({
12855
+ const schema$1 = objectType({
13046
12856
  customer_id: stringType().min(1)
13047
12857
  });
12858
+ const BillingAddress = () => {
12859
+ const { id } = reactRouterDom.useParams();
12860
+ const { order, isPending, isError, error } = useOrder(id, {
12861
+ fields: "+billing_address"
12862
+ });
12863
+ if (isError) {
12864
+ throw error;
12865
+ }
12866
+ const isReady = !isPending && !!order;
12867
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12868
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12869
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12870
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12871
+ ] }),
12872
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12873
+ ] });
12874
+ };
12875
+ const BillingAddressForm = ({ order }) => {
12876
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12877
+ const form = reactHookForm.useForm({
12878
+ defaultValues: {
12879
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12880
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12881
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12882
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12883
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12884
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12885
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12886
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12887
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12888
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12889
+ },
12890
+ resolver: zod.zodResolver(schema)
12891
+ });
12892
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12893
+ const { handleSuccess } = useRouteModal();
12894
+ const onSubmit = form.handleSubmit(async (data) => {
12895
+ await mutateAsync(
12896
+ { billing_address: data },
12897
+ {
12898
+ onSuccess: () => {
12899
+ handleSuccess();
12900
+ },
12901
+ onError: (error) => {
12902
+ ui.toast.error(error.message);
12903
+ }
12904
+ }
12905
+ );
12906
+ });
12907
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12908
+ KeyboundForm,
12909
+ {
12910
+ className: "flex flex-1 flex-col overflow-hidden",
12911
+ onSubmit,
12912
+ children: [
12913
+ /* @__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: [
12914
+ /* @__PURE__ */ jsxRuntime.jsx(
12915
+ Form$2.Field,
12916
+ {
12917
+ control: form.control,
12918
+ name: "country_code",
12919
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12920
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12921
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12922
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12923
+ ] })
12924
+ }
12925
+ ),
12926
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12927
+ /* @__PURE__ */ jsxRuntime.jsx(
12928
+ Form$2.Field,
12929
+ {
12930
+ control: form.control,
12931
+ name: "first_name",
12932
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12933
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12934
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12935
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12936
+ ] })
12937
+ }
12938
+ ),
12939
+ /* @__PURE__ */ jsxRuntime.jsx(
12940
+ Form$2.Field,
12941
+ {
12942
+ control: form.control,
12943
+ name: "last_name",
12944
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12945
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
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
+ ] }),
12952
+ /* @__PURE__ */ jsxRuntime.jsx(
12953
+ Form$2.Field,
12954
+ {
12955
+ control: form.control,
12956
+ name: "company",
12957
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12958
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12959
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12960
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12961
+ ] })
12962
+ }
12963
+ ),
12964
+ /* @__PURE__ */ jsxRuntime.jsx(
12965
+ Form$2.Field,
12966
+ {
12967
+ control: form.control,
12968
+ name: "address_1",
12969
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12970
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12971
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12972
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12973
+ ] })
12974
+ }
12975
+ ),
12976
+ /* @__PURE__ */ jsxRuntime.jsx(
12977
+ Form$2.Field,
12978
+ {
12979
+ control: form.control,
12980
+ name: "address_2",
12981
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12982
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
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.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12989
+ /* @__PURE__ */ jsxRuntime.jsx(
12990
+ Form$2.Field,
12991
+ {
12992
+ control: form.control,
12993
+ name: "postal_code",
12994
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12995
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12996
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12997
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12998
+ ] })
12999
+ }
13000
+ ),
13001
+ /* @__PURE__ */ jsxRuntime.jsx(
13002
+ Form$2.Field,
13003
+ {
13004
+ control: form.control,
13005
+ name: "city",
13006
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13007
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
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
+ ] }),
13014
+ /* @__PURE__ */ jsxRuntime.jsx(
13015
+ Form$2.Field,
13016
+ {
13017
+ control: form.control,
13018
+ name: "province",
13019
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13020
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13021
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13022
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13023
+ ] })
13024
+ }
13025
+ ),
13026
+ /* @__PURE__ */ jsxRuntime.jsx(
13027
+ Form$2.Field,
13028
+ {
13029
+ control: form.control,
13030
+ name: "phone",
13031
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13032
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13033
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13034
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13035
+ ] })
13036
+ }
13037
+ )
13038
+ ] }) }),
13039
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13040
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13041
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13042
+ ] }) })
13043
+ ]
13044
+ }
13045
+ ) });
13046
+ };
13047
+ const schema = addressSchema;
13048
13048
  const widgetModule = { widgets: [] };
13049
13049
  const routeModule = {
13050
13050
  routes: [
@@ -13070,17 +13070,13 @@ const routeModule = {
13070
13070
  path: "/draft-orders/:id/custom-items"
13071
13071
  },
13072
13072
  {
13073
- Component: BillingAddress,
13074
- path: "/draft-orders/:id/billing-address"
13073
+ Component: Email,
13074
+ path: "/draft-orders/:id/email"
13075
13075
  },
13076
13076
  {
13077
13077
  Component: Items,
13078
13078
  path: "/draft-orders/:id/items"
13079
13079
  },
13080
- {
13081
- Component: Email,
13082
- path: "/draft-orders/:id/email"
13083
- },
13084
13080
  {
13085
13081
  Component: Metadata,
13086
13082
  path: "/draft-orders/:id/metadata"
@@ -13093,17 +13089,21 @@ const routeModule = {
13093
13089
  Component: SalesChannel,
13094
13090
  path: "/draft-orders/:id/sales-channel"
13095
13091
  },
13096
- {
13097
- Component: Shipping,
13098
- path: "/draft-orders/:id/shipping"
13099
- },
13100
13092
  {
13101
13093
  Component: ShippingAddress,
13102
13094
  path: "/draft-orders/:id/shipping-address"
13103
13095
  },
13096
+ {
13097
+ Component: Shipping,
13098
+ path: "/draft-orders/:id/shipping"
13099
+ },
13104
13100
  {
13105
13101
  Component: TransferOwnership,
13106
13102
  path: "/draft-orders/:id/transfer-ownership"
13103
+ },
13104
+ {
13105
+ Component: BillingAddress,
13106
+ path: "/draft-orders/:id/billing-address"
13107
13107
  }
13108
13108
  ]
13109
13109
  }