@medusajs/draft-order 2.10.4-snapshot-20250922090257 → 2.10.4-snapshot-20250922165717

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.
@@ -9573,6 +9573,27 @@ const ID = () => {
9573
9573
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9574
9574
  ] });
9575
9575
  };
9576
+ const CustomItems = () => {
9577
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9578
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9579
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9580
+ ] });
9581
+ };
9582
+ const CustomItemsForm = () => {
9583
+ const form = reactHookForm.useForm({
9584
+ resolver: zod.zodResolver(schema$5)
9585
+ });
9586
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9588
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9589
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9590
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9591
+ ] }) })
9592
+ ] }) });
9593
+ };
9594
+ const schema$5 = objectType({
9595
+ email: stringType().email()
9596
+ });
9576
9597
  const Email = () => {
9577
9598
  const { id } = reactRouterDom.useParams();
9578
9599
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9595,7 +9616,7 @@ const EmailForm = ({ order }) => {
9595
9616
  defaultValues: {
9596
9617
  email: order.email ?? ""
9597
9618
  },
9598
- resolver: zod.zodResolver(schema$5)
9619
+ resolver: zod.zodResolver(schema$4)
9599
9620
  });
9600
9621
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9601
9622
  const { handleSuccess } = useRouteModal();
@@ -9638,9 +9659,199 @@ const EmailForm = ({ order }) => {
9638
9659
  }
9639
9660
  ) });
9640
9661
  };
9641
- const schema$5 = objectType({
9662
+ const schema$4 = objectType({
9642
9663
  email: stringType().email()
9643
9664
  });
9665
+ const BillingAddress = () => {
9666
+ const { id } = reactRouterDom.useParams();
9667
+ const { order, isPending, isError, error } = useOrder(id, {
9668
+ fields: "+billing_address"
9669
+ });
9670
+ if (isError) {
9671
+ throw error;
9672
+ }
9673
+ const isReady = !isPending && !!order;
9674
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9675
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9676
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9677
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9678
+ ] }),
9679
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9680
+ ] });
9681
+ };
9682
+ const BillingAddressForm = ({ order }) => {
9683
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9684
+ const form = reactHookForm.useForm({
9685
+ defaultValues: {
9686
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9687
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9688
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9689
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9690
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9691
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9692
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9693
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9694
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9695
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9696
+ },
9697
+ resolver: zod.zodResolver(schema$3)
9698
+ });
9699
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9700
+ const { handleSuccess } = useRouteModal();
9701
+ const onSubmit = form.handleSubmit(async (data) => {
9702
+ await mutateAsync(
9703
+ { billing_address: data },
9704
+ {
9705
+ onSuccess: () => {
9706
+ handleSuccess();
9707
+ },
9708
+ onError: (error) => {
9709
+ ui.toast.error(error.message);
9710
+ }
9711
+ }
9712
+ );
9713
+ });
9714
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9715
+ KeyboundForm,
9716
+ {
9717
+ className: "flex flex-1 flex-col overflow-hidden",
9718
+ onSubmit,
9719
+ children: [
9720
+ /* @__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: [
9721
+ /* @__PURE__ */ jsxRuntime.jsx(
9722
+ Form$2.Field,
9723
+ {
9724
+ control: form.control,
9725
+ name: "country_code",
9726
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9727
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9728
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9729
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9730
+ ] })
9731
+ }
9732
+ ),
9733
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9734
+ /* @__PURE__ */ jsxRuntime.jsx(
9735
+ Form$2.Field,
9736
+ {
9737
+ control: form.control,
9738
+ name: "first_name",
9739
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9740
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9741
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9742
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9743
+ ] })
9744
+ }
9745
+ ),
9746
+ /* @__PURE__ */ jsxRuntime.jsx(
9747
+ Form$2.Field,
9748
+ {
9749
+ control: form.control,
9750
+ name: "last_name",
9751
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9752
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9753
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9754
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9755
+ ] })
9756
+ }
9757
+ )
9758
+ ] }),
9759
+ /* @__PURE__ */ jsxRuntime.jsx(
9760
+ Form$2.Field,
9761
+ {
9762
+ control: form.control,
9763
+ name: "company",
9764
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9765
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9766
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9767
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9768
+ ] })
9769
+ }
9770
+ ),
9771
+ /* @__PURE__ */ jsxRuntime.jsx(
9772
+ Form$2.Field,
9773
+ {
9774
+ control: form.control,
9775
+ name: "address_1",
9776
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9777
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9778
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9779
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9780
+ ] })
9781
+ }
9782
+ ),
9783
+ /* @__PURE__ */ jsxRuntime.jsx(
9784
+ Form$2.Field,
9785
+ {
9786
+ control: form.control,
9787
+ name: "address_2",
9788
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9789
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9790
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9791
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9792
+ ] })
9793
+ }
9794
+ ),
9795
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9796
+ /* @__PURE__ */ jsxRuntime.jsx(
9797
+ Form$2.Field,
9798
+ {
9799
+ control: form.control,
9800
+ name: "postal_code",
9801
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9802
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9803
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9804
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9805
+ ] })
9806
+ }
9807
+ ),
9808
+ /* @__PURE__ */ jsxRuntime.jsx(
9809
+ Form$2.Field,
9810
+ {
9811
+ control: form.control,
9812
+ name: "city",
9813
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9814
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9815
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9816
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9817
+ ] })
9818
+ }
9819
+ )
9820
+ ] }),
9821
+ /* @__PURE__ */ jsxRuntime.jsx(
9822
+ Form$2.Field,
9823
+ {
9824
+ control: form.control,
9825
+ name: "province",
9826
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9827
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9828
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9829
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9830
+ ] })
9831
+ }
9832
+ ),
9833
+ /* @__PURE__ */ jsxRuntime.jsx(
9834
+ Form$2.Field,
9835
+ {
9836
+ control: form.control,
9837
+ name: "phone",
9838
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9839
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9840
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9841
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9842
+ ] })
9843
+ }
9844
+ )
9845
+ ] }) }),
9846
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9847
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9848
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9849
+ ] }) })
9850
+ ]
9851
+ }
9852
+ ) });
9853
+ };
9854
+ const schema$3 = addressSchema;
9644
9855
  const NumberInput = React.forwardRef(
9645
9856
  ({
9646
9857
  value,
@@ -11270,7 +11481,7 @@ const SalesChannelForm = ({ order }) => {
11270
11481
  defaultValues: {
11271
11482
  sales_channel_id: order.sales_channel_id || ""
11272
11483
  },
11273
- resolver: zod.zodResolver(schema$4)
11484
+ resolver: zod.zodResolver(schema$2)
11274
11485
  });
11275
11486
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11276
11487
  const { handleSuccess } = useRouteModal();
@@ -11345,50 +11556,253 @@ const SalesChannelField = ({ control, order }) => {
11345
11556
  }
11346
11557
  );
11347
11558
  };
11348
- const schema$4 = objectType({
11559
+ const schema$2 = objectType({
11349
11560
  sales_channel_id: stringType().min(1)
11350
11561
  });
11351
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11352
- const Shipping = () => {
11353
- var _a;
11562
+ const ShippingAddress = () => {
11354
11563
  const { id } = reactRouterDom.useParams();
11355
11564
  const { order, isPending, isError, error } = useOrder(id, {
11356
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11565
+ fields: "+shipping_address"
11357
11566
  });
11358
- const {
11359
- order: preview,
11360
- isPending: isPreviewPending,
11361
- isError: isPreviewError,
11362
- error: previewError
11363
- } = useOrderPreview(id);
11364
- useInitiateOrderEdit({ preview });
11365
- const { onCancel } = useCancelOrderEdit({ preview });
11366
11567
  if (isError) {
11367
11568
  throw error;
11368
11569
  }
11369
- if (isPreviewError) {
11370
- throw previewError;
11371
- }
11372
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11373
- const isReady = preview && !isPreviewPending && order && !isPending;
11374
- return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11375
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11376
- /* @__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: [
11377
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
11378
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
11379
- ] }) }) }),
11380
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11381
- ] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11382
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11383
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11384
- ] }) });
11385
- };
11386
- const ShippingForm = ({ preview, order }) => {
11387
- var _a;
11388
- const { setIsOpen } = useStackedModal();
11389
- const [isSubmitting, setIsSubmitting] = React.useState(false);
11390
- const [data, setData] = React.useState(null);
11391
- const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11570
+ const isReady = !isPending && !!order;
11571
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11572
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11573
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
11574
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11575
+ ] }),
11576
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
11577
+ ] });
11578
+ };
11579
+ const ShippingAddressForm = ({ order }) => {
11580
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11581
+ const form = reactHookForm.useForm({
11582
+ defaultValues: {
11583
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11584
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11585
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11586
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11587
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11588
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11589
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11590
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11591
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11592
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11593
+ },
11594
+ resolver: zod.zodResolver(schema$1)
11595
+ });
11596
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11597
+ const { handleSuccess } = useRouteModal();
11598
+ const onSubmit = form.handleSubmit(async (data) => {
11599
+ await mutateAsync(
11600
+ {
11601
+ shipping_address: {
11602
+ first_name: data.first_name,
11603
+ last_name: data.last_name,
11604
+ company: data.company,
11605
+ address_1: data.address_1,
11606
+ address_2: data.address_2,
11607
+ city: data.city,
11608
+ province: data.province,
11609
+ country_code: data.country_code,
11610
+ postal_code: data.postal_code,
11611
+ phone: data.phone
11612
+ }
11613
+ },
11614
+ {
11615
+ onSuccess: () => {
11616
+ handleSuccess();
11617
+ },
11618
+ onError: (error) => {
11619
+ ui.toast.error(error.message);
11620
+ }
11621
+ }
11622
+ );
11623
+ });
11624
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11625
+ KeyboundForm,
11626
+ {
11627
+ className: "flex flex-1 flex-col overflow-hidden",
11628
+ onSubmit,
11629
+ children: [
11630
+ /* @__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: [
11631
+ /* @__PURE__ */ jsxRuntime.jsx(
11632
+ Form$2.Field,
11633
+ {
11634
+ control: form.control,
11635
+ name: "country_code",
11636
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11637
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11638
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11639
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11640
+ ] })
11641
+ }
11642
+ ),
11643
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11644
+ /* @__PURE__ */ jsxRuntime.jsx(
11645
+ Form$2.Field,
11646
+ {
11647
+ control: form.control,
11648
+ name: "first_name",
11649
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11650
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11651
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11652
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11653
+ ] })
11654
+ }
11655
+ ),
11656
+ /* @__PURE__ */ jsxRuntime.jsx(
11657
+ Form$2.Field,
11658
+ {
11659
+ control: form.control,
11660
+ name: "last_name",
11661
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11662
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11663
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11664
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11665
+ ] })
11666
+ }
11667
+ )
11668
+ ] }),
11669
+ /* @__PURE__ */ jsxRuntime.jsx(
11670
+ Form$2.Field,
11671
+ {
11672
+ control: form.control,
11673
+ name: "company",
11674
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11675
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11676
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11677
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11678
+ ] })
11679
+ }
11680
+ ),
11681
+ /* @__PURE__ */ jsxRuntime.jsx(
11682
+ Form$2.Field,
11683
+ {
11684
+ control: form.control,
11685
+ name: "address_1",
11686
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11687
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11688
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11689
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11690
+ ] })
11691
+ }
11692
+ ),
11693
+ /* @__PURE__ */ jsxRuntime.jsx(
11694
+ Form$2.Field,
11695
+ {
11696
+ control: form.control,
11697
+ name: "address_2",
11698
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11699
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11701
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11702
+ ] })
11703
+ }
11704
+ ),
11705
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11706
+ /* @__PURE__ */ jsxRuntime.jsx(
11707
+ Form$2.Field,
11708
+ {
11709
+ control: form.control,
11710
+ name: "postal_code",
11711
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11712
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11714
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11715
+ ] })
11716
+ }
11717
+ ),
11718
+ /* @__PURE__ */ jsxRuntime.jsx(
11719
+ Form$2.Field,
11720
+ {
11721
+ control: form.control,
11722
+ name: "city",
11723
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11724
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11727
+ ] })
11728
+ }
11729
+ )
11730
+ ] }),
11731
+ /* @__PURE__ */ jsxRuntime.jsx(
11732
+ Form$2.Field,
11733
+ {
11734
+ control: form.control,
11735
+ name: "province",
11736
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11737
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11739
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11740
+ ] })
11741
+ }
11742
+ ),
11743
+ /* @__PURE__ */ jsxRuntime.jsx(
11744
+ Form$2.Field,
11745
+ {
11746
+ control: form.control,
11747
+ name: "phone",
11748
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11749
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11751
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11752
+ ] })
11753
+ }
11754
+ )
11755
+ ] }) }),
11756
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11757
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11758
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11759
+ ] }) })
11760
+ ]
11761
+ }
11762
+ ) });
11763
+ };
11764
+ const schema$1 = addressSchema;
11765
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11766
+ const Shipping = () => {
11767
+ var _a;
11768
+ const { id } = reactRouterDom.useParams();
11769
+ const { order, isPending, isError, error } = useOrder(id, {
11770
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11771
+ });
11772
+ const {
11773
+ order: preview,
11774
+ isPending: isPreviewPending,
11775
+ isError: isPreviewError,
11776
+ error: previewError
11777
+ } = useOrderPreview(id);
11778
+ useInitiateOrderEdit({ preview });
11779
+ const { onCancel } = useCancelOrderEdit({ preview });
11780
+ if (isError) {
11781
+ throw error;
11782
+ }
11783
+ if (isPreviewError) {
11784
+ throw previewError;
11785
+ }
11786
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11787
+ const isReady = preview && !isPreviewPending && order && !isPending;
11788
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11789
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11790
+ /* @__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: [
11791
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
11792
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
11793
+ ] }) }) }),
11794
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11795
+ ] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11796
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11797
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11798
+ ] }) });
11799
+ };
11800
+ const ShippingForm = ({ preview, order }) => {
11801
+ var _a;
11802
+ const { setIsOpen } = useStackedModal();
11803
+ const [isSubmitting, setIsSubmitting] = React.useState(false);
11804
+ const [data, setData] = React.useState(null);
11805
+ const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11392
11806
  const { shipping_options } = useShippingOptions(
11393
11807
  {
11394
11808
  id: appliedShippingOptionIds,
@@ -12155,233 +12569,30 @@ const CustomAmountField = ({
12155
12569
  }
12156
12570
  );
12157
12571
  };
12158
- const ShippingAddress = () => {
12572
+ const TransferOwnership = () => {
12159
12573
  const { id } = reactRouterDom.useParams();
12160
- const { order, isPending, isError, error } = useOrder(id, {
12161
- fields: "+shipping_address"
12574
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12575
+ fields: "id,customer_id,customer.*"
12162
12576
  });
12163
12577
  if (isError) {
12164
12578
  throw error;
12165
12579
  }
12166
- const isReady = !isPending && !!order;
12580
+ const isReady = !isPending && !!draft_order;
12167
12581
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12168
12582
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12169
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12170
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
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" }) })
12171
12585
  ] }),
12172
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12586
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12173
12587
  ] });
12174
12588
  };
12175
- const ShippingAddressForm = ({ order }) => {
12176
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12177
- const form = reactHookForm.useForm({
12178
- defaultValues: {
12179
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12180
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12181
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12182
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12183
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12184
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12185
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12186
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12187
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12188
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12189
- },
12190
- resolver: zod.zodResolver(schema$3)
12191
- });
12192
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12193
- const { handleSuccess } = useRouteModal();
12194
- const onSubmit = form.handleSubmit(async (data) => {
12195
- await mutateAsync(
12196
- {
12197
- shipping_address: {
12198
- first_name: data.first_name,
12199
- last_name: data.last_name,
12200
- company: data.company,
12201
- address_1: data.address_1,
12202
- address_2: data.address_2,
12203
- city: data.city,
12204
- province: data.province,
12205
- country_code: data.country_code,
12206
- postal_code: data.postal_code,
12207
- phone: data.phone
12208
- }
12209
- },
12210
- {
12211
- onSuccess: () => {
12212
- handleSuccess();
12213
- },
12214
- onError: (error) => {
12215
- ui.toast.error(error.message);
12216
- }
12217
- }
12218
- );
12219
- });
12220
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12221
- KeyboundForm,
12222
- {
12223
- className: "flex flex-1 flex-col overflow-hidden",
12224
- onSubmit,
12225
- children: [
12226
- /* @__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: [
12227
- /* @__PURE__ */ jsxRuntime.jsx(
12228
- Form$2.Field,
12229
- {
12230
- control: form.control,
12231
- name: "country_code",
12232
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12233
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12234
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12235
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12236
- ] })
12237
- }
12238
- ),
12239
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12240
- /* @__PURE__ */ jsxRuntime.jsx(
12241
- Form$2.Field,
12242
- {
12243
- control: form.control,
12244
- name: "first_name",
12245
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12246
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12247
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12248
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12249
- ] })
12250
- }
12251
- ),
12252
- /* @__PURE__ */ jsxRuntime.jsx(
12253
- Form$2.Field,
12254
- {
12255
- control: form.control,
12256
- name: "last_name",
12257
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12258
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12259
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12260
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12261
- ] })
12262
- }
12263
- )
12264
- ] }),
12265
- /* @__PURE__ */ jsxRuntime.jsx(
12266
- Form$2.Field,
12267
- {
12268
- control: form.control,
12269
- name: "company",
12270
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12271
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12272
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12273
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12274
- ] })
12275
- }
12276
- ),
12277
- /* @__PURE__ */ jsxRuntime.jsx(
12278
- Form$2.Field,
12279
- {
12280
- control: form.control,
12281
- name: "address_1",
12282
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12283
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12284
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12285
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12286
- ] })
12287
- }
12288
- ),
12289
- /* @__PURE__ */ jsxRuntime.jsx(
12290
- Form$2.Field,
12291
- {
12292
- control: form.control,
12293
- name: "address_2",
12294
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12295
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12296
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12297
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12298
- ] })
12299
- }
12300
- ),
12301
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12302
- /* @__PURE__ */ jsxRuntime.jsx(
12303
- Form$2.Field,
12304
- {
12305
- control: form.control,
12306
- name: "postal_code",
12307
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12308
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12309
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12310
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12311
- ] })
12312
- }
12313
- ),
12314
- /* @__PURE__ */ jsxRuntime.jsx(
12315
- Form$2.Field,
12316
- {
12317
- control: form.control,
12318
- name: "city",
12319
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12320
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12321
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12322
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12323
- ] })
12324
- }
12325
- )
12326
- ] }),
12327
- /* @__PURE__ */ jsxRuntime.jsx(
12328
- Form$2.Field,
12329
- {
12330
- control: form.control,
12331
- name: "province",
12332
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12333
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12334
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12335
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12336
- ] })
12337
- }
12338
- ),
12339
- /* @__PURE__ */ jsxRuntime.jsx(
12340
- Form$2.Field,
12341
- {
12342
- control: form.control,
12343
- name: "phone",
12344
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12345
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12346
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12347
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12348
- ] })
12349
- }
12350
- )
12351
- ] }) }),
12352
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12353
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12354
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12355
- ] }) })
12356
- ]
12357
- }
12358
- ) });
12359
- };
12360
- const schema$3 = addressSchema;
12361
- const TransferOwnership = () => {
12362
- const { id } = reactRouterDom.useParams();
12363
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12364
- fields: "id,customer_id,customer.*"
12365
- });
12366
- if (isError) {
12367
- throw error;
12368
- }
12369
- const isReady = !isPending && !!draft_order;
12370
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12371
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12372
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12373
- /* @__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" }) })
12374
- ] }),
12375
- isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12376
- ] });
12377
- };
12378
- const TransferOwnershipForm = ({ order }) => {
12379
- var _a, _b;
12589
+ const TransferOwnershipForm = ({ order }) => {
12590
+ var _a, _b;
12380
12591
  const form = reactHookForm.useForm({
12381
12592
  defaultValues: {
12382
12593
  customer_id: order.customer_id || ""
12383
12594
  },
12384
- resolver: zod.zodResolver(schema$2)
12595
+ resolver: zod.zodResolver(schema)
12385
12596
  });
12386
12597
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12387
12598
  const { handleSuccess } = useRouteModal();
@@ -12831,219 +13042,8 @@ const Illustration = () => {
12831
13042
  }
12832
13043
  );
12833
13044
  };
12834
- const schema$2 = objectType({
12835
- customer_id: stringType().min(1)
12836
- });
12837
- const BillingAddress = () => {
12838
- const { id } = reactRouterDom.useParams();
12839
- const { order, isPending, isError, error } = useOrder(id, {
12840
- fields: "+billing_address"
12841
- });
12842
- if (isError) {
12843
- throw error;
12844
- }
12845
- const isReady = !isPending && !!order;
12846
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12847
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12848
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12849
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12850
- ] }),
12851
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12852
- ] });
12853
- };
12854
- const BillingAddressForm = ({ order }) => {
12855
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12856
- const form = reactHookForm.useForm({
12857
- defaultValues: {
12858
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12859
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12860
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12861
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12862
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12863
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12864
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12865
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12866
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12867
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12868
- },
12869
- resolver: zod.zodResolver(schema$1)
12870
- });
12871
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12872
- const { handleSuccess } = useRouteModal();
12873
- const onSubmit = form.handleSubmit(async (data) => {
12874
- await mutateAsync(
12875
- { billing_address: data },
12876
- {
12877
- onSuccess: () => {
12878
- handleSuccess();
12879
- },
12880
- onError: (error) => {
12881
- ui.toast.error(error.message);
12882
- }
12883
- }
12884
- );
12885
- });
12886
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12887
- KeyboundForm,
12888
- {
12889
- className: "flex flex-1 flex-col overflow-hidden",
12890
- onSubmit,
12891
- children: [
12892
- /* @__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: [
12893
- /* @__PURE__ */ jsxRuntime.jsx(
12894
- Form$2.Field,
12895
- {
12896
- control: form.control,
12897
- name: "country_code",
12898
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12899
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12900
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12901
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12902
- ] })
12903
- }
12904
- ),
12905
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12906
- /* @__PURE__ */ jsxRuntime.jsx(
12907
- Form$2.Field,
12908
- {
12909
- control: form.control,
12910
- name: "first_name",
12911
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12912
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12913
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12914
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12915
- ] })
12916
- }
12917
- ),
12918
- /* @__PURE__ */ jsxRuntime.jsx(
12919
- Form$2.Field,
12920
- {
12921
- control: form.control,
12922
- name: "last_name",
12923
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12924
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12925
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12926
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12927
- ] })
12928
- }
12929
- )
12930
- ] }),
12931
- /* @__PURE__ */ jsxRuntime.jsx(
12932
- Form$2.Field,
12933
- {
12934
- control: form.control,
12935
- name: "company",
12936
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12937
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12938
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12939
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12940
- ] })
12941
- }
12942
- ),
12943
- /* @__PURE__ */ jsxRuntime.jsx(
12944
- Form$2.Field,
12945
- {
12946
- control: form.control,
12947
- name: "address_1",
12948
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12949
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12950
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12951
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12952
- ] })
12953
- }
12954
- ),
12955
- /* @__PURE__ */ jsxRuntime.jsx(
12956
- Form$2.Field,
12957
- {
12958
- control: form.control,
12959
- name: "address_2",
12960
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12961
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12962
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12963
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12964
- ] })
12965
- }
12966
- ),
12967
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12968
- /* @__PURE__ */ jsxRuntime.jsx(
12969
- Form$2.Field,
12970
- {
12971
- control: form.control,
12972
- name: "postal_code",
12973
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12974
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12975
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12976
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12977
- ] })
12978
- }
12979
- ),
12980
- /* @__PURE__ */ jsxRuntime.jsx(
12981
- Form$2.Field,
12982
- {
12983
- control: form.control,
12984
- name: "city",
12985
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12986
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12987
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12988
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12989
- ] })
12990
- }
12991
- )
12992
- ] }),
12993
- /* @__PURE__ */ jsxRuntime.jsx(
12994
- Form$2.Field,
12995
- {
12996
- control: form.control,
12997
- name: "province",
12998
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12999
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13000
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13001
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13002
- ] })
13003
- }
13004
- ),
13005
- /* @__PURE__ */ jsxRuntime.jsx(
13006
- Form$2.Field,
13007
- {
13008
- control: form.control,
13009
- name: "phone",
13010
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13011
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13012
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13013
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13014
- ] })
13015
- }
13016
- )
13017
- ] }) }),
13018
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13019
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13020
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13021
- ] }) })
13022
- ]
13023
- }
13024
- ) });
13025
- };
13026
- const schema$1 = addressSchema;
13027
- const CustomItems = () => {
13028
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
13029
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
13030
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
13031
- ] });
13032
- };
13033
- const CustomItemsForm = () => {
13034
- const form = reactHookForm.useForm({
13035
- resolver: zod.zodResolver(schema)
13036
- });
13037
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13038
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
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", children: "Save" })
13042
- ] }) })
13043
- ] }) });
13044
- };
13045
13045
  const schema = objectType({
13046
- email: stringType().email()
13046
+ customer_id: stringType().min(1)
13047
13047
  });
13048
13048
  const widgetModule = { widgets: [] };
13049
13049
  const routeModule = {
@@ -13065,10 +13065,18 @@ const routeModule = {
13065
13065
  handle,
13066
13066
  loader,
13067
13067
  children: [
13068
+ {
13069
+ Component: CustomItems,
13070
+ path: "/draft-orders/:id/custom-items"
13071
+ },
13068
13072
  {
13069
13073
  Component: Email,
13070
13074
  path: "/draft-orders/:id/email"
13071
13075
  },
13076
+ {
13077
+ Component: BillingAddress,
13078
+ path: "/draft-orders/:id/billing-address"
13079
+ },
13072
13080
  {
13073
13081
  Component: Items,
13074
13082
  path: "/draft-orders/:id/items"
@@ -13085,25 +13093,17 @@ const routeModule = {
13085
13093
  Component: SalesChannel,
13086
13094
  path: "/draft-orders/:id/sales-channel"
13087
13095
  },
13088
- {
13089
- Component: Shipping,
13090
- path: "/draft-orders/:id/shipping"
13091
- },
13092
13096
  {
13093
13097
  Component: ShippingAddress,
13094
13098
  path: "/draft-orders/:id/shipping-address"
13095
13099
  },
13096
13100
  {
13097
- Component: TransferOwnership,
13098
- path: "/draft-orders/:id/transfer-ownership"
13099
- },
13100
- {
13101
- Component: BillingAddress,
13102
- path: "/draft-orders/:id/billing-address"
13101
+ Component: Shipping,
13102
+ path: "/draft-orders/:id/shipping"
13103
13103
  },
13104
13104
  {
13105
- Component: CustomItems,
13106
- path: "/draft-orders/:id/custom-items"
13105
+ Component: TransferOwnership,
13106
+ path: "/draft-orders/:id/transfer-ownership"
13107
13107
  }
13108
13108
  ]
13109
13109
  }