@medusajs/draft-order 2.11.2-preview-20251028060159 → 2.11.2-preview-20251028090156

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.
@@ -9571,6 +9571,196 @@ const ID = () => {
9571
9571
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9572
9572
  ] });
9573
9573
  };
9574
+ const BillingAddress = () => {
9575
+ const { id } = reactRouterDom.useParams();
9576
+ const { order, isPending, isError, error } = useOrder(id, {
9577
+ fields: "+billing_address"
9578
+ });
9579
+ if (isError) {
9580
+ throw error;
9581
+ }
9582
+ const isReady = !isPending && !!order;
9583
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9584
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9585
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9586
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9587
+ ] }),
9588
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9589
+ ] });
9590
+ };
9591
+ const BillingAddressForm = ({ order }) => {
9592
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9593
+ const form = reactHookForm.useForm({
9594
+ defaultValues: {
9595
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9596
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9597
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9598
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9599
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9600
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9601
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9602
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9603
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9604
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9605
+ },
9606
+ resolver: zod.zodResolver(schema$5)
9607
+ });
9608
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9609
+ const { handleSuccess } = useRouteModal();
9610
+ const onSubmit = form.handleSubmit(async (data) => {
9611
+ await mutateAsync(
9612
+ { billing_address: data },
9613
+ {
9614
+ onSuccess: () => {
9615
+ handleSuccess();
9616
+ },
9617
+ onError: (error) => {
9618
+ ui.toast.error(error.message);
9619
+ }
9620
+ }
9621
+ );
9622
+ });
9623
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9624
+ KeyboundForm,
9625
+ {
9626
+ className: "flex flex-1 flex-col overflow-hidden",
9627
+ onSubmit,
9628
+ children: [
9629
+ /* @__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: [
9630
+ /* @__PURE__ */ jsxRuntime.jsx(
9631
+ Form$2.Field,
9632
+ {
9633
+ control: form.control,
9634
+ name: "country_code",
9635
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9636
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9637
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9638
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9639
+ ] })
9640
+ }
9641
+ ),
9642
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9643
+ /* @__PURE__ */ jsxRuntime.jsx(
9644
+ Form$2.Field,
9645
+ {
9646
+ control: form.control,
9647
+ name: "first_name",
9648
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9649
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9650
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9651
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9652
+ ] })
9653
+ }
9654
+ ),
9655
+ /* @__PURE__ */ jsxRuntime.jsx(
9656
+ Form$2.Field,
9657
+ {
9658
+ control: form.control,
9659
+ name: "last_name",
9660
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9661
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9662
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9663
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9664
+ ] })
9665
+ }
9666
+ )
9667
+ ] }),
9668
+ /* @__PURE__ */ jsxRuntime.jsx(
9669
+ Form$2.Field,
9670
+ {
9671
+ control: form.control,
9672
+ name: "company",
9673
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9674
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9675
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9676
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9677
+ ] })
9678
+ }
9679
+ ),
9680
+ /* @__PURE__ */ jsxRuntime.jsx(
9681
+ Form$2.Field,
9682
+ {
9683
+ control: form.control,
9684
+ name: "address_1",
9685
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9686
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9687
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9688
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9689
+ ] })
9690
+ }
9691
+ ),
9692
+ /* @__PURE__ */ jsxRuntime.jsx(
9693
+ Form$2.Field,
9694
+ {
9695
+ control: form.control,
9696
+ name: "address_2",
9697
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9698
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9699
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9701
+ ] })
9702
+ }
9703
+ ),
9704
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9705
+ /* @__PURE__ */ jsxRuntime.jsx(
9706
+ Form$2.Field,
9707
+ {
9708
+ control: form.control,
9709
+ name: "postal_code",
9710
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9711
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9712
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9714
+ ] })
9715
+ }
9716
+ ),
9717
+ /* @__PURE__ */ jsxRuntime.jsx(
9718
+ Form$2.Field,
9719
+ {
9720
+ control: form.control,
9721
+ name: "city",
9722
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9723
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9724
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9726
+ ] })
9727
+ }
9728
+ )
9729
+ ] }),
9730
+ /* @__PURE__ */ jsxRuntime.jsx(
9731
+ Form$2.Field,
9732
+ {
9733
+ control: form.control,
9734
+ name: "province",
9735
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9736
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9737
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9739
+ ] })
9740
+ }
9741
+ ),
9742
+ /* @__PURE__ */ jsxRuntime.jsx(
9743
+ Form$2.Field,
9744
+ {
9745
+ control: form.control,
9746
+ name: "phone",
9747
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9748
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9749
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9751
+ ] })
9752
+ }
9753
+ )
9754
+ ] }) }),
9755
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9756
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9757
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9758
+ ] }) })
9759
+ ]
9760
+ }
9761
+ ) });
9762
+ };
9763
+ const schema$5 = addressSchema;
9574
9764
  const CustomItems = () => {
9575
9765
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9576
9766
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9579,7 +9769,7 @@ const CustomItems = () => {
9579
9769
  };
9580
9770
  const CustomItemsForm = () => {
9581
9771
  const form = reactHookForm.useForm({
9582
- resolver: zod.zodResolver(schema$5)
9772
+ resolver: zod.zodResolver(schema$4)
9583
9773
  });
9584
9774
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9585
9775
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9589,7 +9779,75 @@ const CustomItemsForm = () => {
9589
9779
  ] }) })
9590
9780
  ] }) });
9591
9781
  };
9592
- const schema$5 = objectType({
9782
+ const schema$4 = objectType({
9783
+ email: stringType().email()
9784
+ });
9785
+ const Email = () => {
9786
+ const { id } = reactRouterDom.useParams();
9787
+ const { order, isPending, isError, error } = useOrder(id, {
9788
+ fields: "+email"
9789
+ });
9790
+ if (isError) {
9791
+ throw error;
9792
+ }
9793
+ const isReady = !isPending && !!order;
9794
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9795
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9796
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9797
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9798
+ ] }),
9799
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9800
+ ] });
9801
+ };
9802
+ const EmailForm = ({ order }) => {
9803
+ const form = reactHookForm.useForm({
9804
+ defaultValues: {
9805
+ email: order.email ?? ""
9806
+ },
9807
+ resolver: zod.zodResolver(schema$3)
9808
+ });
9809
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9810
+ const { handleSuccess } = useRouteModal();
9811
+ const onSubmit = form.handleSubmit(async (data) => {
9812
+ await mutateAsync(
9813
+ { email: data.email },
9814
+ {
9815
+ onSuccess: () => {
9816
+ handleSuccess();
9817
+ },
9818
+ onError: (error) => {
9819
+ ui.toast.error(error.message);
9820
+ }
9821
+ }
9822
+ );
9823
+ });
9824
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9825
+ KeyboundForm,
9826
+ {
9827
+ className: "flex flex-1 flex-col overflow-hidden",
9828
+ onSubmit,
9829
+ children: [
9830
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9831
+ Form$2.Field,
9832
+ {
9833
+ control: form.control,
9834
+ name: "email",
9835
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9836
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9837
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9838
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9839
+ ] })
9840
+ }
9841
+ ) }),
9842
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9843
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9844
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9845
+ ] }) })
9846
+ ]
9847
+ }
9848
+ ) });
9849
+ };
9850
+ const schema$3 = objectType({
9593
9851
  email: stringType().email()
9594
9852
  });
9595
9853
  const NumberInput = React.forwardRef(
@@ -11221,7 +11479,7 @@ const SalesChannelForm = ({ order }) => {
11221
11479
  defaultValues: {
11222
11480
  sales_channel_id: order.sales_channel_id || ""
11223
11481
  },
11224
- resolver: zod.zodResolver(schema$4)
11482
+ resolver: zod.zodResolver(schema$2)
11225
11483
  });
11226
11484
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11227
11485
  const { handleSuccess } = useRouteModal();
@@ -11296,7 +11554,7 @@ const SalesChannelField = ({ control, order }) => {
11296
11554
  }
11297
11555
  );
11298
11556
  };
11299
- const schema$4 = objectType({
11557
+ const schema$2 = objectType({
11300
11558
  sales_channel_id: stringType().min(1)
11301
11559
  });
11302
11560
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12138,7 +12396,7 @@ const ShippingAddressForm = ({ order }) => {
12138
12396
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12139
12397
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12140
12398
  },
12141
- resolver: zod.zodResolver(schema$3)
12399
+ resolver: zod.zodResolver(schema$1)
12142
12400
  });
12143
12401
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12144
12402
  const { handleSuccess } = useRouteModal();
@@ -12308,7 +12566,7 @@ const ShippingAddressForm = ({ order }) => {
12308
12566
  }
12309
12567
  ) });
12310
12568
  };
12311
- const schema$3 = addressSchema;
12569
+ const schema$1 = addressSchema;
12312
12570
  const TransferOwnership = () => {
12313
12571
  const { id } = reactRouterDom.useParams();
12314
12572
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12332,7 +12590,7 @@ const TransferOwnershipForm = ({ order }) => {
12332
12590
  defaultValues: {
12333
12591
  customer_id: order.customer_id || ""
12334
12592
  },
12335
- resolver: zod.zodResolver(schema$2)
12593
+ resolver: zod.zodResolver(schema)
12336
12594
  });
12337
12595
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12338
12596
  const { handleSuccess } = useRouteModal();
@@ -12711,337 +12969,79 @@ const Illustration = () => {
12711
12969
  strokeLinecap: "round",
12712
12970
  strokeLinejoin: "round"
12713
12971
  }
12714
- ) }),
12715
- /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12716
- "path",
12717
- {
12718
- d: "M146.894 101.198L139.51 101.155L139.486 105.365",
12719
- stroke: "#A1A1AA",
12720
- strokeWidth: "1.5",
12721
- strokeLinecap: "round",
12722
- strokeLinejoin: "round"
12723
- }
12724
- ) }),
12725
- /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
12726
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12727
- "rect",
12728
- {
12729
- width: "12",
12730
- height: "12",
12731
- fill: "white",
12732
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
12733
- }
12734
- ) }),
12735
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12736
- "rect",
12737
- {
12738
- width: "12",
12739
- height: "12",
12740
- fill: "white",
12741
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
12742
- }
12743
- ) }),
12744
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12745
- "rect",
12746
- {
12747
- width: "12",
12748
- height: "12",
12749
- fill: "white",
12750
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
12751
- }
12752
- ) }),
12753
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12754
- "rect",
12755
- {
12756
- width: "12",
12757
- height: "12",
12758
- fill: "white",
12759
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
12760
- }
12761
- ) }),
12762
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12763
- "rect",
12764
- {
12765
- width: "12",
12766
- height: "12",
12767
- fill: "white",
12768
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
12769
- }
12770
- ) }),
12771
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12772
- "rect",
12773
- {
12774
- width: "12",
12775
- height: "12",
12776
- fill: "white",
12777
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12778
- }
12779
- ) })
12780
- ] })
12781
- ]
12782
- }
12783
- );
12784
- };
12785
- const schema$2 = objectType({
12786
- customer_id: stringType().min(1)
12787
- });
12788
- const BillingAddress = () => {
12789
- const { id } = reactRouterDom.useParams();
12790
- const { order, isPending, isError, error } = useOrder(id, {
12791
- fields: "+billing_address"
12792
- });
12793
- if (isError) {
12794
- throw error;
12795
- }
12796
- const isReady = !isPending && !!order;
12797
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12798
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12799
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12800
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12801
- ] }),
12802
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12803
- ] });
12804
- };
12805
- const BillingAddressForm = ({ order }) => {
12806
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12807
- const form = reactHookForm.useForm({
12808
- defaultValues: {
12809
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12810
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12811
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12812
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12813
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12814
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12815
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12816
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12817
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12818
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12819
- },
12820
- resolver: zod.zodResolver(schema$1)
12821
- });
12822
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12823
- const { handleSuccess } = useRouteModal();
12824
- const onSubmit = form.handleSubmit(async (data) => {
12825
- await mutateAsync(
12826
- { billing_address: data },
12827
- {
12828
- onSuccess: () => {
12829
- handleSuccess();
12830
- },
12831
- onError: (error) => {
12832
- ui.toast.error(error.message);
12833
- }
12834
- }
12835
- );
12836
- });
12837
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12838
- KeyboundForm,
12839
- {
12840
- className: "flex flex-1 flex-col overflow-hidden",
12841
- onSubmit,
12842
- children: [
12843
- /* @__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: [
12844
- /* @__PURE__ */ jsxRuntime.jsx(
12845
- Form$2.Field,
12972
+ ) }),
12973
+ /* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
12974
+ "path",
12975
+ {
12976
+ d: "M146.894 101.198L139.51 101.155L139.486 105.365",
12977
+ stroke: "#A1A1AA",
12978
+ strokeWidth: "1.5",
12979
+ strokeLinecap: "round",
12980
+ strokeLinejoin: "round"
12981
+ }
12982
+ ) }),
12983
+ /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
12984
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12985
+ "rect",
12846
12986
  {
12847
- control: form.control,
12848
- name: "country_code",
12849
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12850
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12851
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12852
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12853
- ] })
12987
+ width: "12",
12988
+ height: "12",
12989
+ fill: "white",
12990
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
12854
12991
  }
12855
- ),
12856
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12857
- /* @__PURE__ */ jsxRuntime.jsx(
12858
- Form$2.Field,
12859
- {
12860
- control: form.control,
12861
- name: "first_name",
12862
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12863
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12864
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12865
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12866
- ] })
12867
- }
12868
- ),
12869
- /* @__PURE__ */ jsxRuntime.jsx(
12870
- Form$2.Field,
12871
- {
12872
- control: form.control,
12873
- name: "last_name",
12874
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12875
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12876
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12877
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12878
- ] })
12879
- }
12880
- )
12881
- ] }),
12882
- /* @__PURE__ */ jsxRuntime.jsx(
12883
- Form$2.Field,
12992
+ ) }),
12993
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
12994
+ "rect",
12884
12995
  {
12885
- control: form.control,
12886
- name: "company",
12887
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12888
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12889
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12890
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12891
- ] })
12996
+ width: "12",
12997
+ height: "12",
12998
+ fill: "white",
12999
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
12892
13000
  }
12893
- ),
12894
- /* @__PURE__ */ jsxRuntime.jsx(
12895
- Form$2.Field,
13001
+ ) }),
13002
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13003
+ "rect",
12896
13004
  {
12897
- control: form.control,
12898
- name: "address_1",
12899
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12900
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12901
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12902
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12903
- ] })
13005
+ width: "12",
13006
+ height: "12",
13007
+ fill: "white",
13008
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
12904
13009
  }
12905
- ),
12906
- /* @__PURE__ */ jsxRuntime.jsx(
12907
- Form$2.Field,
13010
+ ) }),
13011
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13012
+ "rect",
12908
13013
  {
12909
- control: form.control,
12910
- name: "address_2",
12911
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12912
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12913
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12914
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12915
- ] })
13014
+ width: "12",
13015
+ height: "12",
13016
+ fill: "white",
13017
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
12916
13018
  }
12917
- ),
12918
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12919
- /* @__PURE__ */ jsxRuntime.jsx(
12920
- Form$2.Field,
12921
- {
12922
- control: form.control,
12923
- name: "postal_code",
12924
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12925
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12926
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12927
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12928
- ] })
12929
- }
12930
- ),
12931
- /* @__PURE__ */ jsxRuntime.jsx(
12932
- Form$2.Field,
12933
- {
12934
- control: form.control,
12935
- name: "city",
12936
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12937
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
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
- ] }),
12944
- /* @__PURE__ */ jsxRuntime.jsx(
12945
- Form$2.Field,
13019
+ ) }),
13020
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13021
+ "rect",
12946
13022
  {
12947
- control: form.control,
12948
- name: "province",
12949
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12950
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12951
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12952
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12953
- ] })
13023
+ width: "12",
13024
+ height: "12",
13025
+ fill: "white",
13026
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
12954
13027
  }
12955
- ),
12956
- /* @__PURE__ */ jsxRuntime.jsx(
12957
- Form$2.Field,
13028
+ ) }),
13029
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
13030
+ "rect",
12958
13031
  {
12959
- control: form.control,
12960
- name: "phone",
12961
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12962
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12963
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12964
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12965
- ] })
13032
+ width: "12",
13033
+ height: "12",
13034
+ fill: "white",
13035
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12966
13036
  }
12967
- )
12968
- ] }) }),
12969
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12970
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12971
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12972
- ] }) })
12973
- ]
12974
- }
12975
- ) });
12976
- };
12977
- const schema$1 = addressSchema;
12978
- const Email = () => {
12979
- const { id } = reactRouterDom.useParams();
12980
- const { order, isPending, isError, error } = useOrder(id, {
12981
- fields: "+email"
12982
- });
12983
- if (isError) {
12984
- throw error;
12985
- }
12986
- const isReady = !isPending && !!order;
12987
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12988
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12989
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
12990
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
12991
- ] }),
12992
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
12993
- ] });
12994
- };
12995
- const EmailForm = ({ order }) => {
12996
- const form = reactHookForm.useForm({
12997
- defaultValues: {
12998
- email: order.email ?? ""
12999
- },
13000
- resolver: zod.zodResolver(schema)
13001
- });
13002
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
13003
- const { handleSuccess } = useRouteModal();
13004
- const onSubmit = form.handleSubmit(async (data) => {
13005
- await mutateAsync(
13006
- { email: data.email },
13007
- {
13008
- onSuccess: () => {
13009
- handleSuccess();
13010
- },
13011
- onError: (error) => {
13012
- ui.toast.error(error.message);
13013
- }
13014
- }
13015
- );
13016
- });
13017
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
13018
- KeyboundForm,
13019
- {
13020
- className: "flex flex-1 flex-col overflow-hidden",
13021
- onSubmit,
13022
- children: [
13023
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
13024
- Form$2.Field,
13025
- {
13026
- control: form.control,
13027
- name: "email",
13028
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13029
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
13030
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13031
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13032
- ] })
13033
- }
13034
- ) }),
13035
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13036
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13037
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13038
- ] }) })
13037
+ ) })
13038
+ ] })
13039
13039
  ]
13040
13040
  }
13041
- ) });
13041
+ );
13042
13042
  };
13043
13043
  const schema = objectType({
13044
- email: stringType().email()
13044
+ customer_id: stringType().min(1)
13045
13045
  });
13046
13046
  const widgetModule = { widgets: [] };
13047
13047
  const routeModule = {
@@ -13063,10 +13063,18 @@ const routeModule = {
13063
13063
  handle,
13064
13064
  loader,
13065
13065
  children: [
13066
+ {
13067
+ Component: BillingAddress,
13068
+ path: "/draft-orders/:id/billing-address"
13069
+ },
13066
13070
  {
13067
13071
  Component: CustomItems,
13068
13072
  path: "/draft-orders/:id/custom-items"
13069
13073
  },
13074
+ {
13075
+ Component: Email,
13076
+ path: "/draft-orders/:id/email"
13077
+ },
13070
13078
  {
13071
13079
  Component: Items,
13072
13080
  path: "/draft-orders/:id/items"
@@ -13094,14 +13102,6 @@ const routeModule = {
13094
13102
  {
13095
13103
  Component: TransferOwnership,
13096
13104
  path: "/draft-orders/:id/transfer-ownership"
13097
- },
13098
- {
13099
- Component: BillingAddress,
13100
- path: "/draft-orders/:id/billing-address"
13101
- },
13102
- {
13103
- Component: Email,
13104
- path: "/draft-orders/:id/email"
13105
13105
  }
13106
13106
  ]
13107
13107
  }