@medusajs/draft-order 2.10.4-preview-20251003031104 → 2.10.4-preview-20251003060157

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.
@@ -9567,217 +9567,6 @@ const ID = () => {
9567
9567
  /* @__PURE__ */ jsx(Outlet, {})
9568
9568
  ] });
9569
9569
  };
9570
- const BillingAddress = () => {
9571
- const { id } = useParams();
9572
- const { order, isPending, isError, error } = useOrder(id, {
9573
- fields: "+billing_address"
9574
- });
9575
- if (isError) {
9576
- throw error;
9577
- }
9578
- const isReady = !isPending && !!order;
9579
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9580
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9581
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9582
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9583
- ] }),
9584
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9585
- ] });
9586
- };
9587
- const BillingAddressForm = ({ order }) => {
9588
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9589
- const form = useForm({
9590
- defaultValues: {
9591
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9592
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9593
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9594
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9595
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9596
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9597
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9598
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9599
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9600
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9601
- },
9602
- resolver: zodResolver(schema$5)
9603
- });
9604
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9605
- const { handleSuccess } = useRouteModal();
9606
- const onSubmit = form.handleSubmit(async (data) => {
9607
- await mutateAsync(
9608
- { billing_address: data },
9609
- {
9610
- onSuccess: () => {
9611
- handleSuccess();
9612
- },
9613
- onError: (error) => {
9614
- toast.error(error.message);
9615
- }
9616
- }
9617
- );
9618
- });
9619
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9620
- KeyboundForm,
9621
- {
9622
- className: "flex flex-1 flex-col overflow-hidden",
9623
- onSubmit,
9624
- children: [
9625
- /* @__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: [
9626
- /* @__PURE__ */ jsx(
9627
- Form$2.Field,
9628
- {
9629
- control: form.control,
9630
- name: "country_code",
9631
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9632
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9633
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9634
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9635
- ] })
9636
- }
9637
- ),
9638
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9639
- /* @__PURE__ */ jsx(
9640
- Form$2.Field,
9641
- {
9642
- control: form.control,
9643
- name: "first_name",
9644
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9645
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9646
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9647
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9648
- ] })
9649
- }
9650
- ),
9651
- /* @__PURE__ */ jsx(
9652
- Form$2.Field,
9653
- {
9654
- control: form.control,
9655
- name: "last_name",
9656
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9657
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9658
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9659
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9660
- ] })
9661
- }
9662
- )
9663
- ] }),
9664
- /* @__PURE__ */ jsx(
9665
- Form$2.Field,
9666
- {
9667
- control: form.control,
9668
- name: "company",
9669
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9670
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9671
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9672
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9673
- ] })
9674
- }
9675
- ),
9676
- /* @__PURE__ */ jsx(
9677
- Form$2.Field,
9678
- {
9679
- control: form.control,
9680
- name: "address_1",
9681
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9682
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9683
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9684
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9685
- ] })
9686
- }
9687
- ),
9688
- /* @__PURE__ */ jsx(
9689
- Form$2.Field,
9690
- {
9691
- control: form.control,
9692
- name: "address_2",
9693
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9694
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9695
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9696
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9697
- ] })
9698
- }
9699
- ),
9700
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9701
- /* @__PURE__ */ jsx(
9702
- Form$2.Field,
9703
- {
9704
- control: form.control,
9705
- name: "postal_code",
9706
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9707
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9708
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9709
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9710
- ] })
9711
- }
9712
- ),
9713
- /* @__PURE__ */ jsx(
9714
- Form$2.Field,
9715
- {
9716
- control: form.control,
9717
- name: "city",
9718
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9719
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9720
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9721
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9722
- ] })
9723
- }
9724
- )
9725
- ] }),
9726
- /* @__PURE__ */ jsx(
9727
- Form$2.Field,
9728
- {
9729
- control: form.control,
9730
- name: "province",
9731
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9732
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9733
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9734
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9735
- ] })
9736
- }
9737
- ),
9738
- /* @__PURE__ */ jsx(
9739
- Form$2.Field,
9740
- {
9741
- control: form.control,
9742
- name: "phone",
9743
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9744
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9745
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9746
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9747
- ] })
9748
- }
9749
- )
9750
- ] }) }),
9751
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9752
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9753
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9754
- ] }) })
9755
- ]
9756
- }
9757
- ) });
9758
- };
9759
- const schema$5 = addressSchema;
9760
- const CustomItems = () => {
9761
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9762
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9763
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9764
- ] });
9765
- };
9766
- const CustomItemsForm = () => {
9767
- const form = useForm({
9768
- resolver: zodResolver(schema$4)
9769
- });
9770
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9771
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9772
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9773
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9774
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9775
- ] }) })
9776
- ] }) });
9777
- };
9778
- const schema$4 = objectType({
9779
- email: stringType().email()
9780
- });
9781
9570
  const Email = () => {
9782
9571
  const { id } = useParams();
9783
9572
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9800,7 +9589,7 @@ const EmailForm = ({ order }) => {
9800
9589
  defaultValues: {
9801
9590
  email: order.email ?? ""
9802
9591
  },
9803
- resolver: zodResolver(schema$3)
9592
+ resolver: zodResolver(schema$5)
9804
9593
  });
9805
9594
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9806
9595
  const { handleSuccess } = useRouteModal();
@@ -9843,7 +9632,7 @@ const EmailForm = ({ order }) => {
9843
9632
  }
9844
9633
  ) });
9845
9634
  };
9846
- const schema$3 = objectType({
9635
+ const schema$5 = objectType({
9847
9636
  email: stringType().email()
9848
9637
  });
9849
9638
  const NumberInput = forwardRef(
@@ -10820,6 +10609,27 @@ const customItemSchema = objectType({
10820
10609
  quantity: numberType(),
10821
10610
  unit_price: unionType([numberType(), stringType()])
10822
10611
  });
10612
+ const CustomItems = () => {
10613
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
10614
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
10615
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
10616
+ ] });
10617
+ };
10618
+ const CustomItemsForm = () => {
10619
+ const form = useForm({
10620
+ resolver: zodResolver(schema$4)
10621
+ });
10622
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
10623
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
10624
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
10625
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10626
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
10627
+ ] }) })
10628
+ ] }) });
10629
+ };
10630
+ const schema$4 = objectType({
10631
+ email: stringType().email()
10632
+ });
10823
10633
  const InlineTip = forwardRef(
10824
10634
  ({ variant = "tip", label, className, children, ...props }, ref) => {
10825
10635
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -11170,21 +10980,298 @@ function getHasUneditableRows(metadata) {
11170
10980
  (value) => !EDITABLE_TYPES.includes(typeof value)
11171
10981
  );
11172
10982
  }
11173
- const SalesChannel = () => {
11174
- const { id } = useParams();
11175
- const { draft_order, isPending, isError, error } = useDraftOrder(
10983
+ const PROMOTION_QUERY_KEY = "promotions";
10984
+ const promotionsQueryKeys = {
10985
+ list: (query2) => [
10986
+ PROMOTION_QUERY_KEY,
10987
+ query2 ? query2 : void 0
10988
+ ],
10989
+ detail: (id, query2) => [
10990
+ PROMOTION_QUERY_KEY,
11176
10991
  id,
11177
- {
11178
- fields: "+sales_channel_id"
11179
- },
11180
- {
11181
- enabled: !!id
11182
- }
11183
- );
11184
- if (isError) {
11185
- throw error;
11186
- }
11187
- const ISrEADY = !!draft_order && !isPending;
10992
+ query2 ? query2 : void 0
10993
+ ]
10994
+ };
10995
+ const usePromotions = (query2, options) => {
10996
+ const { data, ...rest } = useQuery({
10997
+ queryKey: promotionsQueryKeys.list(query2),
10998
+ queryFn: async () => sdk.admin.promotion.list(query2),
10999
+ ...options
11000
+ });
11001
+ return { ...data, ...rest };
11002
+ };
11003
+ const Promotions = () => {
11004
+ const { id } = useParams();
11005
+ const {
11006
+ order: preview,
11007
+ isError: isPreviewError,
11008
+ error: previewError
11009
+ } = useOrderPreview(id, void 0);
11010
+ useInitiateOrderEdit({ preview });
11011
+ const { onCancel } = useCancelOrderEdit({ preview });
11012
+ if (isPreviewError) {
11013
+ throw previewError;
11014
+ }
11015
+ const isReady = !!preview;
11016
+ return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
11017
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
11018
+ isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
11019
+ ] });
11020
+ };
11021
+ const PromotionForm = ({ preview }) => {
11022
+ const { items, shipping_methods } = preview;
11023
+ const [isSubmitting, setIsSubmitting] = useState(false);
11024
+ const [comboboxValue, setComboboxValue] = useState("");
11025
+ const { handleSuccess } = useRouteModal();
11026
+ const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
11027
+ const promoIds = getPromotionIds(items, shipping_methods);
11028
+ const { promotions, isPending, isError, error } = usePromotions(
11029
+ {
11030
+ id: promoIds
11031
+ },
11032
+ {
11033
+ enabled: !!promoIds.length
11034
+ }
11035
+ );
11036
+ const comboboxData = useComboboxData({
11037
+ queryKey: ["promotions", "combobox", promoIds],
11038
+ queryFn: async (params) => {
11039
+ return await sdk.admin.promotion.list({
11040
+ ...params,
11041
+ id: {
11042
+ $nin: promoIds
11043
+ }
11044
+ });
11045
+ },
11046
+ getOptions: (data) => {
11047
+ return data.promotions.map((promotion) => ({
11048
+ label: promotion.code,
11049
+ value: promotion.code
11050
+ }));
11051
+ }
11052
+ });
11053
+ const add = async (value) => {
11054
+ if (!value) {
11055
+ return;
11056
+ }
11057
+ addPromotions(
11058
+ {
11059
+ promo_codes: [value]
11060
+ },
11061
+ {
11062
+ onError: (e) => {
11063
+ toast.error(e.message);
11064
+ comboboxData.onSearchValueChange("");
11065
+ setComboboxValue("");
11066
+ },
11067
+ onSuccess: () => {
11068
+ comboboxData.onSearchValueChange("");
11069
+ setComboboxValue("");
11070
+ }
11071
+ }
11072
+ );
11073
+ };
11074
+ const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
11075
+ const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
11076
+ const onSubmit = async () => {
11077
+ setIsSubmitting(true);
11078
+ let requestSucceeded = false;
11079
+ await requestOrderEdit(void 0, {
11080
+ onError: (e) => {
11081
+ toast.error(e.message);
11082
+ },
11083
+ onSuccess: () => {
11084
+ requestSucceeded = true;
11085
+ }
11086
+ });
11087
+ if (!requestSucceeded) {
11088
+ setIsSubmitting(false);
11089
+ return;
11090
+ }
11091
+ await confirmOrderEdit(void 0, {
11092
+ onError: (e) => {
11093
+ toast.error(e.message);
11094
+ },
11095
+ onSuccess: () => {
11096
+ handleSuccess();
11097
+ },
11098
+ onSettled: () => {
11099
+ setIsSubmitting(false);
11100
+ }
11101
+ });
11102
+ };
11103
+ if (isError) {
11104
+ throw error;
11105
+ }
11106
+ return /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
11107
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
11108
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
11109
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
11110
+ /* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
11111
+ /* @__PURE__ */ jsx(Hint$1, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
11112
+ ] }),
11113
+ /* @__PURE__ */ jsx(
11114
+ Combobox,
11115
+ {
11116
+ id: "promotion-combobox",
11117
+ "aria-describedby": "promotion-combobox-hint",
11118
+ isFetchingNextPage: comboboxData.isFetchingNextPage,
11119
+ fetchNextPage: comboboxData.fetchNextPage,
11120
+ options: comboboxData.options,
11121
+ onSearchValueChange: comboboxData.onSearchValueChange,
11122
+ searchValue: comboboxData.searchValue,
11123
+ disabled: comboboxData.disabled || isAddingPromotions,
11124
+ onChange: add,
11125
+ value: comboboxValue
11126
+ }
11127
+ )
11128
+ ] }),
11129
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11130
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsx(
11131
+ PromotionItem,
11132
+ {
11133
+ promotion,
11134
+ orderId: preview.id,
11135
+ isLoading: isPending
11136
+ },
11137
+ promotion.id
11138
+ )) })
11139
+ ] }) }),
11140
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11141
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11142
+ /* @__PURE__ */ jsx(
11143
+ Button,
11144
+ {
11145
+ size: "small",
11146
+ type: "submit",
11147
+ isLoading: isSubmitting || isAddingPromotions,
11148
+ children: "Save"
11149
+ }
11150
+ )
11151
+ ] }) })
11152
+ ] });
11153
+ };
11154
+ const PromotionItem = ({
11155
+ promotion,
11156
+ orderId,
11157
+ isLoading
11158
+ }) => {
11159
+ var _a;
11160
+ const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
11161
+ const onRemove = async () => {
11162
+ removePromotions(
11163
+ {
11164
+ promo_codes: [promotion.code]
11165
+ },
11166
+ {
11167
+ onError: (e) => {
11168
+ toast.error(e.message);
11169
+ }
11170
+ }
11171
+ );
11172
+ };
11173
+ const displayValue = getDisplayValue(promotion);
11174
+ return /* @__PURE__ */ jsxs(
11175
+ "div",
11176
+ {
11177
+ className: clx(
11178
+ "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
11179
+ {
11180
+ "animate-pulse": isLoading
11181
+ }
11182
+ ),
11183
+ children: [
11184
+ /* @__PURE__ */ jsxs("div", { children: [
11185
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
11186
+ /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
11187
+ displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
11188
+ /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
11189
+ /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
11190
+ ] }),
11191
+ /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
11192
+ ] })
11193
+ ] }),
11194
+ /* @__PURE__ */ jsx(
11195
+ IconButton,
11196
+ {
11197
+ size: "small",
11198
+ type: "button",
11199
+ variant: "transparent",
11200
+ onClick: onRemove,
11201
+ isLoading: isPending || isLoading,
11202
+ children: /* @__PURE__ */ jsx(XMark, {})
11203
+ }
11204
+ )
11205
+ ]
11206
+ },
11207
+ promotion.id
11208
+ );
11209
+ };
11210
+ function getDisplayValue(promotion) {
11211
+ var _a, _b, _c, _d;
11212
+ const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
11213
+ if (!value) {
11214
+ return null;
11215
+ }
11216
+ if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
11217
+ const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
11218
+ if (!currency) {
11219
+ return null;
11220
+ }
11221
+ return getLocaleAmount(value, currency);
11222
+ } else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
11223
+ return formatPercentage(value);
11224
+ }
11225
+ return null;
11226
+ }
11227
+ const formatter = new Intl.NumberFormat([], {
11228
+ style: "percent",
11229
+ minimumFractionDigits: 2
11230
+ });
11231
+ const formatPercentage = (value, isPercentageValue = false) => {
11232
+ let val = value || 0;
11233
+ if (!isPercentageValue) {
11234
+ val = val / 100;
11235
+ }
11236
+ return formatter.format(val);
11237
+ };
11238
+ function getPromotionIds(items, shippingMethods) {
11239
+ const promotionIds = /* @__PURE__ */ new Set();
11240
+ for (const item of items) {
11241
+ if (item.adjustments) {
11242
+ for (const adjustment of item.adjustments) {
11243
+ if (adjustment.promotion_id) {
11244
+ promotionIds.add(adjustment.promotion_id);
11245
+ }
11246
+ }
11247
+ }
11248
+ }
11249
+ for (const shippingMethod of shippingMethods) {
11250
+ if (shippingMethod.adjustments) {
11251
+ for (const adjustment of shippingMethod.adjustments) {
11252
+ if (adjustment.promotion_id) {
11253
+ promotionIds.add(adjustment.promotion_id);
11254
+ }
11255
+ }
11256
+ }
11257
+ }
11258
+ return Array.from(promotionIds);
11259
+ }
11260
+ const SalesChannel = () => {
11261
+ const { id } = useParams();
11262
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11263
+ id,
11264
+ {
11265
+ fields: "+sales_channel_id"
11266
+ },
11267
+ {
11268
+ enabled: !!id
11269
+ }
11270
+ );
11271
+ if (isError) {
11272
+ throw error;
11273
+ }
11274
+ const ISrEADY = !!draft_order && !isPending;
11188
11275
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11189
11276
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11190
11277
  /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
@@ -11198,7 +11285,7 @@ const SalesChannelForm = ({ order }) => {
11198
11285
  defaultValues: {
11199
11286
  sales_channel_id: order.sales_channel_id || ""
11200
11287
  },
11201
- resolver: zodResolver(schema$2)
11288
+ resolver: zodResolver(schema$3)
11202
11289
  });
11203
11290
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11204
11291
  const { handleSuccess } = useRouteModal();
@@ -11273,7 +11360,7 @@ const SalesChannelField = ({ control, order }) => {
11273
11360
  }
11274
11361
  );
11275
11362
  };
11276
- const schema$2 = objectType({
11363
+ const schema$3 = objectType({
11277
11364
  sales_channel_id: stringType().min(1)
11278
11365
  });
11279
11366
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12115,7 +12202,7 @@ const ShippingAddressForm = ({ order }) => {
12115
12202
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12116
12203
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12117
12204
  },
12118
- resolver: zodResolver(schema$1)
12205
+ resolver: zodResolver(schema$2)
12119
12206
  });
12120
12207
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12121
12208
  const { handleSuccess } = useRouteModal();
@@ -12285,7 +12372,7 @@ const ShippingAddressForm = ({ order }) => {
12285
12372
  }
12286
12373
  ) });
12287
12374
  };
12288
- const schema$1 = addressSchema;
12375
+ const schema$2 = addressSchema;
12289
12376
  const TransferOwnership = () => {
12290
12377
  const { id } = useParams();
12291
12378
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12309,7 +12396,7 @@ const TransferOwnershipForm = ({ order }) => {
12309
12396
  defaultValues: {
12310
12397
  customer_id: order.customer_id || ""
12311
12398
  },
12312
- resolver: zodResolver(schema)
12399
+ resolver: zodResolver(schema$1)
12313
12400
  });
12314
12401
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12315
12402
  const { handleSuccess } = useRouteModal();
@@ -12751,294 +12838,207 @@ const Illustration = () => {
12751
12838
  width: "12",
12752
12839
  height: "12",
12753
12840
  fill: "white",
12754
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12755
- }
12756
- ) })
12757
- ] })
12758
- ]
12759
- }
12760
- );
12761
- };
12762
- const schema = objectType({
12763
- customer_id: stringType().min(1)
12764
- });
12765
- const PROMOTION_QUERY_KEY = "promotions";
12766
- const promotionsQueryKeys = {
12767
- list: (query2) => [
12768
- PROMOTION_QUERY_KEY,
12769
- query2 ? query2 : void 0
12770
- ],
12771
- detail: (id, query2) => [
12772
- PROMOTION_QUERY_KEY,
12773
- id,
12774
- query2 ? query2 : void 0
12775
- ]
12776
- };
12777
- const usePromotions = (query2, options) => {
12778
- const { data, ...rest } = useQuery({
12779
- queryKey: promotionsQueryKeys.list(query2),
12780
- queryFn: async () => sdk.admin.promotion.list(query2),
12781
- ...options
12782
- });
12783
- return { ...data, ...rest };
12784
- };
12785
- const Promotions = () => {
12786
- const { id } = useParams();
12787
- const {
12788
- order: preview,
12789
- isError: isPreviewError,
12790
- error: previewError
12791
- } = useOrderPreview(id, void 0);
12792
- useInitiateOrderEdit({ preview });
12793
- const { onCancel } = useCancelOrderEdit({ preview });
12794
- if (isPreviewError) {
12795
- throw previewError;
12796
- }
12797
- const isReady = !!preview;
12798
- return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
12799
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
12800
- isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
12801
- ] });
12802
- };
12803
- const PromotionForm = ({ preview }) => {
12804
- const { items, shipping_methods } = preview;
12805
- const [isSubmitting, setIsSubmitting] = useState(false);
12806
- const [comboboxValue, setComboboxValue] = useState("");
12807
- const { handleSuccess } = useRouteModal();
12808
- const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
12809
- const promoIds = getPromotionIds(items, shipping_methods);
12810
- const { promotions, isPending, isError, error } = usePromotions(
12811
- {
12812
- id: promoIds
12813
- },
12814
- {
12815
- enabled: !!promoIds.length
12816
- }
12817
- );
12818
- const comboboxData = useComboboxData({
12819
- queryKey: ["promotions", "combobox", promoIds],
12820
- queryFn: async (params) => {
12821
- return await sdk.admin.promotion.list({
12822
- ...params,
12823
- id: {
12824
- $nin: promoIds
12825
- }
12826
- });
12827
- },
12828
- getOptions: (data) => {
12829
- return data.promotions.map((promotion) => ({
12830
- label: promotion.code,
12831
- value: promotion.code
12832
- }));
12833
- }
12834
- });
12835
- const add = async (value) => {
12836
- if (!value) {
12837
- return;
12838
- }
12839
- addPromotions(
12840
- {
12841
- promo_codes: [value]
12842
- },
12843
- {
12844
- onError: (e) => {
12845
- toast.error(e.message);
12846
- comboboxData.onSearchValueChange("");
12847
- setComboboxValue("");
12848
- },
12849
- onSuccess: () => {
12850
- comboboxData.onSearchValueChange("");
12851
- setComboboxValue("");
12852
- }
12853
- }
12854
- );
12855
- };
12856
- const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
12857
- const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
12858
- const onSubmit = async () => {
12859
- setIsSubmitting(true);
12860
- let requestSucceeded = false;
12861
- await requestOrderEdit(void 0, {
12862
- onError: (e) => {
12863
- toast.error(e.message);
12864
- },
12865
- onSuccess: () => {
12866
- requestSucceeded = true;
12867
- }
12868
- });
12869
- if (!requestSucceeded) {
12870
- setIsSubmitting(false);
12871
- return;
12872
- }
12873
- await confirmOrderEdit(void 0, {
12874
- onError: (e) => {
12875
- toast.error(e.message);
12876
- },
12877
- onSuccess: () => {
12878
- handleSuccess();
12879
- },
12880
- onSettled: () => {
12881
- setIsSubmitting(false);
12882
- }
12883
- });
12884
- };
12885
- if (isError) {
12886
- throw error;
12887
- }
12888
- return /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
12889
- /* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
12890
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
12891
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12892
- /* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
12893
- /* @__PURE__ */ jsx(Hint$1, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
12894
- ] }),
12895
- /* @__PURE__ */ jsx(
12896
- Combobox,
12897
- {
12898
- id: "promotion-combobox",
12899
- "aria-describedby": "promotion-combobox-hint",
12900
- isFetchingNextPage: comboboxData.isFetchingNextPage,
12901
- fetchNextPage: comboboxData.fetchNextPage,
12902
- options: comboboxData.options,
12903
- onSearchValueChange: comboboxData.onSearchValueChange,
12904
- searchValue: comboboxData.searchValue,
12905
- disabled: comboboxData.disabled || isAddingPromotions,
12906
- onChange: add,
12907
- value: comboboxValue
12908
- }
12909
- )
12910
- ] }),
12911
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12912
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsx(
12913
- PromotionItem,
12914
- {
12915
- promotion,
12916
- orderId: preview.id,
12917
- isLoading: isPending
12918
- },
12919
- promotion.id
12920
- )) })
12921
- ] }) }),
12922
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12923
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12924
- /* @__PURE__ */ jsx(
12925
- Button,
12926
- {
12927
- size: "small",
12928
- type: "submit",
12929
- isLoading: isSubmitting || isAddingPromotions,
12930
- children: "Save"
12931
- }
12932
- )
12933
- ] }) })
12934
- ] });
12935
- };
12936
- const PromotionItem = ({
12937
- promotion,
12938
- orderId,
12939
- isLoading
12940
- }) => {
12941
- var _a;
12942
- const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
12943
- const onRemove = async () => {
12944
- removePromotions(
12945
- {
12946
- promo_codes: [promotion.code]
12947
- },
12948
- {
12949
- onError: (e) => {
12950
- toast.error(e.message);
12951
- }
12952
- }
12953
- );
12954
- };
12955
- const displayValue = getDisplayValue(promotion);
12956
- return /* @__PURE__ */ jsxs(
12957
- "div",
12958
- {
12959
- className: clx(
12960
- "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
12961
- {
12962
- "animate-pulse": isLoading
12963
- }
12964
- ),
12965
- children: [
12966
- /* @__PURE__ */ jsxs("div", { children: [
12967
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
12968
- /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
12969
- displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
12970
- /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
12971
- /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
12972
- ] }),
12973
- /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
12974
- ] })
12975
- ] }),
12976
- /* @__PURE__ */ jsx(
12977
- IconButton,
12978
- {
12979
- size: "small",
12980
- type: "button",
12981
- variant: "transparent",
12982
- onClick: onRemove,
12983
- isLoading: isPending || isLoading,
12984
- children: /* @__PURE__ */ jsx(XMark, {})
12985
- }
12986
- )
12841
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12842
+ }
12843
+ ) })
12844
+ ] })
12987
12845
  ]
12988
- },
12989
- promotion.id
12846
+ }
12990
12847
  );
12991
12848
  };
12992
- function getDisplayValue(promotion) {
12993
- var _a, _b, _c, _d;
12994
- const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
12995
- if (!value) {
12996
- return null;
12997
- }
12998
- if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
12999
- const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
13000
- if (!currency) {
13001
- return null;
13002
- }
13003
- return getLocaleAmount(value, currency);
13004
- } else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
13005
- return formatPercentage(value);
13006
- }
13007
- return null;
13008
- }
13009
- const formatter = new Intl.NumberFormat([], {
13010
- style: "percent",
13011
- minimumFractionDigits: 2
12849
+ const schema$1 = objectType({
12850
+ customer_id: stringType().min(1)
13012
12851
  });
13013
- const formatPercentage = (value, isPercentageValue = false) => {
13014
- let val = value || 0;
13015
- if (!isPercentageValue) {
13016
- val = val / 100;
12852
+ const BillingAddress = () => {
12853
+ const { id } = useParams();
12854
+ const { order, isPending, isError, error } = useOrder(id, {
12855
+ fields: "+billing_address"
12856
+ });
12857
+ if (isError) {
12858
+ throw error;
13017
12859
  }
13018
- return formatter.format(val);
12860
+ const isReady = !isPending && !!order;
12861
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12862
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12863
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
12864
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12865
+ ] }),
12866
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
12867
+ ] });
13019
12868
  };
13020
- function getPromotionIds(items, shippingMethods) {
13021
- const promotionIds = /* @__PURE__ */ new Set();
13022
- for (const item of items) {
13023
- if (item.adjustments) {
13024
- for (const adjustment of item.adjustments) {
13025
- if (adjustment.promotion_id) {
13026
- promotionIds.add(adjustment.promotion_id);
13027
- }
13028
- }
13029
- }
13030
- }
13031
- for (const shippingMethod of shippingMethods) {
13032
- if (shippingMethod.adjustments) {
13033
- for (const adjustment of shippingMethod.adjustments) {
13034
- if (adjustment.promotion_id) {
13035
- promotionIds.add(adjustment.promotion_id);
12869
+ const BillingAddressForm = ({ order }) => {
12870
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12871
+ const form = useForm({
12872
+ defaultValues: {
12873
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12874
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12875
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12876
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12877
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12878
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12879
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12880
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12881
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12882
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12883
+ },
12884
+ resolver: zodResolver(schema)
12885
+ });
12886
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12887
+ const { handleSuccess } = useRouteModal();
12888
+ const onSubmit = form.handleSubmit(async (data) => {
12889
+ await mutateAsync(
12890
+ { billing_address: data },
12891
+ {
12892
+ onSuccess: () => {
12893
+ handleSuccess();
12894
+ },
12895
+ onError: (error) => {
12896
+ toast.error(error.message);
13036
12897
  }
13037
12898
  }
12899
+ );
12900
+ });
12901
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12902
+ KeyboundForm,
12903
+ {
12904
+ className: "flex flex-1 flex-col overflow-hidden",
12905
+ onSubmit,
12906
+ children: [
12907
+ /* @__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: [
12908
+ /* @__PURE__ */ jsx(
12909
+ Form$2.Field,
12910
+ {
12911
+ control: form.control,
12912
+ name: "country_code",
12913
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12914
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12915
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12916
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12917
+ ] })
12918
+ }
12919
+ ),
12920
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12921
+ /* @__PURE__ */ jsx(
12922
+ Form$2.Field,
12923
+ {
12924
+ control: form.control,
12925
+ name: "first_name",
12926
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12927
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12928
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12929
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12930
+ ] })
12931
+ }
12932
+ ),
12933
+ /* @__PURE__ */ jsx(
12934
+ Form$2.Field,
12935
+ {
12936
+ control: form.control,
12937
+ name: "last_name",
12938
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12939
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12940
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12941
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12942
+ ] })
12943
+ }
12944
+ )
12945
+ ] }),
12946
+ /* @__PURE__ */ jsx(
12947
+ Form$2.Field,
12948
+ {
12949
+ control: form.control,
12950
+ name: "company",
12951
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12952
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12953
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12954
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12955
+ ] })
12956
+ }
12957
+ ),
12958
+ /* @__PURE__ */ jsx(
12959
+ Form$2.Field,
12960
+ {
12961
+ control: form.control,
12962
+ name: "address_1",
12963
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12964
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12965
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12966
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12967
+ ] })
12968
+ }
12969
+ ),
12970
+ /* @__PURE__ */ jsx(
12971
+ Form$2.Field,
12972
+ {
12973
+ control: form.control,
12974
+ name: "address_2",
12975
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12976
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12977
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12978
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12979
+ ] })
12980
+ }
12981
+ ),
12982
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12983
+ /* @__PURE__ */ jsx(
12984
+ Form$2.Field,
12985
+ {
12986
+ control: form.control,
12987
+ name: "postal_code",
12988
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12989
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12990
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12991
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12992
+ ] })
12993
+ }
12994
+ ),
12995
+ /* @__PURE__ */ jsx(
12996
+ Form$2.Field,
12997
+ {
12998
+ control: form.control,
12999
+ name: "city",
13000
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13001
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
13002
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13003
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13004
+ ] })
13005
+ }
13006
+ )
13007
+ ] }),
13008
+ /* @__PURE__ */ jsx(
13009
+ Form$2.Field,
13010
+ {
13011
+ control: form.control,
13012
+ name: "province",
13013
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13014
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13015
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13016
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13017
+ ] })
13018
+ }
13019
+ ),
13020
+ /* @__PURE__ */ jsx(
13021
+ Form$2.Field,
13022
+ {
13023
+ control: form.control,
13024
+ name: "phone",
13025
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13026
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13027
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13028
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13029
+ ] })
13030
+ }
13031
+ )
13032
+ ] }) }),
13033
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13034
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13035
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13036
+ ] }) })
13037
+ ]
13038
13038
  }
13039
- }
13040
- return Array.from(promotionIds);
13041
- }
13039
+ ) });
13040
+ };
13041
+ const schema = addressSchema;
13042
13042
  const widgetModule = { widgets: [] };
13043
13043
  const routeModule = {
13044
13044
  routes: [
@@ -13059,14 +13059,6 @@ const routeModule = {
13059
13059
  handle,
13060
13060
  loader,
13061
13061
  children: [
13062
- {
13063
- Component: BillingAddress,
13064
- path: "/draft-orders/:id/billing-address"
13065
- },
13066
- {
13067
- Component: CustomItems,
13068
- path: "/draft-orders/:id/custom-items"
13069
- },
13070
13062
  {
13071
13063
  Component: Email,
13072
13064
  path: "/draft-orders/:id/email"
@@ -13075,10 +13067,18 @@ const routeModule = {
13075
13067
  Component: Items,
13076
13068
  path: "/draft-orders/:id/items"
13077
13069
  },
13070
+ {
13071
+ Component: CustomItems,
13072
+ path: "/draft-orders/:id/custom-items"
13073
+ },
13078
13074
  {
13079
13075
  Component: Metadata,
13080
13076
  path: "/draft-orders/:id/metadata"
13081
13077
  },
13078
+ {
13079
+ Component: Promotions,
13080
+ path: "/draft-orders/:id/promotions"
13081
+ },
13082
13082
  {
13083
13083
  Component: SalesChannel,
13084
13084
  path: "/draft-orders/:id/sales-channel"
@@ -13096,8 +13096,8 @@ const routeModule = {
13096
13096
  path: "/draft-orders/:id/transfer-ownership"
13097
13097
  },
13098
13098
  {
13099
- Component: Promotions,
13100
- path: "/draft-orders/:id/promotions"
13099
+ Component: BillingAddress,
13100
+ path: "/draft-orders/:id/billing-address"
13101
13101
  }
13102
13102
  ]
13103
13103
  }