@medusajs/draft-order 2.11.3-preview-20251103090143 → 2.11.3-preview-20251103120146

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,196 @@ 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;
9575
9765
  const CustomItems = () => {
9576
9766
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9577
9767
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9580,7 +9770,7 @@ const CustomItems = () => {
9580
9770
  };
9581
9771
  const CustomItemsForm = () => {
9582
9772
  const form = reactHookForm.useForm({
9583
- resolver: zod.zodResolver(schema$5)
9773
+ resolver: zod.zodResolver(schema$4)
9584
9774
  });
9585
9775
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9586
9776
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9590,7 +9780,7 @@ const CustomItemsForm = () => {
9590
9780
  ] }) })
9591
9781
  ] }) });
9592
9782
  };
9593
- const schema$5 = objectType({
9783
+ const schema$4 = objectType({
9594
9784
  email: stringType().email()
9595
9785
  });
9596
9786
  const Email = () => {
@@ -9615,7 +9805,7 @@ const EmailForm = ({ order }) => {
9615
9805
  defaultValues: {
9616
9806
  email: order.email ?? ""
9617
9807
  },
9618
- resolver: zod.zodResolver(schema$4)
9808
+ resolver: zod.zodResolver(schema$3)
9619
9809
  });
9620
9810
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9621
9811
  const { handleSuccess } = useRouteModal();
@@ -9658,7 +9848,7 @@ const EmailForm = ({ order }) => {
9658
9848
  }
9659
9849
  ) });
9660
9850
  };
9661
- const schema$4 = objectType({
9851
+ const schema$3 = objectType({
9662
9852
  email: stringType().email()
9663
9853
  });
9664
9854
  const NumberInput = React.forwardRef(
@@ -10610,221 +10800,31 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
10610
10800
  Form$2.Field,
10611
10801
  {
10612
10802
  control: form.control,
10613
- name: "quantity",
10614
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
10615
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10616
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
10617
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
10618
- ] }),
10619
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex-1", children: [
10620
- /* @__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" }) }) }),
10621
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10622
- ] })
10623
- ] }) })
10624
- }
10625
- )
10626
- ] }) }) }),
10627
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10628
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10629
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
10630
- ] }) })
10631
- ] }) }) });
10632
- };
10633
- const customItemSchema = objectType({
10634
- title: stringType().min(1),
10635
- quantity: numberType(),
10636
- unit_price: unionType([numberType(), stringType()])
10637
- });
10638
- const BillingAddress = () => {
10639
- const { id } = reactRouterDom.useParams();
10640
- const { order, isPending, isError, error } = useOrder(id, {
10641
- fields: "+billing_address"
10642
- });
10643
- if (isError) {
10644
- throw error;
10645
- }
10646
- const isReady = !isPending && !!order;
10647
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10648
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10649
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
10650
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
10651
- ] }),
10652
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
10653
- ] });
10654
- };
10655
- const BillingAddressForm = ({ order }) => {
10656
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
10657
- const form = reactHookForm.useForm({
10658
- defaultValues: {
10659
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
10660
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
10661
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
10662
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
10663
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
10664
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
10665
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
10666
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
10667
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
10668
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
10669
- },
10670
- resolver: zod.zodResolver(schema$3)
10671
- });
10672
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10673
- const { handleSuccess } = useRouteModal();
10674
- const onSubmit = form.handleSubmit(async (data) => {
10675
- await mutateAsync(
10676
- { billing_address: data },
10677
- {
10678
- onSuccess: () => {
10679
- handleSuccess();
10680
- },
10681
- onError: (error) => {
10682
- ui.toast.error(error.message);
10683
- }
10684
- }
10685
- );
10686
- });
10687
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10688
- KeyboundForm,
10689
- {
10690
- className: "flex flex-1 flex-col overflow-hidden",
10691
- onSubmit,
10692
- children: [
10693
- /* @__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: [
10694
- /* @__PURE__ */ jsxRuntime.jsx(
10695
- Form$2.Field,
10696
- {
10697
- control: form.control,
10698
- name: "country_code",
10699
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10700
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
10701
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
10702
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10703
- ] })
10704
- }
10705
- ),
10706
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10707
- /* @__PURE__ */ jsxRuntime.jsx(
10708
- Form$2.Field,
10709
- {
10710
- control: form.control,
10711
- name: "first_name",
10712
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10713
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
10714
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10715
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10716
- ] })
10717
- }
10718
- ),
10719
- /* @__PURE__ */ jsxRuntime.jsx(
10720
- Form$2.Field,
10721
- {
10722
- control: form.control,
10723
- name: "last_name",
10724
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10725
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
10726
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10727
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10728
- ] })
10729
- }
10730
- )
10731
- ] }),
10732
- /* @__PURE__ */ jsxRuntime.jsx(
10733
- Form$2.Field,
10734
- {
10735
- control: form.control,
10736
- name: "company",
10737
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10738
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
10739
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10740
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10741
- ] })
10742
- }
10743
- ),
10744
- /* @__PURE__ */ jsxRuntime.jsx(
10745
- Form$2.Field,
10746
- {
10747
- control: form.control,
10748
- name: "address_1",
10749
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10750
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
10751
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10752
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10753
- ] })
10754
- }
10755
- ),
10756
- /* @__PURE__ */ jsxRuntime.jsx(
10757
- Form$2.Field,
10758
- {
10759
- control: form.control,
10760
- name: "address_2",
10761
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10762
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
10763
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10764
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10765
- ] })
10766
- }
10767
- ),
10768
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10769
- /* @__PURE__ */ jsxRuntime.jsx(
10770
- Form$2.Field,
10771
- {
10772
- control: form.control,
10773
- name: "postal_code",
10774
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10775
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
10776
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10777
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10778
- ] })
10779
- }
10780
- ),
10781
- /* @__PURE__ */ jsxRuntime.jsx(
10782
- Form$2.Field,
10783
- {
10784
- control: form.control,
10785
- name: "city",
10786
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10787
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
10788
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10789
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10790
- ] })
10791
- }
10792
- )
10793
- ] }),
10794
- /* @__PURE__ */ jsxRuntime.jsx(
10795
- Form$2.Field,
10796
- {
10797
- control: form.control,
10798
- name: "province",
10799
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10800
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
10801
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10802
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10803
- ] })
10804
- }
10805
- ),
10806
- /* @__PURE__ */ jsxRuntime.jsx(
10807
- Form$2.Field,
10808
- {
10809
- control: form.control,
10810
- name: "phone",
10811
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10812
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
10813
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10814
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10815
- ] })
10816
- }
10817
- )
10818
- ] }) }),
10819
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10820
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10821
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10822
- ] }) })
10823
- ]
10824
- }
10825
- ) });
10803
+ name: "quantity",
10804
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
10805
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10806
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
10807
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
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" }) }) }),
10811
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10812
+ ] })
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
+ ] }) }) });
10826
10822
  };
10827
- const schema$3 = addressSchema;
10823
+ const customItemSchema = objectType({
10824
+ title: stringType().min(1),
10825
+ quantity: numberType(),
10826
+ unit_price: unionType([numberType(), stringType()])
10827
+ });
10828
10828
  const InlineTip = React.forwardRef(
10829
10829
  ({ variant = "tip", label, className, children, ...props }, ref) => {
10830
10830
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -11452,112 +11452,6 @@ function getPromotionIds(items, shippingMethods) {
11452
11452
  }
11453
11453
  return Array.from(promotionIds);
11454
11454
  }
11455
- const SalesChannel = () => {
11456
- const { id } = reactRouterDom.useParams();
11457
- const { draft_order, isPending, isError, error } = useDraftOrder(
11458
- id,
11459
- {
11460
- fields: "+sales_channel_id"
11461
- },
11462
- {
11463
- enabled: !!id
11464
- }
11465
- );
11466
- if (isError) {
11467
- throw error;
11468
- }
11469
- const ISrEADY = !!draft_order && !isPending;
11470
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11471
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11472
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11473
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11474
- ] }),
11475
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11476
- ] });
11477
- };
11478
- const SalesChannelForm = ({ order }) => {
11479
- const form = reactHookForm.useForm({
11480
- defaultValues: {
11481
- sales_channel_id: order.sales_channel_id || ""
11482
- },
11483
- resolver: zod.zodResolver(schema$2)
11484
- });
11485
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11486
- const { handleSuccess } = useRouteModal();
11487
- const onSubmit = form.handleSubmit(async (data) => {
11488
- await mutateAsync(
11489
- {
11490
- sales_channel_id: data.sales_channel_id
11491
- },
11492
- {
11493
- onSuccess: () => {
11494
- ui.toast.success("Sales channel updated");
11495
- handleSuccess();
11496
- },
11497
- onError: (error) => {
11498
- ui.toast.error(error.message);
11499
- }
11500
- }
11501
- );
11502
- });
11503
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11504
- KeyboundForm,
11505
- {
11506
- className: "flex flex-1 flex-col overflow-hidden",
11507
- onSubmit,
11508
- children: [
11509
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11510
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11511
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11512
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11513
- ] }) })
11514
- ]
11515
- }
11516
- ) });
11517
- };
11518
- const SalesChannelField = ({ control, order }) => {
11519
- const salesChannels = useComboboxData({
11520
- queryFn: async (params) => {
11521
- return await sdk.admin.salesChannel.list(params);
11522
- },
11523
- queryKey: ["sales-channels"],
11524
- getOptions: (data) => {
11525
- return data.sales_channels.map((salesChannel) => ({
11526
- label: salesChannel.name,
11527
- value: salesChannel.id
11528
- }));
11529
- },
11530
- defaultValue: order.sales_channel_id || void 0
11531
- });
11532
- return /* @__PURE__ */ jsxRuntime.jsx(
11533
- Form$2.Field,
11534
- {
11535
- control,
11536
- name: "sales_channel_id",
11537
- render: ({ field }) => {
11538
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11539
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11540
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11541
- Combobox,
11542
- {
11543
- options: salesChannels.options,
11544
- fetchNextPage: salesChannels.fetchNextPage,
11545
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11546
- searchValue: salesChannels.searchValue,
11547
- onSearchValueChange: salesChannels.onSearchValueChange,
11548
- placeholder: "Select sales channel",
11549
- ...field
11550
- }
11551
- ) }),
11552
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11553
- ] });
11554
- }
11555
- }
11556
- );
11557
- };
11558
- const schema$2 = objectType({
11559
- sales_channel_id: stringType().min(1)
11560
- });
11561
11455
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11562
11456
  const Shipping = () => {
11563
11457
  var _a;
@@ -12397,7 +12291,7 @@ const ShippingAddressForm = ({ order }) => {
12397
12291
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12398
12292
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12399
12293
  },
12400
- resolver: zod.zodResolver(schema$1)
12294
+ resolver: zod.zodResolver(schema$2)
12401
12295
  });
12402
12296
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12403
12297
  const { handleSuccess } = useRouteModal();
@@ -12567,7 +12461,7 @@ const ShippingAddressForm = ({ order }) => {
12567
12461
  }
12568
12462
  ) });
12569
12463
  };
12570
- const schema$1 = addressSchema;
12464
+ const schema$2 = addressSchema;
12571
12465
  const TransferOwnership = () => {
12572
12466
  const { id } = reactRouterDom.useParams();
12573
12467
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12591,7 +12485,7 @@ const TransferOwnershipForm = ({ order }) => {
12591
12485
  defaultValues: {
12592
12486
  customer_id: order.customer_id || ""
12593
12487
  },
12594
- resolver: zod.zodResolver(schema)
12488
+ resolver: zod.zodResolver(schema$1)
12595
12489
  });
12596
12490
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12597
12491
  const { handleSuccess } = useRouteModal();
@@ -13041,9 +12935,115 @@ const Illustration = () => {
13041
12935
  }
13042
12936
  );
13043
12937
  };
13044
- const schema = objectType({
12938
+ const schema$1 = objectType({
13045
12939
  customer_id: stringType().min(1)
13046
12940
  });
12941
+ const SalesChannel = () => {
12942
+ const { id } = reactRouterDom.useParams();
12943
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12944
+ id,
12945
+ {
12946
+ fields: "+sales_channel_id"
12947
+ },
12948
+ {
12949
+ enabled: !!id
12950
+ }
12951
+ );
12952
+ if (isError) {
12953
+ throw error;
12954
+ }
12955
+ const ISrEADY = !!draft_order && !isPending;
12956
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12957
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12958
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12959
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12960
+ ] }),
12961
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12962
+ ] });
12963
+ };
12964
+ const SalesChannelForm = ({ order }) => {
12965
+ const form = reactHookForm.useForm({
12966
+ defaultValues: {
12967
+ sales_channel_id: order.sales_channel_id || ""
12968
+ },
12969
+ resolver: zod.zodResolver(schema)
12970
+ });
12971
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12972
+ const { handleSuccess } = useRouteModal();
12973
+ const onSubmit = form.handleSubmit(async (data) => {
12974
+ await mutateAsync(
12975
+ {
12976
+ sales_channel_id: data.sales_channel_id
12977
+ },
12978
+ {
12979
+ onSuccess: () => {
12980
+ ui.toast.success("Sales channel updated");
12981
+ handleSuccess();
12982
+ },
12983
+ onError: (error) => {
12984
+ ui.toast.error(error.message);
12985
+ }
12986
+ }
12987
+ );
12988
+ });
12989
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12990
+ KeyboundForm,
12991
+ {
12992
+ className: "flex flex-1 flex-col overflow-hidden",
12993
+ onSubmit,
12994
+ children: [
12995
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12996
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12997
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12998
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12999
+ ] }) })
13000
+ ]
13001
+ }
13002
+ ) });
13003
+ };
13004
+ const SalesChannelField = ({ control, order }) => {
13005
+ const salesChannels = useComboboxData({
13006
+ queryFn: async (params) => {
13007
+ return await sdk.admin.salesChannel.list(params);
13008
+ },
13009
+ queryKey: ["sales-channels"],
13010
+ getOptions: (data) => {
13011
+ return data.sales_channels.map((salesChannel) => ({
13012
+ label: salesChannel.name,
13013
+ value: salesChannel.id
13014
+ }));
13015
+ },
13016
+ defaultValue: order.sales_channel_id || void 0
13017
+ });
13018
+ return /* @__PURE__ */ jsxRuntime.jsx(
13019
+ Form$2.Field,
13020
+ {
13021
+ control,
13022
+ name: "sales_channel_id",
13023
+ render: ({ field }) => {
13024
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13025
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
13026
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
13027
+ Combobox,
13028
+ {
13029
+ options: salesChannels.options,
13030
+ fetchNextPage: salesChannels.fetchNextPage,
13031
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
13032
+ searchValue: salesChannels.searchValue,
13033
+ onSearchValueChange: salesChannels.onSearchValueChange,
13034
+ placeholder: "Select sales channel",
13035
+ ...field
13036
+ }
13037
+ ) }),
13038
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13039
+ ] });
13040
+ }
13041
+ }
13042
+ );
13043
+ };
13044
+ const schema = objectType({
13045
+ sales_channel_id: stringType().min(1)
13046
+ });
13047
13047
  const widgetModule = { widgets: [] };
13048
13048
  const routeModule = {
13049
13049
  routes: [
@@ -13064,6 +13064,10 @@ const routeModule = {
13064
13064
  handle,
13065
13065
  loader,
13066
13066
  children: [
13067
+ {
13068
+ Component: BillingAddress,
13069
+ path: "/draft-orders/:id/billing-address"
13070
+ },
13067
13071
  {
13068
13072
  Component: CustomItems,
13069
13073
  path: "/draft-orders/:id/custom-items"
@@ -13076,10 +13080,6 @@ const routeModule = {
13076
13080
  Component: Items,
13077
13081
  path: "/draft-orders/:id/items"
13078
13082
  },
13079
- {
13080
- Component: BillingAddress,
13081
- path: "/draft-orders/:id/billing-address"
13082
- },
13083
13083
  {
13084
13084
  Component: Metadata,
13085
13085
  path: "/draft-orders/:id/metadata"
@@ -13088,10 +13088,6 @@ const routeModule = {
13088
13088
  Component: Promotions,
13089
13089
  path: "/draft-orders/:id/promotions"
13090
13090
  },
13091
- {
13092
- Component: SalesChannel,
13093
- path: "/draft-orders/:id/sales-channel"
13094
- },
13095
13091
  {
13096
13092
  Component: Shipping,
13097
13093
  path: "/draft-orders/:id/shipping"
@@ -13103,6 +13099,10 @@ const routeModule = {
13103
13099
  {
13104
13100
  Component: TransferOwnership,
13105
13101
  path: "/draft-orders/:id/transfer-ownership"
13102
+ },
13103
+ {
13104
+ Component: SalesChannel,
13105
+ path: "/draft-orders/:id/sales-channel"
13106
13106
  }
13107
13107
  ]
13108
13108
  }