@medusajs/draft-order 2.10.2-preview-20250901060152 → 2.10.2-preview-20250901090155

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.
@@ -9554,196 +9554,6 @@ const ID = () => {
9554
9554
  /* @__PURE__ */ jsx(Outlet, {})
9555
9555
  ] });
9556
9556
  };
9557
- const BillingAddress = () => {
9558
- const { id } = useParams();
9559
- const { order, isPending, isError, error } = useOrder(id, {
9560
- fields: "+billing_address"
9561
- });
9562
- if (isError) {
9563
- throw error;
9564
- }
9565
- const isReady = !isPending && !!order;
9566
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9567
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9568
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9569
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9570
- ] }),
9571
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9572
- ] });
9573
- };
9574
- const BillingAddressForm = ({ order }) => {
9575
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9576
- const form = useForm({
9577
- defaultValues: {
9578
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9579
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9580
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9581
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9582
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9583
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9584
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9585
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9586
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9587
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9588
- },
9589
- resolver: zodResolver(schema$5)
9590
- });
9591
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9592
- const { handleSuccess } = useRouteModal();
9593
- const onSubmit = form.handleSubmit(async (data) => {
9594
- await mutateAsync(
9595
- { billing_address: data },
9596
- {
9597
- onSuccess: () => {
9598
- handleSuccess();
9599
- },
9600
- onError: (error) => {
9601
- toast.error(error.message);
9602
- }
9603
- }
9604
- );
9605
- });
9606
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9607
- KeyboundForm,
9608
- {
9609
- className: "flex flex-1 flex-col overflow-hidden",
9610
- onSubmit,
9611
- children: [
9612
- /* @__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: [
9613
- /* @__PURE__ */ jsx(
9614
- Form$2.Field,
9615
- {
9616
- control: form.control,
9617
- name: "country_code",
9618
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9619
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9620
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9621
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9622
- ] })
9623
- }
9624
- ),
9625
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9626
- /* @__PURE__ */ jsx(
9627
- Form$2.Field,
9628
- {
9629
- control: form.control,
9630
- name: "first_name",
9631
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9632
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9633
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9634
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9635
- ] })
9636
- }
9637
- ),
9638
- /* @__PURE__ */ jsx(
9639
- Form$2.Field,
9640
- {
9641
- control: form.control,
9642
- name: "last_name",
9643
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9644
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9645
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9646
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9647
- ] })
9648
- }
9649
- )
9650
- ] }),
9651
- /* @__PURE__ */ jsx(
9652
- Form$2.Field,
9653
- {
9654
- control: form.control,
9655
- name: "company",
9656
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9657
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9658
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9659
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9660
- ] })
9661
- }
9662
- ),
9663
- /* @__PURE__ */ jsx(
9664
- Form$2.Field,
9665
- {
9666
- control: form.control,
9667
- name: "address_1",
9668
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9669
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9670
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9671
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9672
- ] })
9673
- }
9674
- ),
9675
- /* @__PURE__ */ jsx(
9676
- Form$2.Field,
9677
- {
9678
- control: form.control,
9679
- name: "address_2",
9680
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9681
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9682
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9683
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9684
- ] })
9685
- }
9686
- ),
9687
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9688
- /* @__PURE__ */ jsx(
9689
- Form$2.Field,
9690
- {
9691
- control: form.control,
9692
- name: "postal_code",
9693
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9694
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9695
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9696
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9697
- ] })
9698
- }
9699
- ),
9700
- /* @__PURE__ */ jsx(
9701
- Form$2.Field,
9702
- {
9703
- control: form.control,
9704
- name: "city",
9705
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9706
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9707
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9708
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9709
- ] })
9710
- }
9711
- )
9712
- ] }),
9713
- /* @__PURE__ */ jsx(
9714
- Form$2.Field,
9715
- {
9716
- control: form.control,
9717
- name: "province",
9718
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9719
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9720
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9721
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9722
- ] })
9723
- }
9724
- ),
9725
- /* @__PURE__ */ jsx(
9726
- Form$2.Field,
9727
- {
9728
- control: form.control,
9729
- name: "phone",
9730
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9731
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9732
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9733
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9734
- ] })
9735
- }
9736
- )
9737
- ] }) }),
9738
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9739
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9740
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9741
- ] }) })
9742
- ]
9743
- }
9744
- ) });
9745
- };
9746
- const schema$5 = addressSchema;
9747
9557
  const CustomItems = () => {
9748
9558
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9749
9559
  /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
@@ -9752,7 +9562,7 @@ const CustomItems = () => {
9752
9562
  };
9753
9563
  const CustomItemsForm = () => {
9754
9564
  const form = useForm({
9755
- resolver: zodResolver(schema$4)
9565
+ resolver: zodResolver(schema$5)
9756
9566
  });
9757
9567
  return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9758
9568
  /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
@@ -9762,7 +9572,7 @@ const CustomItemsForm = () => {
9762
9572
  ] }) })
9763
9573
  ] }) });
9764
9574
  };
9765
- const schema$4 = objectType({
9575
+ const schema$5 = objectType({
9766
9576
  email: stringType().email()
9767
9577
  });
9768
9578
  const Email = () => {
@@ -9787,7 +9597,7 @@ const EmailForm = ({ order }) => {
9787
9597
  defaultValues: {
9788
9598
  email: order.email ?? ""
9789
9599
  },
9790
- resolver: zodResolver(schema$3)
9600
+ resolver: zodResolver(schema$4)
9791
9601
  });
9792
9602
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9793
9603
  const { handleSuccess } = useRouteModal();
@@ -9830,7 +9640,7 @@ const EmailForm = ({ order }) => {
9830
9640
  }
9831
9641
  ) });
9832
9642
  };
9833
- const schema$3 = objectType({
9643
+ const schema$4 = objectType({
9834
9644
  email: stringType().email()
9835
9645
  });
9836
9646
  const NumberInput = forwardRef(
@@ -10802,11 +10612,201 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
10802
10612
  ] }) })
10803
10613
  ] }) }) });
10804
10614
  };
10805
- const customItemSchema = objectType({
10806
- title: stringType().min(1),
10807
- quantity: numberType(),
10808
- unit_price: unionType([numberType(), stringType()])
10809
- });
10615
+ const customItemSchema = objectType({
10616
+ title: stringType().min(1),
10617
+ quantity: numberType(),
10618
+ unit_price: unionType([numberType(), stringType()])
10619
+ });
10620
+ const BillingAddress = () => {
10621
+ const { id } = useParams();
10622
+ const { order, isPending, isError, error } = useOrder(id, {
10623
+ fields: "+billing_address"
10624
+ });
10625
+ if (isError) {
10626
+ throw error;
10627
+ }
10628
+ const isReady = !isPending && !!order;
10629
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
10630
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
10631
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
10632
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
10633
+ ] }),
10634
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
10635
+ ] });
10636
+ };
10637
+ const BillingAddressForm = ({ order }) => {
10638
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
10639
+ const form = useForm({
10640
+ defaultValues: {
10641
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
10642
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
10643
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
10644
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
10645
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
10646
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
10647
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
10648
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
10649
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
10650
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
10651
+ },
10652
+ resolver: zodResolver(schema$3)
10653
+ });
10654
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10655
+ const { handleSuccess } = useRouteModal();
10656
+ const onSubmit = form.handleSubmit(async (data) => {
10657
+ await mutateAsync(
10658
+ { billing_address: data },
10659
+ {
10660
+ onSuccess: () => {
10661
+ handleSuccess();
10662
+ },
10663
+ onError: (error) => {
10664
+ toast.error(error.message);
10665
+ }
10666
+ }
10667
+ );
10668
+ });
10669
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
10670
+ KeyboundForm,
10671
+ {
10672
+ className: "flex flex-1 flex-col overflow-hidden",
10673
+ onSubmit,
10674
+ children: [
10675
+ /* @__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: [
10676
+ /* @__PURE__ */ jsx(
10677
+ Form$2.Field,
10678
+ {
10679
+ control: form.control,
10680
+ name: "country_code",
10681
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10682
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
10683
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
10684
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10685
+ ] })
10686
+ }
10687
+ ),
10688
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10689
+ /* @__PURE__ */ jsx(
10690
+ Form$2.Field,
10691
+ {
10692
+ control: form.control,
10693
+ name: "first_name",
10694
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10695
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
10696
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10697
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10698
+ ] })
10699
+ }
10700
+ ),
10701
+ /* @__PURE__ */ jsx(
10702
+ Form$2.Field,
10703
+ {
10704
+ control: form.control,
10705
+ name: "last_name",
10706
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10707
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
10708
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10709
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10710
+ ] })
10711
+ }
10712
+ )
10713
+ ] }),
10714
+ /* @__PURE__ */ jsx(
10715
+ Form$2.Field,
10716
+ {
10717
+ control: form.control,
10718
+ name: "company",
10719
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10720
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
10721
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10722
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10723
+ ] })
10724
+ }
10725
+ ),
10726
+ /* @__PURE__ */ jsx(
10727
+ Form$2.Field,
10728
+ {
10729
+ control: form.control,
10730
+ name: "address_1",
10731
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10732
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
10733
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10734
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10735
+ ] })
10736
+ }
10737
+ ),
10738
+ /* @__PURE__ */ jsx(
10739
+ Form$2.Field,
10740
+ {
10741
+ control: form.control,
10742
+ name: "address_2",
10743
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10744
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
10745
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10746
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10747
+ ] })
10748
+ }
10749
+ ),
10750
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10751
+ /* @__PURE__ */ jsx(
10752
+ Form$2.Field,
10753
+ {
10754
+ control: form.control,
10755
+ name: "postal_code",
10756
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10757
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
10758
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10759
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10760
+ ] })
10761
+ }
10762
+ ),
10763
+ /* @__PURE__ */ jsx(
10764
+ Form$2.Field,
10765
+ {
10766
+ control: form.control,
10767
+ name: "city",
10768
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10769
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
10770
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10771
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10772
+ ] })
10773
+ }
10774
+ )
10775
+ ] }),
10776
+ /* @__PURE__ */ jsx(
10777
+ Form$2.Field,
10778
+ {
10779
+ control: form.control,
10780
+ name: "province",
10781
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10782
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
10783
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10784
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10785
+ ] })
10786
+ }
10787
+ ),
10788
+ /* @__PURE__ */ jsx(
10789
+ Form$2.Field,
10790
+ {
10791
+ control: form.control,
10792
+ name: "phone",
10793
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10794
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
10795
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10796
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10797
+ ] })
10798
+ }
10799
+ )
10800
+ ] }) }),
10801
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
10802
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10803
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10804
+ ] }) })
10805
+ ]
10806
+ }
10807
+ ) });
10808
+ };
10809
+ const schema$3 = addressSchema;
10810
10810
  const InlineTip = forwardRef(
10811
10811
  ({ variant = "tip", label, className, children, ...props }, ref) => {
10812
10812
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -11434,112 +11434,6 @@ function getPromotionCodes(items, shippingMethods) {
11434
11434
  }
11435
11435
  return Array.from(codes);
11436
11436
  }
11437
- const SalesChannel = () => {
11438
- const { id } = useParams();
11439
- const { draft_order, isPending, isError, error } = useDraftOrder(
11440
- id,
11441
- {
11442
- fields: "+sales_channel_id"
11443
- },
11444
- {
11445
- enabled: !!id
11446
- }
11447
- );
11448
- if (isError) {
11449
- throw error;
11450
- }
11451
- const ISrEADY = !!draft_order && !isPending;
11452
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11453
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11454
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11455
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11456
- ] }),
11457
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11458
- ] });
11459
- };
11460
- const SalesChannelForm = ({ order }) => {
11461
- const form = useForm({
11462
- defaultValues: {
11463
- sales_channel_id: order.sales_channel_id || ""
11464
- },
11465
- resolver: zodResolver(schema$2)
11466
- });
11467
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11468
- const { handleSuccess } = useRouteModal();
11469
- const onSubmit = form.handleSubmit(async (data) => {
11470
- await mutateAsync(
11471
- {
11472
- sales_channel_id: data.sales_channel_id
11473
- },
11474
- {
11475
- onSuccess: () => {
11476
- toast.success("Sales channel updated");
11477
- handleSuccess();
11478
- },
11479
- onError: (error) => {
11480
- toast.error(error.message);
11481
- }
11482
- }
11483
- );
11484
- });
11485
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11486
- KeyboundForm,
11487
- {
11488
- className: "flex flex-1 flex-col overflow-hidden",
11489
- onSubmit,
11490
- children: [
11491
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11492
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11493
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11494
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11495
- ] }) })
11496
- ]
11497
- }
11498
- ) });
11499
- };
11500
- const SalesChannelField = ({ control, order }) => {
11501
- const salesChannels = useComboboxData({
11502
- queryFn: async (params) => {
11503
- return await sdk.admin.salesChannel.list(params);
11504
- },
11505
- queryKey: ["sales-channels"],
11506
- getOptions: (data) => {
11507
- return data.sales_channels.map((salesChannel) => ({
11508
- label: salesChannel.name,
11509
- value: salesChannel.id
11510
- }));
11511
- },
11512
- defaultValue: order.sales_channel_id || void 0
11513
- });
11514
- return /* @__PURE__ */ jsx(
11515
- Form$2.Field,
11516
- {
11517
- control,
11518
- name: "sales_channel_id",
11519
- render: ({ field }) => {
11520
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11521
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11522
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11523
- Combobox,
11524
- {
11525
- options: salesChannels.options,
11526
- fetchNextPage: salesChannels.fetchNextPage,
11527
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11528
- searchValue: salesChannels.searchValue,
11529
- onSearchValueChange: salesChannels.onSearchValueChange,
11530
- placeholder: "Select sales channel",
11531
- ...field
11532
- }
11533
- ) }),
11534
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11535
- ] });
11536
- }
11537
- }
11538
- );
11539
- };
11540
- const schema$2 = objectType({
11541
- sales_channel_id: stringType().min(1)
11542
- });
11543
11437
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11544
11438
  const Shipping = () => {
11545
11439
  var _a;
@@ -12347,6 +12241,112 @@ const CustomAmountField = ({
12347
12241
  }
12348
12242
  );
12349
12243
  };
12244
+ const SalesChannel = () => {
12245
+ const { id } = useParams();
12246
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12247
+ id,
12248
+ {
12249
+ fields: "+sales_channel_id"
12250
+ },
12251
+ {
12252
+ enabled: !!id
12253
+ }
12254
+ );
12255
+ if (isError) {
12256
+ throw error;
12257
+ }
12258
+ const ISrEADY = !!draft_order && !isPending;
12259
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12260
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12261
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12262
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12263
+ ] }),
12264
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12265
+ ] });
12266
+ };
12267
+ const SalesChannelForm = ({ order }) => {
12268
+ const form = useForm({
12269
+ defaultValues: {
12270
+ sales_channel_id: order.sales_channel_id || ""
12271
+ },
12272
+ resolver: zodResolver(schema$2)
12273
+ });
12274
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12275
+ const { handleSuccess } = useRouteModal();
12276
+ const onSubmit = form.handleSubmit(async (data) => {
12277
+ await mutateAsync(
12278
+ {
12279
+ sales_channel_id: data.sales_channel_id
12280
+ },
12281
+ {
12282
+ onSuccess: () => {
12283
+ toast.success("Sales channel updated");
12284
+ handleSuccess();
12285
+ },
12286
+ onError: (error) => {
12287
+ toast.error(error.message);
12288
+ }
12289
+ }
12290
+ );
12291
+ });
12292
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12293
+ KeyboundForm,
12294
+ {
12295
+ className: "flex flex-1 flex-col overflow-hidden",
12296
+ onSubmit,
12297
+ children: [
12298
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12299
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12300
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12301
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12302
+ ] }) })
12303
+ ]
12304
+ }
12305
+ ) });
12306
+ };
12307
+ const SalesChannelField = ({ control, order }) => {
12308
+ const salesChannels = useComboboxData({
12309
+ queryFn: async (params) => {
12310
+ return await sdk.admin.salesChannel.list(params);
12311
+ },
12312
+ queryKey: ["sales-channels"],
12313
+ getOptions: (data) => {
12314
+ return data.sales_channels.map((salesChannel) => ({
12315
+ label: salesChannel.name,
12316
+ value: salesChannel.id
12317
+ }));
12318
+ },
12319
+ defaultValue: order.sales_channel_id || void 0
12320
+ });
12321
+ return /* @__PURE__ */ jsx(
12322
+ Form$2.Field,
12323
+ {
12324
+ control,
12325
+ name: "sales_channel_id",
12326
+ render: ({ field }) => {
12327
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12328
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12329
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12330
+ Combobox,
12331
+ {
12332
+ options: salesChannels.options,
12333
+ fetchNextPage: salesChannels.fetchNextPage,
12334
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12335
+ searchValue: salesChannels.searchValue,
12336
+ onSearchValueChange: salesChannels.onSearchValueChange,
12337
+ placeholder: "Select sales channel",
12338
+ ...field
12339
+ }
12340
+ ) }),
12341
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12342
+ ] });
12343
+ }
12344
+ }
12345
+ );
12346
+ };
12347
+ const schema$2 = objectType({
12348
+ sales_channel_id: stringType().min(1)
12349
+ });
12350
12350
  const ShippingAddress = () => {
12351
12351
  const { id } = useParams();
12352
12352
  const { order, isPending, isError, error } = useOrder(id, {
@@ -13046,10 +13046,6 @@ const routeModule = {
13046
13046
  handle,
13047
13047
  loader,
13048
13048
  children: [
13049
- {
13050
- Component: BillingAddress,
13051
- path: "/draft-orders/:id/billing-address"
13052
- },
13053
13049
  {
13054
13050
  Component: CustomItems,
13055
13051
  path: "/draft-orders/:id/custom-items"
@@ -13062,6 +13058,10 @@ const routeModule = {
13062
13058
  Component: Items,
13063
13059
  path: "/draft-orders/:id/items"
13064
13060
  },
13061
+ {
13062
+ Component: BillingAddress,
13063
+ path: "/draft-orders/:id/billing-address"
13064
+ },
13065
13065
  {
13066
13066
  Component: Metadata,
13067
13067
  path: "/draft-orders/:id/metadata"
@@ -13070,14 +13070,14 @@ const routeModule = {
13070
13070
  Component: Promotions,
13071
13071
  path: "/draft-orders/:id/promotions"
13072
13072
  },
13073
- {
13074
- Component: SalesChannel,
13075
- path: "/draft-orders/:id/sales-channel"
13076
- },
13077
13073
  {
13078
13074
  Component: Shipping,
13079
13075
  path: "/draft-orders/:id/shipping"
13080
13076
  },
13077
+ {
13078
+ Component: SalesChannel,
13079
+ path: "/draft-orders/:id/sales-channel"
13080
+ },
13081
13081
  {
13082
13082
  Component: ShippingAddress,
13083
13083
  path: "/draft-orders/:id/shipping-address"