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

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