@medusajs/draft-order 2.11.3-preview-20251101060137 → 2.11.3-preview-20251101090134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9572,6 +9572,285 @@ const ID = () => {
9572
9572
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9573
9573
  ] });
9574
9574
  };
9575
+ const BillingAddress = () => {
9576
+ const { id } = reactRouterDom.useParams();
9577
+ const { order, isPending, isError, error } = useOrder(id, {
9578
+ fields: "+billing_address"
9579
+ });
9580
+ if (isError) {
9581
+ throw error;
9582
+ }
9583
+ const isReady = !isPending && !!order;
9584
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9585
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9586
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9588
+ ] }),
9589
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9590
+ ] });
9591
+ };
9592
+ const BillingAddressForm = ({ order }) => {
9593
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9594
+ const form = reactHookForm.useForm({
9595
+ defaultValues: {
9596
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9597
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9598
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9599
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9600
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9601
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9602
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9603
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9604
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9605
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9606
+ },
9607
+ resolver: zod.zodResolver(schema$5)
9608
+ });
9609
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9610
+ const { handleSuccess } = useRouteModal();
9611
+ const onSubmit = form.handleSubmit(async (data) => {
9612
+ await mutateAsync(
9613
+ { billing_address: data },
9614
+ {
9615
+ onSuccess: () => {
9616
+ handleSuccess();
9617
+ },
9618
+ onError: (error) => {
9619
+ ui.toast.error(error.message);
9620
+ }
9621
+ }
9622
+ );
9623
+ });
9624
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9625
+ KeyboundForm,
9626
+ {
9627
+ className: "flex flex-1 flex-col overflow-hidden",
9628
+ onSubmit,
9629
+ children: [
9630
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
9631
+ /* @__PURE__ */ jsxRuntime.jsx(
9632
+ Form$2.Field,
9633
+ {
9634
+ control: form.control,
9635
+ name: "country_code",
9636
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9637
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9638
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9639
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9640
+ ] })
9641
+ }
9642
+ ),
9643
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9644
+ /* @__PURE__ */ jsxRuntime.jsx(
9645
+ Form$2.Field,
9646
+ {
9647
+ control: form.control,
9648
+ name: "first_name",
9649
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9650
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9651
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9652
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9653
+ ] })
9654
+ }
9655
+ ),
9656
+ /* @__PURE__ */ jsxRuntime.jsx(
9657
+ Form$2.Field,
9658
+ {
9659
+ control: form.control,
9660
+ name: "last_name",
9661
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9662
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9663
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9664
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9665
+ ] })
9666
+ }
9667
+ )
9668
+ ] }),
9669
+ /* @__PURE__ */ jsxRuntime.jsx(
9670
+ Form$2.Field,
9671
+ {
9672
+ control: form.control,
9673
+ name: "company",
9674
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9675
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9676
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9677
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9678
+ ] })
9679
+ }
9680
+ ),
9681
+ /* @__PURE__ */ jsxRuntime.jsx(
9682
+ Form$2.Field,
9683
+ {
9684
+ control: form.control,
9685
+ name: "address_1",
9686
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9687
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9688
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9689
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9690
+ ] })
9691
+ }
9692
+ ),
9693
+ /* @__PURE__ */ jsxRuntime.jsx(
9694
+ Form$2.Field,
9695
+ {
9696
+ control: form.control,
9697
+ name: "address_2",
9698
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9699
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9701
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9702
+ ] })
9703
+ }
9704
+ ),
9705
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9706
+ /* @__PURE__ */ jsxRuntime.jsx(
9707
+ Form$2.Field,
9708
+ {
9709
+ control: form.control,
9710
+ name: "postal_code",
9711
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9712
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9714
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9715
+ ] })
9716
+ }
9717
+ ),
9718
+ /* @__PURE__ */ jsxRuntime.jsx(
9719
+ Form$2.Field,
9720
+ {
9721
+ control: form.control,
9722
+ name: "city",
9723
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9724
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9727
+ ] })
9728
+ }
9729
+ )
9730
+ ] }),
9731
+ /* @__PURE__ */ jsxRuntime.jsx(
9732
+ Form$2.Field,
9733
+ {
9734
+ control: form.control,
9735
+ name: "province",
9736
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9737
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9739
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9740
+ ] })
9741
+ }
9742
+ ),
9743
+ /* @__PURE__ */ jsxRuntime.jsx(
9744
+ Form$2.Field,
9745
+ {
9746
+ control: form.control,
9747
+ name: "phone",
9748
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9749
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9751
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9752
+ ] })
9753
+ }
9754
+ )
9755
+ ] }) }),
9756
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9757
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9758
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9759
+ ] }) })
9760
+ ]
9761
+ }
9762
+ ) });
9763
+ };
9764
+ const schema$5 = addressSchema;
9765
+ const CustomItems = () => {
9766
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9767
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9768
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9769
+ ] });
9770
+ };
9771
+ const CustomItemsForm = () => {
9772
+ const form = reactHookForm.useForm({
9773
+ resolver: zod.zodResolver(schema$4)
9774
+ });
9775
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9776
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9777
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9778
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9779
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9780
+ ] }) })
9781
+ ] }) });
9782
+ };
9783
+ const schema$4 = objectType({
9784
+ email: stringType().email()
9785
+ });
9786
+ const Email = () => {
9787
+ const { id } = reactRouterDom.useParams();
9788
+ const { order, isPending, isError, error } = useOrder(id, {
9789
+ fields: "+email"
9790
+ });
9791
+ if (isError) {
9792
+ throw error;
9793
+ }
9794
+ const isReady = !isPending && !!order;
9795
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9796
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9797
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9798
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9799
+ ] }),
9800
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9801
+ ] });
9802
+ };
9803
+ const EmailForm = ({ order }) => {
9804
+ const form = reactHookForm.useForm({
9805
+ defaultValues: {
9806
+ email: order.email ?? ""
9807
+ },
9808
+ resolver: zod.zodResolver(schema$3)
9809
+ });
9810
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9811
+ const { handleSuccess } = useRouteModal();
9812
+ const onSubmit = form.handleSubmit(async (data) => {
9813
+ await mutateAsync(
9814
+ { email: data.email },
9815
+ {
9816
+ onSuccess: () => {
9817
+ handleSuccess();
9818
+ },
9819
+ onError: (error) => {
9820
+ ui.toast.error(error.message);
9821
+ }
9822
+ }
9823
+ );
9824
+ });
9825
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9826
+ KeyboundForm,
9827
+ {
9828
+ className: "flex flex-1 flex-col overflow-hidden",
9829
+ onSubmit,
9830
+ children: [
9831
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9832
+ Form$2.Field,
9833
+ {
9834
+ control: form.control,
9835
+ name: "email",
9836
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9837
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9838
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9839
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9840
+ ] })
9841
+ }
9842
+ ) }),
9843
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9844
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9845
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9846
+ ] }) })
9847
+ ]
9848
+ }
9849
+ ) });
9850
+ };
9851
+ const schema$3 = objectType({
9852
+ email: stringType().email()
9853
+ });
9575
9854
  const NumberInput = React.forwardRef(
9576
9855
  ({
9577
9856
  value,
@@ -10526,93 +10805,25 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
10526
10805
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10527
10806
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
10528
10807
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
10529
- ] }),
10530
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex-1", children: [
10531
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field, className: "w-full" }) }) }),
10532
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10533
- ] })
10534
- ] }) })
10535
- }
10536
- )
10537
- ] }) }) }),
10538
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10539
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10540
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
10541
- ] }) })
10542
- ] }) }) });
10543
- };
10544
- const customItemSchema = objectType({
10545
- title: stringType().min(1),
10546
- quantity: numberType(),
10547
- unit_price: unionType([numberType(), stringType()])
10548
- });
10549
- const Email = () => {
10550
- const { id } = reactRouterDom.useParams();
10551
- const { order, isPending, isError, error } = useOrder(id, {
10552
- fields: "+email"
10553
- });
10554
- if (isError) {
10555
- throw error;
10556
- }
10557
- const isReady = !isPending && !!order;
10558
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10559
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10560
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
10561
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
10562
- ] }),
10563
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
10564
- ] });
10565
- };
10566
- const EmailForm = ({ order }) => {
10567
- const form = reactHookForm.useForm({
10568
- defaultValues: {
10569
- email: order.email ?? ""
10570
- },
10571
- resolver: zod.zodResolver(schema$5)
10572
- });
10573
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10574
- const { handleSuccess } = useRouteModal();
10575
- const onSubmit = form.handleSubmit(async (data) => {
10576
- await mutateAsync(
10577
- { email: data.email },
10578
- {
10579
- onSuccess: () => {
10580
- handleSuccess();
10581
- },
10582
- onError: (error) => {
10583
- ui.toast.error(error.message);
10584
- }
10585
- }
10586
- );
10587
- });
10588
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10589
- KeyboundForm,
10590
- {
10591
- className: "flex flex-1 flex-col overflow-hidden",
10592
- onSubmit,
10593
- children: [
10594
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
10595
- Form$2.Field,
10596
- {
10597
- control: form.control,
10598
- name: "email",
10599
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10600
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
10601
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10808
+ ] }),
10809
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex-1", children: [
10810
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field, className: "w-full" }) }) }),
10602
10811
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10603
10812
  ] })
10604
- }
10605
- ) }),
10606
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10607
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10608
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10609
- ] }) })
10610
- ]
10611
- }
10612
- ) });
10813
+ ] }) })
10814
+ }
10815
+ )
10816
+ ] }) }) }),
10817
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10818
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10819
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
10820
+ ] }) })
10821
+ ] }) }) });
10613
10822
  };
10614
- const schema$5 = objectType({
10615
- email: stringType().email()
10823
+ const customItemSchema = objectType({
10824
+ title: stringType().min(1),
10825
+ quantity: numberType(),
10826
+ unit_price: unionType([numberType(), stringType()])
10616
10827
  });
10617
10828
  const InlineTip = React.forwardRef(
10618
10829
  ({ variant = "tip", label, className, children, ...props }, ref) => {
@@ -11241,217 +11452,6 @@ function getPromotionIds(items, shippingMethods) {
11241
11452
  }
11242
11453
  return Array.from(promotionIds);
11243
11454
  }
11244
- const CustomItems = () => {
11245
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11246
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
11247
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
11248
- ] });
11249
- };
11250
- const CustomItemsForm = () => {
11251
- const form = reactHookForm.useForm({
11252
- resolver: zod.zodResolver(schema$4)
11253
- });
11254
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
11255
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
11256
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11257
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11258
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
11259
- ] }) })
11260
- ] }) });
11261
- };
11262
- const schema$4 = objectType({
11263
- email: stringType().email()
11264
- });
11265
- const BillingAddress = () => {
11266
- const { id } = reactRouterDom.useParams();
11267
- const { order, isPending, isError, error } = useOrder(id, {
11268
- fields: "+billing_address"
11269
- });
11270
- if (isError) {
11271
- throw error;
11272
- }
11273
- const isReady = !isPending && !!order;
11274
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11275
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11276
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
11277
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
11278
- ] }),
11279
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
11280
- ] });
11281
- };
11282
- const BillingAddressForm = ({ order }) => {
11283
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11284
- const form = reactHookForm.useForm({
11285
- defaultValues: {
11286
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
11287
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
11288
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
11289
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
11290
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
11291
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
11292
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
11293
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
11294
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
11295
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
11296
- },
11297
- resolver: zod.zodResolver(schema$3)
11298
- });
11299
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11300
- const { handleSuccess } = useRouteModal();
11301
- const onSubmit = form.handleSubmit(async (data) => {
11302
- await mutateAsync(
11303
- { billing_address: data },
11304
- {
11305
- onSuccess: () => {
11306
- handleSuccess();
11307
- },
11308
- onError: (error) => {
11309
- ui.toast.error(error.message);
11310
- }
11311
- }
11312
- );
11313
- });
11314
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11315
- KeyboundForm,
11316
- {
11317
- className: "flex flex-1 flex-col overflow-hidden",
11318
- onSubmit,
11319
- children: [
11320
- /* @__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: [
11321
- /* @__PURE__ */ jsxRuntime.jsx(
11322
- Form$2.Field,
11323
- {
11324
- control: form.control,
11325
- name: "country_code",
11326
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11327
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11328
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11329
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11330
- ] })
11331
- }
11332
- ),
11333
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11334
- /* @__PURE__ */ jsxRuntime.jsx(
11335
- Form$2.Field,
11336
- {
11337
- control: form.control,
11338
- name: "first_name",
11339
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11340
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11341
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11342
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11343
- ] })
11344
- }
11345
- ),
11346
- /* @__PURE__ */ jsxRuntime.jsx(
11347
- Form$2.Field,
11348
- {
11349
- control: form.control,
11350
- name: "last_name",
11351
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11352
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11353
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11354
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11355
- ] })
11356
- }
11357
- )
11358
- ] }),
11359
- /* @__PURE__ */ jsxRuntime.jsx(
11360
- Form$2.Field,
11361
- {
11362
- control: form.control,
11363
- name: "company",
11364
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11365
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11366
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11367
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11368
- ] })
11369
- }
11370
- ),
11371
- /* @__PURE__ */ jsxRuntime.jsx(
11372
- Form$2.Field,
11373
- {
11374
- control: form.control,
11375
- name: "address_1",
11376
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11377
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11378
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11379
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11380
- ] })
11381
- }
11382
- ),
11383
- /* @__PURE__ */ jsxRuntime.jsx(
11384
- Form$2.Field,
11385
- {
11386
- control: form.control,
11387
- name: "address_2",
11388
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11389
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11390
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11391
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11392
- ] })
11393
- }
11394
- ),
11395
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11396
- /* @__PURE__ */ jsxRuntime.jsx(
11397
- Form$2.Field,
11398
- {
11399
- control: form.control,
11400
- name: "postal_code",
11401
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11402
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11403
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11404
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11405
- ] })
11406
- }
11407
- ),
11408
- /* @__PURE__ */ jsxRuntime.jsx(
11409
- Form$2.Field,
11410
- {
11411
- control: form.control,
11412
- name: "city",
11413
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11414
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11415
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11416
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11417
- ] })
11418
- }
11419
- )
11420
- ] }),
11421
- /* @__PURE__ */ jsxRuntime.jsx(
11422
- Form$2.Field,
11423
- {
11424
- control: form.control,
11425
- name: "province",
11426
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11427
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11428
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11429
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11430
- ] })
11431
- }
11432
- ),
11433
- /* @__PURE__ */ jsxRuntime.jsx(
11434
- Form$2.Field,
11435
- {
11436
- control: form.control,
11437
- name: "phone",
11438
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11439
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11440
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11441
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11442
- ] })
11443
- }
11444
- )
11445
- ] }) }),
11446
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11447
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11448
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11449
- ] }) })
11450
- ]
11451
- }
11452
- ) });
11453
- };
11454
- const schema$3 = addressSchema;
11455
11455
  const SalesChannel = () => {
11456
11456
  const { id } = reactRouterDom.useParams();
11457
11457
  const { draft_order, isPending, isError, error } = useDraftOrder(
@@ -13065,13 +13065,21 @@ const routeModule = {
13065
13065
  loader,
13066
13066
  children: [
13067
13067
  {
13068
- Component: Items,
13069
- path: "/draft-orders/:id/items"
13068
+ Component: BillingAddress,
13069
+ path: "/draft-orders/:id/billing-address"
13070
+ },
13071
+ {
13072
+ Component: CustomItems,
13073
+ path: "/draft-orders/:id/custom-items"
13070
13074
  },
13071
13075
  {
13072
13076
  Component: Email,
13073
13077
  path: "/draft-orders/:id/email"
13074
13078
  },
13079
+ {
13080
+ Component: Items,
13081
+ path: "/draft-orders/:id/items"
13082
+ },
13075
13083
  {
13076
13084
  Component: Metadata,
13077
13085
  path: "/draft-orders/:id/metadata"
@@ -13080,14 +13088,6 @@ const routeModule = {
13080
13088
  Component: Promotions,
13081
13089
  path: "/draft-orders/:id/promotions"
13082
13090
  },
13083
- {
13084
- Component: CustomItems,
13085
- path: "/draft-orders/:id/custom-items"
13086
- },
13087
- {
13088
- Component: BillingAddress,
13089
- path: "/draft-orders/:id/billing-address"
13090
- },
13091
13091
  {
13092
13092
  Component: SalesChannel,
13093
13093
  path: "/draft-orders/:id/sales-channel"