@medusajs/draft-order 2.11.4-preview-20251109120135 → 2.11.4-preview-20251109180126

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.
@@ -9568,6 +9568,217 @@ const ID = () => {
9568
9568
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9569
9569
  ] });
9570
9570
  };
9571
+ const BillingAddress = () => {
9572
+ const { id } = reactRouterDom.useParams();
9573
+ const { order, isPending, isError, error } = useOrder(id, {
9574
+ fields: "+billing_address"
9575
+ });
9576
+ if (isError) {
9577
+ throw error;
9578
+ }
9579
+ const isReady = !isPending && !!order;
9580
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9581
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9582
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9583
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9584
+ ] }),
9585
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9586
+ ] });
9587
+ };
9588
+ const BillingAddressForm = ({ order }) => {
9589
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9590
+ const form = reactHookForm.useForm({
9591
+ defaultValues: {
9592
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9593
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9594
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9595
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9596
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9597
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9598
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9599
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9600
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9601
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9602
+ },
9603
+ resolver: zod.zodResolver(schema$5)
9604
+ });
9605
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9606
+ const { handleSuccess } = useRouteModal();
9607
+ const onSubmit = form.handleSubmit(async (data) => {
9608
+ await mutateAsync(
9609
+ { billing_address: data },
9610
+ {
9611
+ onSuccess: () => {
9612
+ handleSuccess();
9613
+ },
9614
+ onError: (error) => {
9615
+ ui.toast.error(error.message);
9616
+ }
9617
+ }
9618
+ );
9619
+ });
9620
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9621
+ KeyboundForm,
9622
+ {
9623
+ className: "flex flex-1 flex-col overflow-hidden",
9624
+ onSubmit,
9625
+ children: [
9626
+ /* @__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: [
9627
+ /* @__PURE__ */ jsxRuntime.jsx(
9628
+ Form$2.Field,
9629
+ {
9630
+ control: form.control,
9631
+ name: "country_code",
9632
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9633
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9634
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9635
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9636
+ ] })
9637
+ }
9638
+ ),
9639
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9640
+ /* @__PURE__ */ jsxRuntime.jsx(
9641
+ Form$2.Field,
9642
+ {
9643
+ control: form.control,
9644
+ name: "first_name",
9645
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9646
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9647
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9648
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9649
+ ] })
9650
+ }
9651
+ ),
9652
+ /* @__PURE__ */ jsxRuntime.jsx(
9653
+ Form$2.Field,
9654
+ {
9655
+ control: form.control,
9656
+ name: "last_name",
9657
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9658
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9659
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9660
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9661
+ ] })
9662
+ }
9663
+ )
9664
+ ] }),
9665
+ /* @__PURE__ */ jsxRuntime.jsx(
9666
+ Form$2.Field,
9667
+ {
9668
+ control: form.control,
9669
+ name: "company",
9670
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9671
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9672
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9673
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9674
+ ] })
9675
+ }
9676
+ ),
9677
+ /* @__PURE__ */ jsxRuntime.jsx(
9678
+ Form$2.Field,
9679
+ {
9680
+ control: form.control,
9681
+ name: "address_1",
9682
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9683
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9684
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9685
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9686
+ ] })
9687
+ }
9688
+ ),
9689
+ /* @__PURE__ */ jsxRuntime.jsx(
9690
+ Form$2.Field,
9691
+ {
9692
+ control: form.control,
9693
+ name: "address_2",
9694
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9695
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9696
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9697
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9698
+ ] })
9699
+ }
9700
+ ),
9701
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9702
+ /* @__PURE__ */ jsxRuntime.jsx(
9703
+ Form$2.Field,
9704
+ {
9705
+ control: form.control,
9706
+ name: "postal_code",
9707
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9708
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9709
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9710
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9711
+ ] })
9712
+ }
9713
+ ),
9714
+ /* @__PURE__ */ jsxRuntime.jsx(
9715
+ Form$2.Field,
9716
+ {
9717
+ control: form.control,
9718
+ name: "city",
9719
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9720
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9721
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9722
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9723
+ ] })
9724
+ }
9725
+ )
9726
+ ] }),
9727
+ /* @__PURE__ */ jsxRuntime.jsx(
9728
+ Form$2.Field,
9729
+ {
9730
+ control: form.control,
9731
+ name: "province",
9732
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9733
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9734
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9735
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9736
+ ] })
9737
+ }
9738
+ ),
9739
+ /* @__PURE__ */ jsxRuntime.jsx(
9740
+ Form$2.Field,
9741
+ {
9742
+ control: form.control,
9743
+ name: "phone",
9744
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9745
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9746
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9747
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9748
+ ] })
9749
+ }
9750
+ )
9751
+ ] }) }),
9752
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9753
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9754
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9755
+ ] }) })
9756
+ ]
9757
+ }
9758
+ ) });
9759
+ };
9760
+ const schema$5 = addressSchema;
9761
+ const CustomItems = () => {
9762
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9763
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9764
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9765
+ ] });
9766
+ };
9767
+ const CustomItemsForm = () => {
9768
+ const form = reactHookForm.useForm({
9769
+ resolver: zod.zodResolver(schema$4)
9770
+ });
9771
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9772
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9773
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9774
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9775
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9776
+ ] }) })
9777
+ ] }) });
9778
+ };
9779
+ const schema$4 = objectType({
9780
+ email: stringType().email()
9781
+ });
9571
9782
  const Email = () => {
9572
9783
  const { id } = reactRouterDom.useParams();
9573
9784
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9590,7 +9801,7 @@ const EmailForm = ({ order }) => {
9590
9801
  defaultValues: {
9591
9802
  email: order.email ?? ""
9592
9803
  },
9593
- resolver: zod.zodResolver(schema$5)
9804
+ resolver: zod.zodResolver(schema$3)
9594
9805
  });
9595
9806
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9596
9807
  const { handleSuccess } = useRouteModal();
@@ -9633,7 +9844,7 @@ const EmailForm = ({ order }) => {
9633
9844
  }
9634
9845
  ) });
9635
9846
  };
9636
- const schema$5 = objectType({
9847
+ const schema$3 = objectType({
9637
9848
  email: stringType().email()
9638
9849
  });
9639
9850
  const NumberInput = React.forwardRef(
@@ -11265,7 +11476,7 @@ const SalesChannelForm = ({ order }) => {
11265
11476
  defaultValues: {
11266
11477
  sales_channel_id: order.sales_channel_id || ""
11267
11478
  },
11268
- resolver: zod.zodResolver(schema$4)
11479
+ resolver: zod.zodResolver(schema$2)
11269
11480
  });
11270
11481
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11271
11482
  const { handleSuccess } = useRouteModal();
@@ -11340,7 +11551,7 @@ const SalesChannelField = ({ control, order }) => {
11340
11551
  }
11341
11552
  );
11342
11553
  };
11343
- const schema$4 = objectType({
11554
+ const schema$2 = objectType({
11344
11555
  sales_channel_id: stringType().min(1)
11345
11556
  });
11346
11557
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12182,7 +12393,7 @@ const ShippingAddressForm = ({ order }) => {
12182
12393
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12183
12394
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12184
12395
  },
12185
- resolver: zod.zodResolver(schema$3)
12396
+ resolver: zod.zodResolver(schema$1)
12186
12397
  });
12187
12398
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12188
12399
  const { handleSuccess } = useRouteModal();
@@ -12352,7 +12563,7 @@ const ShippingAddressForm = ({ order }) => {
12352
12563
  }
12353
12564
  ) });
12354
12565
  };
12355
- const schema$3 = addressSchema;
12566
+ const schema$1 = addressSchema;
12356
12567
  const TransferOwnership = () => {
12357
12568
  const { id } = reactRouterDom.useParams();
12358
12569
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12376,7 +12587,7 @@ const TransferOwnershipForm = ({ order }) => {
12376
12587
  defaultValues: {
12377
12588
  customer_id: order.customer_id || ""
12378
12589
  },
12379
- resolver: zod.zodResolver(schema$2)
12590
+ resolver: zod.zodResolver(schema)
12380
12591
  });
12381
12592
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12382
12593
  const { handleSuccess } = useRouteModal();
@@ -12826,219 +13037,8 @@ const Illustration = () => {
12826
13037
  }
12827
13038
  );
12828
13039
  };
12829
- const schema$2 = objectType({
12830
- customer_id: stringType().min(1)
12831
- });
12832
- const BillingAddress = () => {
12833
- const { id } = reactRouterDom.useParams();
12834
- const { order, isPending, isError, error } = useOrder(id, {
12835
- fields: "+billing_address"
12836
- });
12837
- if (isError) {
12838
- throw error;
12839
- }
12840
- const isReady = !isPending && !!order;
12841
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12842
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12843
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12844
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12845
- ] }),
12846
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12847
- ] });
12848
- };
12849
- const BillingAddressForm = ({ order }) => {
12850
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12851
- const form = reactHookForm.useForm({
12852
- defaultValues: {
12853
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12854
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12855
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12856
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12857
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12858
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12859
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12860
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12861
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12862
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12863
- },
12864
- resolver: zod.zodResolver(schema$1)
12865
- });
12866
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12867
- const { handleSuccess } = useRouteModal();
12868
- const onSubmit = form.handleSubmit(async (data) => {
12869
- await mutateAsync(
12870
- { billing_address: data },
12871
- {
12872
- onSuccess: () => {
12873
- handleSuccess();
12874
- },
12875
- onError: (error) => {
12876
- ui.toast.error(error.message);
12877
- }
12878
- }
12879
- );
12880
- });
12881
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12882
- KeyboundForm,
12883
- {
12884
- className: "flex flex-1 flex-col overflow-hidden",
12885
- onSubmit,
12886
- children: [
12887
- /* @__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: [
12888
- /* @__PURE__ */ jsxRuntime.jsx(
12889
- Form$2.Field,
12890
- {
12891
- control: form.control,
12892
- name: "country_code",
12893
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12894
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12895
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12896
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12897
- ] })
12898
- }
12899
- ),
12900
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12901
- /* @__PURE__ */ jsxRuntime.jsx(
12902
- Form$2.Field,
12903
- {
12904
- control: form.control,
12905
- name: "first_name",
12906
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12907
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12908
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12909
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12910
- ] })
12911
- }
12912
- ),
12913
- /* @__PURE__ */ jsxRuntime.jsx(
12914
- Form$2.Field,
12915
- {
12916
- control: form.control,
12917
- name: "last_name",
12918
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12919
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12920
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12921
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12922
- ] })
12923
- }
12924
- )
12925
- ] }),
12926
- /* @__PURE__ */ jsxRuntime.jsx(
12927
- Form$2.Field,
12928
- {
12929
- control: form.control,
12930
- name: "company",
12931
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12932
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12933
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12934
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12935
- ] })
12936
- }
12937
- ),
12938
- /* @__PURE__ */ jsxRuntime.jsx(
12939
- Form$2.Field,
12940
- {
12941
- control: form.control,
12942
- name: "address_1",
12943
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12944
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12945
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12946
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12947
- ] })
12948
- }
12949
- ),
12950
- /* @__PURE__ */ jsxRuntime.jsx(
12951
- Form$2.Field,
12952
- {
12953
- control: form.control,
12954
- name: "address_2",
12955
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12956
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12957
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12958
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12959
- ] })
12960
- }
12961
- ),
12962
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12963
- /* @__PURE__ */ jsxRuntime.jsx(
12964
- Form$2.Field,
12965
- {
12966
- control: form.control,
12967
- name: "postal_code",
12968
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12969
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12970
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12971
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12972
- ] })
12973
- }
12974
- ),
12975
- /* @__PURE__ */ jsxRuntime.jsx(
12976
- Form$2.Field,
12977
- {
12978
- control: form.control,
12979
- name: "city",
12980
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12981
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12982
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12983
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12984
- ] })
12985
- }
12986
- )
12987
- ] }),
12988
- /* @__PURE__ */ jsxRuntime.jsx(
12989
- Form$2.Field,
12990
- {
12991
- control: form.control,
12992
- name: "province",
12993
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12994
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12995
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12996
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12997
- ] })
12998
- }
12999
- ),
13000
- /* @__PURE__ */ jsxRuntime.jsx(
13001
- Form$2.Field,
13002
- {
13003
- control: form.control,
13004
- name: "phone",
13005
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13006
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13007
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13008
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13009
- ] })
13010
- }
13011
- )
13012
- ] }) }),
13013
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13014
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13015
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13016
- ] }) })
13017
- ]
13018
- }
13019
- ) });
13020
- };
13021
- const schema$1 = addressSchema;
13022
- const CustomItems = () => {
13023
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
13024
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
13025
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
13026
- ] });
13027
- };
13028
- const CustomItemsForm = () => {
13029
- const form = reactHookForm.useForm({
13030
- resolver: zod.zodResolver(schema)
13031
- });
13032
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13033
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
13034
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13035
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13036
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
13037
- ] }) })
13038
- ] }) });
13039
- };
13040
13040
  const schema = objectType({
13041
- email: stringType().email()
13041
+ customer_id: stringType().min(1)
13042
13042
  });
13043
13043
  const widgetModule = { widgets: [] };
13044
13044
  const routeModule = {
@@ -13060,6 +13060,14 @@ const routeModule = {
13060
13060
  handle,
13061
13061
  loader,
13062
13062
  children: [
13063
+ {
13064
+ Component: BillingAddress,
13065
+ path: "/draft-orders/:id/billing-address"
13066
+ },
13067
+ {
13068
+ Component: CustomItems,
13069
+ path: "/draft-orders/:id/custom-items"
13070
+ },
13063
13071
  {
13064
13072
  Component: Email,
13065
13073
  path: "/draft-orders/:id/email"
@@ -13091,14 +13099,6 @@ const routeModule = {
13091
13099
  {
13092
13100
  Component: TransferOwnership,
13093
13101
  path: "/draft-orders/:id/transfer-ownership"
13094
- },
13095
- {
13096
- Component: BillingAddress,
13097
- path: "/draft-orders/:id/billing-address"
13098
- },
13099
- {
13100
- Component: CustomItems,
13101
- path: "/draft-orders/:id/custom-items"
13102
13102
  }
13103
13103
  ]
13104
13104
  }
@@ -9561,6 +9561,217 @@ const ID = () => {
9561
9561
  /* @__PURE__ */ jsx(Outlet, {})
9562
9562
  ] });
9563
9563
  };
9564
+ const BillingAddress = () => {
9565
+ const { id } = useParams();
9566
+ const { order, isPending, isError, error } = useOrder(id, {
9567
+ fields: "+billing_address"
9568
+ });
9569
+ if (isError) {
9570
+ throw error;
9571
+ }
9572
+ const isReady = !isPending && !!order;
9573
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9574
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9575
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9576
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9577
+ ] }),
9578
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9579
+ ] });
9580
+ };
9581
+ const BillingAddressForm = ({ order }) => {
9582
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9583
+ const form = useForm({
9584
+ defaultValues: {
9585
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9586
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9587
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9588
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9589
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9590
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9591
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9592
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9593
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9594
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9595
+ },
9596
+ resolver: zodResolver(schema$5)
9597
+ });
9598
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9599
+ const { handleSuccess } = useRouteModal();
9600
+ const onSubmit = form.handleSubmit(async (data) => {
9601
+ await mutateAsync(
9602
+ { billing_address: data },
9603
+ {
9604
+ onSuccess: () => {
9605
+ handleSuccess();
9606
+ },
9607
+ onError: (error) => {
9608
+ toast.error(error.message);
9609
+ }
9610
+ }
9611
+ );
9612
+ });
9613
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9614
+ KeyboundForm,
9615
+ {
9616
+ className: "flex flex-1 flex-col overflow-hidden",
9617
+ onSubmit,
9618
+ children: [
9619
+ /* @__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: [
9620
+ /* @__PURE__ */ jsx(
9621
+ Form$2.Field,
9622
+ {
9623
+ control: form.control,
9624
+ name: "country_code",
9625
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9626
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9627
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9628
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9629
+ ] })
9630
+ }
9631
+ ),
9632
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9633
+ /* @__PURE__ */ jsx(
9634
+ Form$2.Field,
9635
+ {
9636
+ control: form.control,
9637
+ name: "first_name",
9638
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9639
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9640
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9641
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9642
+ ] })
9643
+ }
9644
+ ),
9645
+ /* @__PURE__ */ jsx(
9646
+ Form$2.Field,
9647
+ {
9648
+ control: form.control,
9649
+ name: "last_name",
9650
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9651
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9652
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9653
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9654
+ ] })
9655
+ }
9656
+ )
9657
+ ] }),
9658
+ /* @__PURE__ */ jsx(
9659
+ Form$2.Field,
9660
+ {
9661
+ control: form.control,
9662
+ name: "company",
9663
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9664
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
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: "address_1",
9675
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9676
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9677
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9678
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9679
+ ] })
9680
+ }
9681
+ ),
9682
+ /* @__PURE__ */ jsx(
9683
+ Form$2.Field,
9684
+ {
9685
+ control: form.control,
9686
+ name: "address_2",
9687
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9688
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9689
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9690
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9691
+ ] })
9692
+ }
9693
+ ),
9694
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9695
+ /* @__PURE__ */ jsx(
9696
+ Form$2.Field,
9697
+ {
9698
+ control: form.control,
9699
+ name: "postal_code",
9700
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9701
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
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: "city",
9712
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9713
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9714
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9715
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9716
+ ] })
9717
+ }
9718
+ )
9719
+ ] }),
9720
+ /* @__PURE__ */ jsx(
9721
+ Form$2.Field,
9722
+ {
9723
+ control: form.control,
9724
+ name: "province",
9725
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9726
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
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: "phone",
9737
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9738
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9739
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9740
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9741
+ ] })
9742
+ }
9743
+ )
9744
+ ] }) }),
9745
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9746
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9747
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9748
+ ] }) })
9749
+ ]
9750
+ }
9751
+ ) });
9752
+ };
9753
+ const schema$5 = addressSchema;
9754
+ const CustomItems = () => {
9755
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9756
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9757
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9758
+ ] });
9759
+ };
9760
+ const CustomItemsForm = () => {
9761
+ const form = useForm({
9762
+ resolver: zodResolver(schema$4)
9763
+ });
9764
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9765
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9766
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9767
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9768
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9769
+ ] }) })
9770
+ ] }) });
9771
+ };
9772
+ const schema$4 = objectType({
9773
+ email: stringType().email()
9774
+ });
9564
9775
  const Email = () => {
9565
9776
  const { id } = useParams();
9566
9777
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9583,7 +9794,7 @@ const EmailForm = ({ order }) => {
9583
9794
  defaultValues: {
9584
9795
  email: order.email ?? ""
9585
9796
  },
9586
- resolver: zodResolver(schema$5)
9797
+ resolver: zodResolver(schema$3)
9587
9798
  });
9588
9799
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9589
9800
  const { handleSuccess } = useRouteModal();
@@ -9626,7 +9837,7 @@ const EmailForm = ({ order }) => {
9626
9837
  }
9627
9838
  ) });
9628
9839
  };
9629
- const schema$5 = objectType({
9840
+ const schema$3 = objectType({
9630
9841
  email: stringType().email()
9631
9842
  });
9632
9843
  const NumberInput = forwardRef(
@@ -11258,7 +11469,7 @@ const SalesChannelForm = ({ order }) => {
11258
11469
  defaultValues: {
11259
11470
  sales_channel_id: order.sales_channel_id || ""
11260
11471
  },
11261
- resolver: zodResolver(schema$4)
11472
+ resolver: zodResolver(schema$2)
11262
11473
  });
11263
11474
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11264
11475
  const { handleSuccess } = useRouteModal();
@@ -11333,7 +11544,7 @@ const SalesChannelField = ({ control, order }) => {
11333
11544
  }
11334
11545
  );
11335
11546
  };
11336
- const schema$4 = objectType({
11547
+ const schema$2 = objectType({
11337
11548
  sales_channel_id: stringType().min(1)
11338
11549
  });
11339
11550
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12175,7 +12386,7 @@ const ShippingAddressForm = ({ order }) => {
12175
12386
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12176
12387
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12177
12388
  },
12178
- resolver: zodResolver(schema$3)
12389
+ resolver: zodResolver(schema$1)
12179
12390
  });
12180
12391
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12181
12392
  const { handleSuccess } = useRouteModal();
@@ -12345,7 +12556,7 @@ const ShippingAddressForm = ({ order }) => {
12345
12556
  }
12346
12557
  ) });
12347
12558
  };
12348
- const schema$3 = addressSchema;
12559
+ const schema$1 = addressSchema;
12349
12560
  const TransferOwnership = () => {
12350
12561
  const { id } = useParams();
12351
12562
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12369,7 +12580,7 @@ const TransferOwnershipForm = ({ order }) => {
12369
12580
  defaultValues: {
12370
12581
  customer_id: order.customer_id || ""
12371
12582
  },
12372
- resolver: zodResolver(schema$2)
12583
+ resolver: zodResolver(schema)
12373
12584
  });
12374
12585
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12375
12586
  const { handleSuccess } = useRouteModal();
@@ -12819,219 +13030,8 @@ const Illustration = () => {
12819
13030
  }
12820
13031
  );
12821
13032
  };
12822
- const schema$2 = objectType({
12823
- customer_id: stringType().min(1)
12824
- });
12825
- const BillingAddress = () => {
12826
- const { id } = useParams();
12827
- const { order, isPending, isError, error } = useOrder(id, {
12828
- fields: "+billing_address"
12829
- });
12830
- if (isError) {
12831
- throw error;
12832
- }
12833
- const isReady = !isPending && !!order;
12834
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12835
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12836
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
12837
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12838
- ] }),
12839
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
12840
- ] });
12841
- };
12842
- const BillingAddressForm = ({ order }) => {
12843
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12844
- const form = useForm({
12845
- defaultValues: {
12846
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12847
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12848
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12849
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12850
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12851
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12852
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12853
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12854
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12855
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12856
- },
12857
- resolver: zodResolver(schema$1)
12858
- });
12859
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12860
- const { handleSuccess } = useRouteModal();
12861
- const onSubmit = form.handleSubmit(async (data) => {
12862
- await mutateAsync(
12863
- { billing_address: data },
12864
- {
12865
- onSuccess: () => {
12866
- handleSuccess();
12867
- },
12868
- onError: (error) => {
12869
- toast.error(error.message);
12870
- }
12871
- }
12872
- );
12873
- });
12874
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12875
- KeyboundForm,
12876
- {
12877
- className: "flex flex-1 flex-col overflow-hidden",
12878
- onSubmit,
12879
- children: [
12880
- /* @__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: [
12881
- /* @__PURE__ */ jsx(
12882
- Form$2.Field,
12883
- {
12884
- control: form.control,
12885
- name: "country_code",
12886
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12887
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12888
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12889
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12890
- ] })
12891
- }
12892
- ),
12893
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12894
- /* @__PURE__ */ jsx(
12895
- Form$2.Field,
12896
- {
12897
- control: form.control,
12898
- name: "first_name",
12899
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12900
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12901
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12902
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12903
- ] })
12904
- }
12905
- ),
12906
- /* @__PURE__ */ jsx(
12907
- Form$2.Field,
12908
- {
12909
- control: form.control,
12910
- name: "last_name",
12911
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12912
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12913
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12914
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12915
- ] })
12916
- }
12917
- )
12918
- ] }),
12919
- /* @__PURE__ */ jsx(
12920
- Form$2.Field,
12921
- {
12922
- control: form.control,
12923
- name: "company",
12924
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12925
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12926
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12927
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12928
- ] })
12929
- }
12930
- ),
12931
- /* @__PURE__ */ jsx(
12932
- Form$2.Field,
12933
- {
12934
- control: form.control,
12935
- name: "address_1",
12936
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12937
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12938
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12939
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12940
- ] })
12941
- }
12942
- ),
12943
- /* @__PURE__ */ jsx(
12944
- Form$2.Field,
12945
- {
12946
- control: form.control,
12947
- name: "address_2",
12948
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12949
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12950
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12951
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12952
- ] })
12953
- }
12954
- ),
12955
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12956
- /* @__PURE__ */ jsx(
12957
- Form$2.Field,
12958
- {
12959
- control: form.control,
12960
- name: "postal_code",
12961
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12962
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12963
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12964
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12965
- ] })
12966
- }
12967
- ),
12968
- /* @__PURE__ */ jsx(
12969
- Form$2.Field,
12970
- {
12971
- control: form.control,
12972
- name: "city",
12973
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12974
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12975
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12976
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12977
- ] })
12978
- }
12979
- )
12980
- ] }),
12981
- /* @__PURE__ */ jsx(
12982
- Form$2.Field,
12983
- {
12984
- control: form.control,
12985
- name: "province",
12986
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12987
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12988
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12989
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12990
- ] })
12991
- }
12992
- ),
12993
- /* @__PURE__ */ jsx(
12994
- Form$2.Field,
12995
- {
12996
- control: form.control,
12997
- name: "phone",
12998
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12999
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13000
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13001
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13002
- ] })
13003
- }
13004
- )
13005
- ] }) }),
13006
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13007
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13008
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13009
- ] }) })
13010
- ]
13011
- }
13012
- ) });
13013
- };
13014
- const schema$1 = addressSchema;
13015
- const CustomItems = () => {
13016
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13017
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
13018
- /* @__PURE__ */ jsx(CustomItemsForm, {})
13019
- ] });
13020
- };
13021
- const CustomItemsForm = () => {
13022
- const form = useForm({
13023
- resolver: zodResolver(schema)
13024
- });
13025
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13026
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
13027
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13028
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13029
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
13030
- ] }) })
13031
- ] }) });
13032
- };
13033
13033
  const schema = objectType({
13034
- email: stringType().email()
13034
+ customer_id: stringType().min(1)
13035
13035
  });
13036
13036
  const widgetModule = { widgets: [] };
13037
13037
  const routeModule = {
@@ -13053,6 +13053,14 @@ const routeModule = {
13053
13053
  handle,
13054
13054
  loader,
13055
13055
  children: [
13056
+ {
13057
+ Component: BillingAddress,
13058
+ path: "/draft-orders/:id/billing-address"
13059
+ },
13060
+ {
13061
+ Component: CustomItems,
13062
+ path: "/draft-orders/:id/custom-items"
13063
+ },
13056
13064
  {
13057
13065
  Component: Email,
13058
13066
  path: "/draft-orders/:id/email"
@@ -13084,14 +13092,6 @@ const routeModule = {
13084
13092
  {
13085
13093
  Component: TransferOwnership,
13086
13094
  path: "/draft-orders/:id/transfer-ownership"
13087
- },
13088
- {
13089
- Component: BillingAddress,
13090
- path: "/draft-orders/:id/billing-address"
13091
- },
13092
- {
13093
- Component: CustomItems,
13094
- path: "/draft-orders/:id/custom-items"
13095
13095
  }
13096
13096
  ]
13097
13097
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.11.4-preview-20251109120135",
3
+ "version": "2.11.4-preview-20251109180126",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "@ariakit/react": "^0.4.15",
38
38
  "@babel/runtime": "^7.26.10",
39
39
  "@hookform/resolvers": "3.4.2",
40
- "@medusajs/js-sdk": "2.11.4-preview-20251109120135",
40
+ "@medusajs/js-sdk": "2.11.4-preview-20251109180126",
41
41
  "@tanstack/react-query": "5.64.2",
42
42
  "@uiw/react-json-view": "^2.0.0-alpha.17",
43
43
  "date-fns": "^3.6.0",
@@ -48,22 +48,22 @@
48
48
  "react-hook-form": "7.49.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@medusajs/admin-sdk": "2.11.4-preview-20251109120135",
52
- "@medusajs/cli": "2.11.4-preview-20251109120135",
53
- "@medusajs/framework": "2.11.4-preview-20251109120135",
54
- "@medusajs/icons": "2.11.4-preview-20251109120135",
55
- "@medusajs/test-utils": "2.11.4-preview-20251109120135",
56
- "@medusajs/types": "2.11.4-preview-20251109120135",
57
- "@medusajs/ui": "4.0.28-preview-20251109120135",
58
- "@medusajs/ui-preset": "2.11.4-preview-20251109120135"
51
+ "@medusajs/admin-sdk": "2.11.4-preview-20251109180126",
52
+ "@medusajs/cli": "2.11.4-preview-20251109180126",
53
+ "@medusajs/framework": "2.11.4-preview-20251109180126",
54
+ "@medusajs/icons": "2.11.4-preview-20251109180126",
55
+ "@medusajs/test-utils": "2.11.4-preview-20251109180126",
56
+ "@medusajs/types": "2.11.4-preview-20251109180126",
57
+ "@medusajs/ui": "4.0.28-preview-20251109180126",
58
+ "@medusajs/ui-preset": "2.11.4-preview-20251109180126"
59
59
  },
60
60
  "peerDependencies": {
61
- "@medusajs/admin-sdk": "2.11.4-preview-20251109120135",
62
- "@medusajs/cli": "2.11.4-preview-20251109120135",
63
- "@medusajs/framework": "2.11.4-preview-20251109120135",
64
- "@medusajs/icons": "2.11.4-preview-20251109120135",
65
- "@medusajs/test-utils": "2.11.4-preview-20251109120135",
66
- "@medusajs/ui": "4.0.28-preview-20251109120135",
61
+ "@medusajs/admin-sdk": "2.11.4-preview-20251109180126",
62
+ "@medusajs/cli": "2.11.4-preview-20251109180126",
63
+ "@medusajs/framework": "2.11.4-preview-20251109180126",
64
+ "@medusajs/icons": "2.11.4-preview-20251109180126",
65
+ "@medusajs/test-utils": "2.11.4-preview-20251109180126",
66
+ "@medusajs/ui": "4.0.28-preview-20251109180126",
67
67
  "react": "^18.3.1",
68
68
  "react-dom": "^18.3.1",
69
69
  "react-router-dom": "6.20.1"