@medusajs/draft-order 2.11.0-snapshot-20251020120939 → 2.11.1-snapshot-20251021080449

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.
@@ -9571,196 +9571,6 @@ const ID = () => {
9571
9571
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9572
9572
  ] });
9573
9573
  };
9574
- const BillingAddress = () => {
9575
- const { id } = reactRouterDom.useParams();
9576
- const { order, isPending, isError, error } = useOrder(id, {
9577
- fields: "+billing_address"
9578
- });
9579
- if (isError) {
9580
- throw error;
9581
- }
9582
- const isReady = !isPending && !!order;
9583
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9584
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9585
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9586
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9587
- ] }),
9588
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9589
- ] });
9590
- };
9591
- const BillingAddressForm = ({ order }) => {
9592
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9593
- const form = reactHookForm.useForm({
9594
- defaultValues: {
9595
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9596
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9597
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9598
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9599
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9600
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9601
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9602
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9603
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9604
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9605
- },
9606
- resolver: zod.zodResolver(schema$5)
9607
- });
9608
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9609
- const { handleSuccess } = useRouteModal();
9610
- const onSubmit = form.handleSubmit(async (data) => {
9611
- await mutateAsync(
9612
- { billing_address: data },
9613
- {
9614
- onSuccess: () => {
9615
- handleSuccess();
9616
- },
9617
- onError: (error) => {
9618
- ui.toast.error(error.message);
9619
- }
9620
- }
9621
- );
9622
- });
9623
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9624
- KeyboundForm,
9625
- {
9626
- className: "flex flex-1 flex-col overflow-hidden",
9627
- onSubmit,
9628
- children: [
9629
- /* @__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: [
9630
- /* @__PURE__ */ jsxRuntime.jsx(
9631
- Form$2.Field,
9632
- {
9633
- control: form.control,
9634
- name: "country_code",
9635
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9636
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9637
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9638
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9639
- ] })
9640
- }
9641
- ),
9642
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9643
- /* @__PURE__ */ jsxRuntime.jsx(
9644
- Form$2.Field,
9645
- {
9646
- control: form.control,
9647
- name: "first_name",
9648
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9649
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9650
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9651
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9652
- ] })
9653
- }
9654
- ),
9655
- /* @__PURE__ */ jsxRuntime.jsx(
9656
- Form$2.Field,
9657
- {
9658
- control: form.control,
9659
- name: "last_name",
9660
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9661
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9662
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9663
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9664
- ] })
9665
- }
9666
- )
9667
- ] }),
9668
- /* @__PURE__ */ jsxRuntime.jsx(
9669
- Form$2.Field,
9670
- {
9671
- control: form.control,
9672
- name: "company",
9673
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9674
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9675
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9676
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9677
- ] })
9678
- }
9679
- ),
9680
- /* @__PURE__ */ jsxRuntime.jsx(
9681
- Form$2.Field,
9682
- {
9683
- control: form.control,
9684
- name: "address_1",
9685
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9686
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9687
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9688
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9689
- ] })
9690
- }
9691
- ),
9692
- /* @__PURE__ */ jsxRuntime.jsx(
9693
- Form$2.Field,
9694
- {
9695
- control: form.control,
9696
- name: "address_2",
9697
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9698
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9699
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9700
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9701
- ] })
9702
- }
9703
- ),
9704
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9705
- /* @__PURE__ */ jsxRuntime.jsx(
9706
- Form$2.Field,
9707
- {
9708
- control: form.control,
9709
- name: "postal_code",
9710
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9711
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9712
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9713
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9714
- ] })
9715
- }
9716
- ),
9717
- /* @__PURE__ */ jsxRuntime.jsx(
9718
- Form$2.Field,
9719
- {
9720
- control: form.control,
9721
- name: "city",
9722
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9723
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9724
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9725
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9726
- ] })
9727
- }
9728
- )
9729
- ] }),
9730
- /* @__PURE__ */ jsxRuntime.jsx(
9731
- Form$2.Field,
9732
- {
9733
- control: form.control,
9734
- name: "province",
9735
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9736
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9737
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9738
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9739
- ] })
9740
- }
9741
- ),
9742
- /* @__PURE__ */ jsxRuntime.jsx(
9743
- Form$2.Field,
9744
- {
9745
- control: form.control,
9746
- name: "phone",
9747
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9748
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9749
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9750
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9751
- ] })
9752
- }
9753
- )
9754
- ] }) }),
9755
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9756
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9757
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9758
- ] }) })
9759
- ]
9760
- }
9761
- ) });
9762
- };
9763
- const schema$5 = addressSchema;
9764
9574
  const CustomItems = () => {
9765
9575
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9766
9576
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9769,7 +9579,7 @@ const CustomItems = () => {
9769
9579
  };
9770
9580
  const CustomItemsForm = () => {
9771
9581
  const form = reactHookForm.useForm({
9772
- resolver: zod.zodResolver(schema$4)
9582
+ resolver: zod.zodResolver(schema$5)
9773
9583
  });
9774
9584
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9775
9585
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9779,7 +9589,7 @@ const CustomItemsForm = () => {
9779
9589
  ] }) })
9780
9590
  ] }) });
9781
9591
  };
9782
- const schema$4 = objectType({
9592
+ const schema$5 = objectType({
9783
9593
  email: stringType().email()
9784
9594
  });
9785
9595
  const Email = () => {
@@ -9804,7 +9614,7 @@ const EmailForm = ({ order }) => {
9804
9614
  defaultValues: {
9805
9615
  email: order.email ?? ""
9806
9616
  },
9807
- resolver: zod.zodResolver(schema$3)
9617
+ resolver: zod.zodResolver(schema$4)
9808
9618
  });
9809
9619
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9810
9620
  const { handleSuccess } = useRouteModal();
@@ -9847,7 +9657,7 @@ const EmailForm = ({ order }) => {
9847
9657
  }
9848
9658
  ) });
9849
9659
  };
9850
- const schema$3 = objectType({
9660
+ const schema$4 = objectType({
9851
9661
  email: stringType().email()
9852
9662
  });
9853
9663
  const NumberInput = React.forwardRef(
@@ -10824,283 +10634,6 @@ const customItemSchema = objectType({
10824
10634
  quantity: numberType(),
10825
10635
  unit_price: unionType([numberType(), stringType()])
10826
10636
  });
10827
- const PROMOTION_QUERY_KEY = "promotions";
10828
- const promotionsQueryKeys = {
10829
- list: (query2) => [
10830
- PROMOTION_QUERY_KEY,
10831
- query2 ? query2 : void 0
10832
- ],
10833
- detail: (id, query2) => [
10834
- PROMOTION_QUERY_KEY,
10835
- id,
10836
- query2 ? query2 : void 0
10837
- ]
10838
- };
10839
- const usePromotions = (query2, options) => {
10840
- const { data, ...rest } = reactQuery.useQuery({
10841
- queryKey: promotionsQueryKeys.list(query2),
10842
- queryFn: async () => sdk.admin.promotion.list(query2),
10843
- ...options
10844
- });
10845
- return { ...data, ...rest };
10846
- };
10847
- const Promotions = () => {
10848
- const { id } = reactRouterDom.useParams();
10849
- const {
10850
- order: preview,
10851
- isError: isPreviewError,
10852
- error: previewError
10853
- } = useOrderPreview(id, void 0);
10854
- useInitiateOrderEdit({ preview });
10855
- const { onCancel } = useCancelOrderEdit({ preview });
10856
- if (isPreviewError) {
10857
- throw previewError;
10858
- }
10859
- const isReady = !!preview;
10860
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
10861
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
10862
- isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
10863
- ] });
10864
- };
10865
- const PromotionForm = ({ preview }) => {
10866
- const { items, shipping_methods } = preview;
10867
- const [isSubmitting, setIsSubmitting] = React.useState(false);
10868
- const [comboboxValue, setComboboxValue] = React.useState("");
10869
- const { handleSuccess } = useRouteModal();
10870
- const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
10871
- const promoIds = getPromotionIds(items, shipping_methods);
10872
- const { promotions, isPending, isError, error } = usePromotions(
10873
- {
10874
- id: promoIds
10875
- },
10876
- {
10877
- enabled: !!promoIds.length
10878
- }
10879
- );
10880
- const comboboxData = useComboboxData({
10881
- queryKey: ["promotions", "combobox", promoIds],
10882
- queryFn: async (params) => {
10883
- return await sdk.admin.promotion.list({
10884
- ...params,
10885
- id: {
10886
- $nin: promoIds
10887
- }
10888
- });
10889
- },
10890
- getOptions: (data) => {
10891
- return data.promotions.map((promotion) => ({
10892
- label: promotion.code,
10893
- value: promotion.code
10894
- }));
10895
- }
10896
- });
10897
- const add = async (value) => {
10898
- if (!value) {
10899
- return;
10900
- }
10901
- addPromotions(
10902
- {
10903
- promo_codes: [value]
10904
- },
10905
- {
10906
- onError: (e) => {
10907
- ui.toast.error(e.message);
10908
- comboboxData.onSearchValueChange("");
10909
- setComboboxValue("");
10910
- },
10911
- onSuccess: () => {
10912
- comboboxData.onSearchValueChange("");
10913
- setComboboxValue("");
10914
- }
10915
- }
10916
- );
10917
- };
10918
- const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
10919
- const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
10920
- const onSubmit = async () => {
10921
- setIsSubmitting(true);
10922
- let requestSucceeded = false;
10923
- await requestOrderEdit(void 0, {
10924
- onError: (e) => {
10925
- ui.toast.error(e.message);
10926
- },
10927
- onSuccess: () => {
10928
- requestSucceeded = true;
10929
- }
10930
- });
10931
- if (!requestSucceeded) {
10932
- setIsSubmitting(false);
10933
- return;
10934
- }
10935
- await confirmOrderEdit(void 0, {
10936
- onError: (e) => {
10937
- ui.toast.error(e.message);
10938
- },
10939
- onSuccess: () => {
10940
- handleSuccess();
10941
- },
10942
- onSettled: () => {
10943
- setIsSubmitting(false);
10944
- }
10945
- });
10946
- };
10947
- if (isError) {
10948
- throw error;
10949
- }
10950
- return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
10951
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
10952
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
10953
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
10954
- /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
10955
- /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
10956
- ] }),
10957
- /* @__PURE__ */ jsxRuntime.jsx(
10958
- Combobox,
10959
- {
10960
- id: "promotion-combobox",
10961
- "aria-describedby": "promotion-combobox-hint",
10962
- isFetchingNextPage: comboboxData.isFetchingNextPage,
10963
- fetchNextPage: comboboxData.fetchNextPage,
10964
- options: comboboxData.options,
10965
- onSearchValueChange: comboboxData.onSearchValueChange,
10966
- searchValue: comboboxData.searchValue,
10967
- disabled: comboboxData.disabled || isAddingPromotions,
10968
- onChange: add,
10969
- value: comboboxValue
10970
- }
10971
- )
10972
- ] }),
10973
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
10974
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
10975
- PromotionItem,
10976
- {
10977
- promotion,
10978
- orderId: preview.id,
10979
- isLoading: isPending
10980
- },
10981
- promotion.id
10982
- )) })
10983
- ] }) }),
10984
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10985
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10986
- /* @__PURE__ */ jsxRuntime.jsx(
10987
- ui.Button,
10988
- {
10989
- size: "small",
10990
- type: "submit",
10991
- isLoading: isSubmitting || isAddingPromotions,
10992
- children: "Save"
10993
- }
10994
- )
10995
- ] }) })
10996
- ] });
10997
- };
10998
- const PromotionItem = ({
10999
- promotion,
11000
- orderId,
11001
- isLoading
11002
- }) => {
11003
- var _a;
11004
- const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
11005
- const onRemove = async () => {
11006
- removePromotions(
11007
- {
11008
- promo_codes: [promotion.code]
11009
- },
11010
- {
11011
- onError: (e) => {
11012
- ui.toast.error(e.message);
11013
- }
11014
- }
11015
- );
11016
- };
11017
- const displayValue = getDisplayValue(promotion);
11018
- return /* @__PURE__ */ jsxRuntime.jsxs(
11019
- "div",
11020
- {
11021
- className: ui.clx(
11022
- "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
11023
- {
11024
- "animate-pulse": isLoading
11025
- }
11026
- ),
11027
- children: [
11028
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11029
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
11030
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
11031
- displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
11032
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
11033
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
11034
- ] }),
11035
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
11036
- ] })
11037
- ] }),
11038
- /* @__PURE__ */ jsxRuntime.jsx(
11039
- ui.IconButton,
11040
- {
11041
- size: "small",
11042
- type: "button",
11043
- variant: "transparent",
11044
- onClick: onRemove,
11045
- isLoading: isPending || isLoading,
11046
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
11047
- }
11048
- )
11049
- ]
11050
- },
11051
- promotion.id
11052
- );
11053
- };
11054
- function getDisplayValue(promotion) {
11055
- var _a, _b, _c, _d;
11056
- const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
11057
- if (!value) {
11058
- return null;
11059
- }
11060
- if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
11061
- const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
11062
- if (!currency) {
11063
- return null;
11064
- }
11065
- return getLocaleAmount(value, currency);
11066
- } else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
11067
- return formatPercentage(value);
11068
- }
11069
- return null;
11070
- }
11071
- const formatter = new Intl.NumberFormat([], {
11072
- style: "percent",
11073
- minimumFractionDigits: 2
11074
- });
11075
- const formatPercentage = (value, isPercentageValue = false) => {
11076
- let val = value || 0;
11077
- if (!isPercentageValue) {
11078
- val = val / 100;
11079
- }
11080
- return formatter.format(val);
11081
- };
11082
- function getPromotionIds(items, shippingMethods) {
11083
- const promotionIds = /* @__PURE__ */ new Set();
11084
- for (const item of items) {
11085
- if (item.adjustments) {
11086
- for (const adjustment of item.adjustments) {
11087
- if (adjustment.promotion_id) {
11088
- promotionIds.add(adjustment.promotion_id);
11089
- }
11090
- }
11091
- }
11092
- }
11093
- for (const shippingMethod of shippingMethods) {
11094
- if (shippingMethod.adjustments) {
11095
- for (const adjustment of shippingMethod.adjustments) {
11096
- if (adjustment.promotion_id) {
11097
- promotionIds.add(adjustment.promotion_id);
11098
- }
11099
- }
11100
- }
11101
- }
11102
- return Array.from(promotionIds);
11103
- }
11104
10637
  const InlineTip = React.forwardRef(
11105
10638
  ({ variant = "tip", label, className, children, ...props }, ref) => {
11106
10639
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -11426,30 +10959,307 @@ function parseValues(values) {
11426
10959
  update[key] = value;
11427
10960
  return;
11428
10961
  }
11429
- key = key.trim();
11430
- value = value.trim();
11431
- if (value === "true") {
11432
- update[key] = true;
11433
- } else if (value === "false") {
11434
- update[key] = false;
11435
- } else {
11436
- const parsedNumber = parseFloat(value);
11437
- if (!isNaN(parsedNumber)) {
11438
- update[key] = parsedNumber;
11439
- } else {
11440
- update[key] = value;
10962
+ key = key.trim();
10963
+ value = value.trim();
10964
+ if (value === "true") {
10965
+ update[key] = true;
10966
+ } else if (value === "false") {
10967
+ update[key] = false;
10968
+ } else {
10969
+ const parsedNumber = parseFloat(value);
10970
+ if (!isNaN(parsedNumber)) {
10971
+ update[key] = parsedNumber;
10972
+ } else {
10973
+ update[key] = value;
10974
+ }
10975
+ }
10976
+ });
10977
+ return update;
10978
+ }
10979
+ function getHasUneditableRows(metadata) {
10980
+ if (!metadata) {
10981
+ return false;
10982
+ }
10983
+ return Object.values(metadata).some(
10984
+ (value) => !EDITABLE_TYPES.includes(typeof value)
10985
+ );
10986
+ }
10987
+ const PROMOTION_QUERY_KEY = "promotions";
10988
+ const promotionsQueryKeys = {
10989
+ list: (query2) => [
10990
+ PROMOTION_QUERY_KEY,
10991
+ query2 ? query2 : void 0
10992
+ ],
10993
+ detail: (id, query2) => [
10994
+ PROMOTION_QUERY_KEY,
10995
+ id,
10996
+ query2 ? query2 : void 0
10997
+ ]
10998
+ };
10999
+ const usePromotions = (query2, options) => {
11000
+ const { data, ...rest } = reactQuery.useQuery({
11001
+ queryKey: promotionsQueryKeys.list(query2),
11002
+ queryFn: async () => sdk.admin.promotion.list(query2),
11003
+ ...options
11004
+ });
11005
+ return { ...data, ...rest };
11006
+ };
11007
+ const Promotions = () => {
11008
+ const { id } = reactRouterDom.useParams();
11009
+ const {
11010
+ order: preview,
11011
+ isError: isPreviewError,
11012
+ error: previewError
11013
+ } = useOrderPreview(id, void 0);
11014
+ useInitiateOrderEdit({ preview });
11015
+ const { onCancel } = useCancelOrderEdit({ preview });
11016
+ if (isPreviewError) {
11017
+ throw previewError;
11018
+ }
11019
+ const isReady = !!preview;
11020
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
11021
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
11022
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
11023
+ ] });
11024
+ };
11025
+ const PromotionForm = ({ preview }) => {
11026
+ const { items, shipping_methods } = preview;
11027
+ const [isSubmitting, setIsSubmitting] = React.useState(false);
11028
+ const [comboboxValue, setComboboxValue] = React.useState("");
11029
+ const { handleSuccess } = useRouteModal();
11030
+ const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
11031
+ const promoIds = getPromotionIds(items, shipping_methods);
11032
+ const { promotions, isPending, isError, error } = usePromotions(
11033
+ {
11034
+ id: promoIds
11035
+ },
11036
+ {
11037
+ enabled: !!promoIds.length
11038
+ }
11039
+ );
11040
+ const comboboxData = useComboboxData({
11041
+ queryKey: ["promotions", "combobox", promoIds],
11042
+ queryFn: async (params) => {
11043
+ return await sdk.admin.promotion.list({
11044
+ ...params,
11045
+ id: {
11046
+ $nin: promoIds
11047
+ }
11048
+ });
11049
+ },
11050
+ getOptions: (data) => {
11051
+ return data.promotions.map((promotion) => ({
11052
+ label: promotion.code,
11053
+ value: promotion.code
11054
+ }));
11055
+ }
11056
+ });
11057
+ const add = async (value) => {
11058
+ if (!value) {
11059
+ return;
11060
+ }
11061
+ addPromotions(
11062
+ {
11063
+ promo_codes: [value]
11064
+ },
11065
+ {
11066
+ onError: (e) => {
11067
+ ui.toast.error(e.message);
11068
+ comboboxData.onSearchValueChange("");
11069
+ setComboboxValue("");
11070
+ },
11071
+ onSuccess: () => {
11072
+ comboboxData.onSearchValueChange("");
11073
+ setComboboxValue("");
11074
+ }
11075
+ }
11076
+ );
11077
+ };
11078
+ const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
11079
+ const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
11080
+ const onSubmit = async () => {
11081
+ setIsSubmitting(true);
11082
+ let requestSucceeded = false;
11083
+ await requestOrderEdit(void 0, {
11084
+ onError: (e) => {
11085
+ ui.toast.error(e.message);
11086
+ },
11087
+ onSuccess: () => {
11088
+ requestSucceeded = true;
11089
+ }
11090
+ });
11091
+ if (!requestSucceeded) {
11092
+ setIsSubmitting(false);
11093
+ return;
11094
+ }
11095
+ await confirmOrderEdit(void 0, {
11096
+ onError: (e) => {
11097
+ ui.toast.error(e.message);
11098
+ },
11099
+ onSuccess: () => {
11100
+ handleSuccess();
11101
+ },
11102
+ onSettled: () => {
11103
+ setIsSubmitting(false);
11104
+ }
11105
+ });
11106
+ };
11107
+ if (isError) {
11108
+ throw error;
11109
+ }
11110
+ return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
11111
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
11112
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
11113
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
11114
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
11115
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
11116
+ ] }),
11117
+ /* @__PURE__ */ jsxRuntime.jsx(
11118
+ Combobox,
11119
+ {
11120
+ id: "promotion-combobox",
11121
+ "aria-describedby": "promotion-combobox-hint",
11122
+ isFetchingNextPage: comboboxData.isFetchingNextPage,
11123
+ fetchNextPage: comboboxData.fetchNextPage,
11124
+ options: comboboxData.options,
11125
+ onSearchValueChange: comboboxData.onSearchValueChange,
11126
+ searchValue: comboboxData.searchValue,
11127
+ disabled: comboboxData.disabled || isAddingPromotions,
11128
+ onChange: add,
11129
+ value: comboboxValue
11130
+ }
11131
+ )
11132
+ ] }),
11133
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11134
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
11135
+ PromotionItem,
11136
+ {
11137
+ promotion,
11138
+ orderId: preview.id,
11139
+ isLoading: isPending
11140
+ },
11141
+ promotion.id
11142
+ )) })
11143
+ ] }) }),
11144
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11145
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11146
+ /* @__PURE__ */ jsxRuntime.jsx(
11147
+ ui.Button,
11148
+ {
11149
+ size: "small",
11150
+ type: "submit",
11151
+ isLoading: isSubmitting || isAddingPromotions,
11152
+ children: "Save"
11153
+ }
11154
+ )
11155
+ ] }) })
11156
+ ] });
11157
+ };
11158
+ const PromotionItem = ({
11159
+ promotion,
11160
+ orderId,
11161
+ isLoading
11162
+ }) => {
11163
+ var _a;
11164
+ const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
11165
+ const onRemove = async () => {
11166
+ removePromotions(
11167
+ {
11168
+ promo_codes: [promotion.code]
11169
+ },
11170
+ {
11171
+ onError: (e) => {
11172
+ ui.toast.error(e.message);
11173
+ }
11174
+ }
11175
+ );
11176
+ };
11177
+ const displayValue = getDisplayValue(promotion);
11178
+ return /* @__PURE__ */ jsxRuntime.jsxs(
11179
+ "div",
11180
+ {
11181
+ className: ui.clx(
11182
+ "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
11183
+ {
11184
+ "animate-pulse": isLoading
11185
+ }
11186
+ ),
11187
+ children: [
11188
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11189
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
11190
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
11191
+ displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
11192
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
11193
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
11194
+ ] }),
11195
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
11196
+ ] })
11197
+ ] }),
11198
+ /* @__PURE__ */ jsxRuntime.jsx(
11199
+ ui.IconButton,
11200
+ {
11201
+ size: "small",
11202
+ type: "button",
11203
+ variant: "transparent",
11204
+ onClick: onRemove,
11205
+ isLoading: isPending || isLoading,
11206
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
11207
+ }
11208
+ )
11209
+ ]
11210
+ },
11211
+ promotion.id
11212
+ );
11213
+ };
11214
+ function getDisplayValue(promotion) {
11215
+ var _a, _b, _c, _d;
11216
+ const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
11217
+ if (!value) {
11218
+ return null;
11219
+ }
11220
+ if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
11221
+ const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
11222
+ if (!currency) {
11223
+ return null;
11224
+ }
11225
+ return getLocaleAmount(value, currency);
11226
+ } else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
11227
+ return formatPercentage(value);
11228
+ }
11229
+ return null;
11230
+ }
11231
+ const formatter = new Intl.NumberFormat([], {
11232
+ style: "percent",
11233
+ minimumFractionDigits: 2
11234
+ });
11235
+ const formatPercentage = (value, isPercentageValue = false) => {
11236
+ let val = value || 0;
11237
+ if (!isPercentageValue) {
11238
+ val = val / 100;
11239
+ }
11240
+ return formatter.format(val);
11241
+ };
11242
+ function getPromotionIds(items, shippingMethods) {
11243
+ const promotionIds = /* @__PURE__ */ new Set();
11244
+ for (const item of items) {
11245
+ if (item.adjustments) {
11246
+ for (const adjustment of item.adjustments) {
11247
+ if (adjustment.promotion_id) {
11248
+ promotionIds.add(adjustment.promotion_id);
11249
+ }
11250
+ }
11251
+ }
11252
+ }
11253
+ for (const shippingMethod of shippingMethods) {
11254
+ if (shippingMethod.adjustments) {
11255
+ for (const adjustment of shippingMethod.adjustments) {
11256
+ if (adjustment.promotion_id) {
11257
+ promotionIds.add(adjustment.promotion_id);
11258
+ }
11441
11259
  }
11442
11260
  }
11443
- });
11444
- return update;
11445
- }
11446
- function getHasUneditableRows(metadata) {
11447
- if (!metadata) {
11448
- return false;
11449
11261
  }
11450
- return Object.values(metadata).some(
11451
- (value) => !EDITABLE_TYPES.includes(typeof value)
11452
- );
11262
+ return Array.from(promotionIds);
11453
11263
  }
11454
11264
  const SalesChannel = () => {
11455
11265
  const { id } = reactRouterDom.useParams();
@@ -11479,7 +11289,7 @@ const SalesChannelForm = ({ order }) => {
11479
11289
  defaultValues: {
11480
11290
  sales_channel_id: order.sales_channel_id || ""
11481
11291
  },
11482
- resolver: zod.zodResolver(schema$2)
11292
+ resolver: zod.zodResolver(schema$3)
11483
11293
  });
11484
11294
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11485
11295
  const { handleSuccess } = useRouteModal();
@@ -11554,7 +11364,7 @@ const SalesChannelField = ({ control, order }) => {
11554
11364
  }
11555
11365
  );
11556
11366
  };
11557
- const schema$2 = objectType({
11367
+ const schema$3 = objectType({
11558
11368
  sales_channel_id: stringType().min(1)
11559
11369
  });
11560
11370
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12396,7 +12206,7 @@ const ShippingAddressForm = ({ order }) => {
12396
12206
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12397
12207
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12398
12208
  },
12399
- resolver: zod.zodResolver(schema$1)
12209
+ resolver: zod.zodResolver(schema$2)
12400
12210
  });
12401
12211
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12402
12212
  const { handleSuccess } = useRouteModal();
@@ -12566,7 +12376,7 @@ const ShippingAddressForm = ({ order }) => {
12566
12376
  }
12567
12377
  ) });
12568
12378
  };
12569
- const schema$1 = addressSchema;
12379
+ const schema$2 = addressSchema;
12570
12380
  const TransferOwnership = () => {
12571
12381
  const { id } = reactRouterDom.useParams();
12572
12382
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12590,7 +12400,7 @@ const TransferOwnershipForm = ({ order }) => {
12590
12400
  defaultValues: {
12591
12401
  customer_id: order.customer_id || ""
12592
12402
  },
12593
- resolver: zod.zodResolver(schema)
12403
+ resolver: zod.zodResolver(schema$1)
12594
12404
  });
12595
12405
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12596
12406
  const { handleSuccess } = useRouteModal();
@@ -13040,9 +12850,199 @@ const Illustration = () => {
13040
12850
  }
13041
12851
  );
13042
12852
  };
13043
- const schema = objectType({
12853
+ const schema$1 = objectType({
13044
12854
  customer_id: stringType().min(1)
13045
12855
  });
12856
+ const BillingAddress = () => {
12857
+ const { id } = reactRouterDom.useParams();
12858
+ const { order, isPending, isError, error } = useOrder(id, {
12859
+ fields: "+billing_address"
12860
+ });
12861
+ if (isError) {
12862
+ throw error;
12863
+ }
12864
+ const isReady = !isPending && !!order;
12865
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12866
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12867
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12868
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12869
+ ] }),
12870
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12871
+ ] });
12872
+ };
12873
+ const BillingAddressForm = ({ order }) => {
12874
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12875
+ const form = reactHookForm.useForm({
12876
+ defaultValues: {
12877
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12878
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12879
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12880
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12881
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12882
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12883
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12884
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12885
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12886
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12887
+ },
12888
+ resolver: zod.zodResolver(schema)
12889
+ });
12890
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12891
+ const { handleSuccess } = useRouteModal();
12892
+ const onSubmit = form.handleSubmit(async (data) => {
12893
+ await mutateAsync(
12894
+ { billing_address: data },
12895
+ {
12896
+ onSuccess: () => {
12897
+ handleSuccess();
12898
+ },
12899
+ onError: (error) => {
12900
+ ui.toast.error(error.message);
12901
+ }
12902
+ }
12903
+ );
12904
+ });
12905
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12906
+ KeyboundForm,
12907
+ {
12908
+ className: "flex flex-1 flex-col overflow-hidden",
12909
+ onSubmit,
12910
+ children: [
12911
+ /* @__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: [
12912
+ /* @__PURE__ */ jsxRuntime.jsx(
12913
+ Form$2.Field,
12914
+ {
12915
+ control: form.control,
12916
+ name: "country_code",
12917
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12918
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12919
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12920
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12921
+ ] })
12922
+ }
12923
+ ),
12924
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12925
+ /* @__PURE__ */ jsxRuntime.jsx(
12926
+ Form$2.Field,
12927
+ {
12928
+ control: form.control,
12929
+ name: "first_name",
12930
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12931
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12932
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12933
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12934
+ ] })
12935
+ }
12936
+ ),
12937
+ /* @__PURE__ */ jsxRuntime.jsx(
12938
+ Form$2.Field,
12939
+ {
12940
+ control: form.control,
12941
+ name: "last_name",
12942
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12943
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12944
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12945
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12946
+ ] })
12947
+ }
12948
+ )
12949
+ ] }),
12950
+ /* @__PURE__ */ jsxRuntime.jsx(
12951
+ Form$2.Field,
12952
+ {
12953
+ control: form.control,
12954
+ name: "company",
12955
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12956
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
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.jsx(
12963
+ Form$2.Field,
12964
+ {
12965
+ control: form.control,
12966
+ name: "address_1",
12967
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12968
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12969
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12970
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12971
+ ] })
12972
+ }
12973
+ ),
12974
+ /* @__PURE__ */ jsxRuntime.jsx(
12975
+ Form$2.Field,
12976
+ {
12977
+ control: form.control,
12978
+ name: "address_2",
12979
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12980
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12981
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12982
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12983
+ ] })
12984
+ }
12985
+ ),
12986
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12987
+ /* @__PURE__ */ jsxRuntime.jsx(
12988
+ Form$2.Field,
12989
+ {
12990
+ control: form.control,
12991
+ name: "postal_code",
12992
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12993
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12994
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12995
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12996
+ ] })
12997
+ }
12998
+ ),
12999
+ /* @__PURE__ */ jsxRuntime.jsx(
13000
+ Form$2.Field,
13001
+ {
13002
+ control: form.control,
13003
+ name: "city",
13004
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13005
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
13006
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13007
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13008
+ ] })
13009
+ }
13010
+ )
13011
+ ] }),
13012
+ /* @__PURE__ */ jsxRuntime.jsx(
13013
+ Form$2.Field,
13014
+ {
13015
+ control: form.control,
13016
+ name: "province",
13017
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13018
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13019
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13020
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13021
+ ] })
13022
+ }
13023
+ ),
13024
+ /* @__PURE__ */ jsxRuntime.jsx(
13025
+ Form$2.Field,
13026
+ {
13027
+ control: form.control,
13028
+ name: "phone",
13029
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13030
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13031
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13032
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13033
+ ] })
13034
+ }
13035
+ )
13036
+ ] }) }),
13037
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13038
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13039
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13040
+ ] }) })
13041
+ ]
13042
+ }
13043
+ ) });
13044
+ };
13045
+ const schema = addressSchema;
13046
13046
  const widgetModule = { widgets: [] };
13047
13047
  const routeModule = {
13048
13048
  routes: [
@@ -13063,10 +13063,6 @@ const routeModule = {
13063
13063
  handle,
13064
13064
  loader,
13065
13065
  children: [
13066
- {
13067
- Component: BillingAddress,
13068
- path: "/draft-orders/:id/billing-address"
13069
- },
13070
13066
  {
13071
13067
  Component: CustomItems,
13072
13068
  path: "/draft-orders/:id/custom-items"
@@ -13079,14 +13075,14 @@ const routeModule = {
13079
13075
  Component: Items,
13080
13076
  path: "/draft-orders/:id/items"
13081
13077
  },
13082
- {
13083
- Component: Promotions,
13084
- path: "/draft-orders/:id/promotions"
13085
- },
13086
13078
  {
13087
13079
  Component: Metadata,
13088
13080
  path: "/draft-orders/:id/metadata"
13089
13081
  },
13082
+ {
13083
+ Component: Promotions,
13084
+ path: "/draft-orders/:id/promotions"
13085
+ },
13090
13086
  {
13091
13087
  Component: SalesChannel,
13092
13088
  path: "/draft-orders/:id/sales-channel"
@@ -13102,6 +13098,10 @@ const routeModule = {
13102
13098
  {
13103
13099
  Component: TransferOwnership,
13104
13100
  path: "/draft-orders/:id/transfer-ownership"
13101
+ },
13102
+ {
13103
+ Component: BillingAddress,
13104
+ path: "/draft-orders/:id/billing-address"
13105
13105
  }
13106
13106
  ]
13107
13107
  }