@medusajs/draft-order 2.10.4-preview-20250929090207 → 2.10.4-preview-20250929120206

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.
@@ -9573,31 +9573,10 @@ const ID = () => {
9573
9573
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9574
9574
  ] });
9575
9575
  };
9576
- const CustomItems = () => {
9577
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9578
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9579
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9580
- ] });
9581
- };
9582
- const CustomItemsForm = () => {
9583
- const form = reactHookForm.useForm({
9584
- resolver: zod.zodResolver(schema$5)
9585
- });
9586
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9587
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9588
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9589
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9590
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9591
- ] }) })
9592
- ] }) });
9593
- };
9594
- const schema$5 = objectType({
9595
- email: stringType().email()
9596
- });
9597
- const Email = () => {
9576
+ const BillingAddress = () => {
9598
9577
  const { id } = reactRouterDom.useParams();
9599
9578
  const { order, isPending, isError, error } = useOrder(id, {
9600
- fields: "+email"
9579
+ fields: "+billing_address"
9601
9580
  });
9602
9581
  if (isError) {
9603
9582
  throw error;
@@ -9605,24 +9584,34 @@ const Email = () => {
9605
9584
  const isReady = !isPending && !!order;
9606
9585
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9607
9586
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9608
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9609
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9588
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9610
9589
  ] }),
9611
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9590
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9612
9591
  ] });
9613
9592
  };
9614
- const EmailForm = ({ order }) => {
9593
+ const BillingAddressForm = ({ order }) => {
9594
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9615
9595
  const form = reactHookForm.useForm({
9616
9596
  defaultValues: {
9617
- email: order.email ?? ""
9597
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9598
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9599
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9600
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9601
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9602
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9603
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9604
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9605
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9606
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9618
9607
  },
9619
- resolver: zod.zodResolver(schema$4)
9608
+ resolver: zod.zodResolver(schema$5)
9620
9609
  });
9621
9610
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9622
9611
  const { handleSuccess } = useRouteModal();
9623
9612
  const onSubmit = form.handleSubmit(async (data) => {
9624
9613
  await mutateAsync(
9625
- { email: data.email },
9614
+ { billing_address: data },
9626
9615
  {
9627
9616
  onSuccess: () => {
9628
9617
  handleSuccess();
@@ -9639,18 +9628,132 @@ const EmailForm = ({ order }) => {
9639
9628
  className: "flex flex-1 flex-col overflow-hidden",
9640
9629
  onSubmit,
9641
9630
  children: [
9642
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9643
- Form$2.Field,
9644
- {
9645
- control: form.control,
9646
- name: "email",
9647
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9648
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9649
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9650
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9651
- ] })
9652
- }
9653
- ) }),
9631
+ /* @__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: [
9632
+ /* @__PURE__ */ jsxRuntime.jsx(
9633
+ Form$2.Field,
9634
+ {
9635
+ control: form.control,
9636
+ name: "country_code",
9637
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9638
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9639
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9640
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9641
+ ] })
9642
+ }
9643
+ ),
9644
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9645
+ /* @__PURE__ */ jsxRuntime.jsx(
9646
+ Form$2.Field,
9647
+ {
9648
+ control: form.control,
9649
+ name: "first_name",
9650
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9651
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9652
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9653
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9654
+ ] })
9655
+ }
9656
+ ),
9657
+ /* @__PURE__ */ jsxRuntime.jsx(
9658
+ Form$2.Field,
9659
+ {
9660
+ control: form.control,
9661
+ name: "last_name",
9662
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9663
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9664
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9665
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9666
+ ] })
9667
+ }
9668
+ )
9669
+ ] }),
9670
+ /* @__PURE__ */ jsxRuntime.jsx(
9671
+ Form$2.Field,
9672
+ {
9673
+ control: form.control,
9674
+ name: "company",
9675
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9676
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9677
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9678
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9679
+ ] })
9680
+ }
9681
+ ),
9682
+ /* @__PURE__ */ jsxRuntime.jsx(
9683
+ Form$2.Field,
9684
+ {
9685
+ control: form.control,
9686
+ name: "address_1",
9687
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9688
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9689
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9690
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9691
+ ] })
9692
+ }
9693
+ ),
9694
+ /* @__PURE__ */ jsxRuntime.jsx(
9695
+ Form$2.Field,
9696
+ {
9697
+ control: form.control,
9698
+ name: "address_2",
9699
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9701
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9702
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9703
+ ] })
9704
+ }
9705
+ ),
9706
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9707
+ /* @__PURE__ */ jsxRuntime.jsx(
9708
+ Form$2.Field,
9709
+ {
9710
+ control: form.control,
9711
+ name: "postal_code",
9712
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9714
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9715
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9716
+ ] })
9717
+ }
9718
+ ),
9719
+ /* @__PURE__ */ jsxRuntime.jsx(
9720
+ Form$2.Field,
9721
+ {
9722
+ control: form.control,
9723
+ name: "city",
9724
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9727
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9728
+ ] })
9729
+ }
9730
+ )
9731
+ ] }),
9732
+ /* @__PURE__ */ jsxRuntime.jsx(
9733
+ Form$2.Field,
9734
+ {
9735
+ control: form.control,
9736
+ name: "province",
9737
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9739
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9740
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9741
+ ] })
9742
+ }
9743
+ ),
9744
+ /* @__PURE__ */ jsxRuntime.jsx(
9745
+ Form$2.Field,
9746
+ {
9747
+ control: form.control,
9748
+ name: "phone",
9749
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9751
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9752
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9753
+ ] })
9754
+ }
9755
+ )
9756
+ ] }) }),
9654
9757
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9655
9758
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9656
9759
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -9659,6 +9762,25 @@ const EmailForm = ({ order }) => {
9659
9762
  }
9660
9763
  ) });
9661
9764
  };
9765
+ const schema$5 = addressSchema;
9766
+ const CustomItems = () => {
9767
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9768
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9769
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9770
+ ] });
9771
+ };
9772
+ const CustomItemsForm = () => {
9773
+ const form = reactHookForm.useForm({
9774
+ resolver: zod.zodResolver(schema$4)
9775
+ });
9776
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9777
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9778
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9779
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9780
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9781
+ ] }) })
9782
+ ] }) });
9783
+ };
9662
9784
  const schema$4 = objectType({
9663
9785
  email: stringType().email()
9664
9786
  });
@@ -10986,49 +11108,117 @@ function getHasUneditableRows(metadata) {
10986
11108
  (value) => !EDITABLE_TYPES.includes(typeof value)
10987
11109
  );
10988
11110
  }
10989
- const PROMOTION_QUERY_KEY = "promotions";
10990
- const promotionsQueryKeys = {
10991
- list: (query2) => [
10992
- PROMOTION_QUERY_KEY,
10993
- query2 ? query2 : void 0
10994
- ],
10995
- detail: (id, query2) => [
10996
- PROMOTION_QUERY_KEY,
10997
- id,
10998
- query2 ? query2 : void 0
10999
- ]
11000
- };
11001
- const usePromotions = (query2, options) => {
11002
- const { data, ...rest } = reactQuery.useQuery({
11003
- queryKey: promotionsQueryKeys.list(query2),
11004
- queryFn: async () => sdk.admin.promotion.list(query2),
11005
- ...options
11006
- });
11007
- return { ...data, ...rest };
11008
- };
11009
- const Promotions = () => {
11111
+ const Email = () => {
11010
11112
  const { id } = reactRouterDom.useParams();
11011
- const {
11012
- order: preview,
11013
- isError: isPreviewError,
11014
- error: previewError
11015
- } = useOrderPreview(id, void 0);
11016
- useInitiateOrderEdit({ preview });
11017
- const { onCancel } = useCancelOrderEdit({ preview });
11018
- if (isPreviewError) {
11019
- throw previewError;
11113
+ const { order, isPending, isError, error } = useOrder(id, {
11114
+ fields: "+email"
11115
+ });
11116
+ if (isError) {
11117
+ throw error;
11020
11118
  }
11021
- const isReady = !!preview;
11022
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
11023
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
11024
- isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
11119
+ const isReady = !isPending && !!order;
11120
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11121
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11122
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
11123
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
11124
+ ] }),
11125
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
11025
11126
  ] });
11026
11127
  };
11027
- const PromotionForm = ({ preview }) => {
11028
- const { items, shipping_methods } = preview;
11029
- const [isSubmitting, setIsSubmitting] = React.useState(false);
11030
- const [comboboxValue, setComboboxValue] = React.useState("");
11031
- const { handleSuccess } = useRouteModal();
11128
+ const EmailForm = ({ order }) => {
11129
+ const form = reactHookForm.useForm({
11130
+ defaultValues: {
11131
+ email: order.email ?? ""
11132
+ },
11133
+ resolver: zod.zodResolver(schema$3)
11134
+ });
11135
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11136
+ const { handleSuccess } = useRouteModal();
11137
+ const onSubmit = form.handleSubmit(async (data) => {
11138
+ await mutateAsync(
11139
+ { email: data.email },
11140
+ {
11141
+ onSuccess: () => {
11142
+ handleSuccess();
11143
+ },
11144
+ onError: (error) => {
11145
+ ui.toast.error(error.message);
11146
+ }
11147
+ }
11148
+ );
11149
+ });
11150
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11151
+ KeyboundForm,
11152
+ {
11153
+ className: "flex flex-1 flex-col overflow-hidden",
11154
+ onSubmit,
11155
+ children: [
11156
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
11157
+ Form$2.Field,
11158
+ {
11159
+ control: form.control,
11160
+ name: "email",
11161
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11162
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
11163
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11164
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11165
+ ] })
11166
+ }
11167
+ ) }),
11168
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11169
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11170
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11171
+ ] }) })
11172
+ ]
11173
+ }
11174
+ ) });
11175
+ };
11176
+ const schema$3 = objectType({
11177
+ email: stringType().email()
11178
+ });
11179
+ const PROMOTION_QUERY_KEY = "promotions";
11180
+ const promotionsQueryKeys = {
11181
+ list: (query2) => [
11182
+ PROMOTION_QUERY_KEY,
11183
+ query2 ? query2 : void 0
11184
+ ],
11185
+ detail: (id, query2) => [
11186
+ PROMOTION_QUERY_KEY,
11187
+ id,
11188
+ query2 ? query2 : void 0
11189
+ ]
11190
+ };
11191
+ const usePromotions = (query2, options) => {
11192
+ const { data, ...rest } = reactQuery.useQuery({
11193
+ queryKey: promotionsQueryKeys.list(query2),
11194
+ queryFn: async () => sdk.admin.promotion.list(query2),
11195
+ ...options
11196
+ });
11197
+ return { ...data, ...rest };
11198
+ };
11199
+ const Promotions = () => {
11200
+ const { id } = reactRouterDom.useParams();
11201
+ const {
11202
+ order: preview,
11203
+ isError: isPreviewError,
11204
+ error: previewError
11205
+ } = useOrderPreview(id, void 0);
11206
+ useInitiateOrderEdit({ preview });
11207
+ const { onCancel } = useCancelOrderEdit({ preview });
11208
+ if (isPreviewError) {
11209
+ throw previewError;
11210
+ }
11211
+ const isReady = !!preview;
11212
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
11213
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
11214
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
11215
+ ] });
11216
+ };
11217
+ const PromotionForm = ({ preview }) => {
11218
+ const { items, shipping_methods } = preview;
11219
+ const [isSubmitting, setIsSubmitting] = React.useState(false);
11220
+ const [comboboxValue, setComboboxValue] = React.useState("");
11221
+ const { handleSuccess } = useRouteModal();
11032
11222
  const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
11033
11223
  const promoIds = getPromotionIds(items, shipping_methods);
11034
11224
  const { promotions, isPending, isError, error } = usePromotions(
@@ -11263,112 +11453,6 @@ function getPromotionIds(items, shippingMethods) {
11263
11453
  }
11264
11454
  return Array.from(promotionIds);
11265
11455
  }
11266
- const SalesChannel = () => {
11267
- const { id } = reactRouterDom.useParams();
11268
- const { draft_order, isPending, isError, error } = useDraftOrder(
11269
- id,
11270
- {
11271
- fields: "+sales_channel_id"
11272
- },
11273
- {
11274
- enabled: !!id
11275
- }
11276
- );
11277
- if (isError) {
11278
- throw error;
11279
- }
11280
- const ISrEADY = !!draft_order && !isPending;
11281
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11282
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11283
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11284
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11285
- ] }),
11286
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11287
- ] });
11288
- };
11289
- const SalesChannelForm = ({ order }) => {
11290
- const form = reactHookForm.useForm({
11291
- defaultValues: {
11292
- sales_channel_id: order.sales_channel_id || ""
11293
- },
11294
- resolver: zod.zodResolver(schema$3)
11295
- });
11296
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11297
- const { handleSuccess } = useRouteModal();
11298
- const onSubmit = form.handleSubmit(async (data) => {
11299
- await mutateAsync(
11300
- {
11301
- sales_channel_id: data.sales_channel_id
11302
- },
11303
- {
11304
- onSuccess: () => {
11305
- ui.toast.success("Sales channel updated");
11306
- handleSuccess();
11307
- },
11308
- onError: (error) => {
11309
- ui.toast.error(error.message);
11310
- }
11311
- }
11312
- );
11313
- });
11314
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11315
- KeyboundForm,
11316
- {
11317
- className: "flex flex-1 flex-col overflow-hidden",
11318
- onSubmit,
11319
- children: [
11320
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11321
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11322
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11323
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11324
- ] }) })
11325
- ]
11326
- }
11327
- ) });
11328
- };
11329
- const SalesChannelField = ({ control, order }) => {
11330
- const salesChannels = useComboboxData({
11331
- queryFn: async (params) => {
11332
- return await sdk.admin.salesChannel.list(params);
11333
- },
11334
- queryKey: ["sales-channels"],
11335
- getOptions: (data) => {
11336
- return data.sales_channels.map((salesChannel) => ({
11337
- label: salesChannel.name,
11338
- value: salesChannel.id
11339
- }));
11340
- },
11341
- defaultValue: order.sales_channel_id || void 0
11342
- });
11343
- return /* @__PURE__ */ jsxRuntime.jsx(
11344
- Form$2.Field,
11345
- {
11346
- control,
11347
- name: "sales_channel_id",
11348
- render: ({ field }) => {
11349
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11350
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11351
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11352
- Combobox,
11353
- {
11354
- options: salesChannels.options,
11355
- fetchNextPage: salesChannels.fetchNextPage,
11356
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11357
- searchValue: salesChannels.searchValue,
11358
- onSearchValueChange: salesChannels.onSearchValueChange,
11359
- placeholder: "Select sales channel",
11360
- ...field
11361
- }
11362
- ) }),
11363
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11364
- ] });
11365
- }
11366
- }
11367
- );
11368
- };
11369
- const schema$3 = objectType({
11370
- sales_channel_id: stringType().min(1)
11371
- });
11372
11456
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11373
11457
  const Shipping = () => {
11374
11458
  var _a;
@@ -12652,37 +12736,33 @@ const Illustration = () => {
12652
12736
  const schema$2 = objectType({
12653
12737
  customer_id: stringType().min(1)
12654
12738
  });
12655
- const ShippingAddress = () => {
12739
+ const SalesChannel = () => {
12656
12740
  const { id } = reactRouterDom.useParams();
12657
- const { order, isPending, isError, error } = useOrder(id, {
12658
- fields: "+shipping_address"
12659
- });
12741
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12742
+ id,
12743
+ {
12744
+ fields: "+sales_channel_id"
12745
+ },
12746
+ {
12747
+ enabled: !!id
12748
+ }
12749
+ );
12660
12750
  if (isError) {
12661
12751
  throw error;
12662
12752
  }
12663
- const isReady = !isPending && !!order;
12753
+ const ISrEADY = !!draft_order && !isPending;
12664
12754
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12665
12755
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12666
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12667
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12756
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12757
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12668
12758
  ] }),
12669
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12759
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12670
12760
  ] });
12671
12761
  };
12672
- const ShippingAddressForm = ({ order }) => {
12673
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12762
+ const SalesChannelForm = ({ order }) => {
12674
12763
  const form = reactHookForm.useForm({
12675
12764
  defaultValues: {
12676
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12677
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12678
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12679
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12680
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12681
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12682
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12683
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12684
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12685
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12765
+ sales_channel_id: order.sales_channel_id || ""
12686
12766
  },
12687
12767
  resolver: zod.zodResolver(schema$1)
12688
12768
  });
@@ -12691,21 +12771,11 @@ const ShippingAddressForm = ({ order }) => {
12691
12771
  const onSubmit = form.handleSubmit(async (data) => {
12692
12772
  await mutateAsync(
12693
12773
  {
12694
- shipping_address: {
12695
- first_name: data.first_name,
12696
- last_name: data.last_name,
12697
- company: data.company,
12698
- address_1: data.address_1,
12699
- address_2: data.address_2,
12700
- city: data.city,
12701
- province: data.province,
12702
- country_code: data.country_code,
12703
- postal_code: data.postal_code,
12704
- phone: data.phone
12705
- }
12774
+ sales_channel_id: data.sales_channel_id
12706
12775
  },
12707
12776
  {
12708
12777
  onSuccess: () => {
12778
+ ui.toast.success("Sales channel updated");
12709
12779
  handleSuccess();
12710
12780
  },
12711
12781
  onError: (error) => {
@@ -12720,132 +12790,7 @@ const ShippingAddressForm = ({ order }) => {
12720
12790
  className: "flex flex-1 flex-col overflow-hidden",
12721
12791
  onSubmit,
12722
12792
  children: [
12723
- /* @__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: [
12724
- /* @__PURE__ */ jsxRuntime.jsx(
12725
- Form$2.Field,
12726
- {
12727
- control: form.control,
12728
- name: "country_code",
12729
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12730
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12731
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12732
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12733
- ] })
12734
- }
12735
- ),
12736
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12737
- /* @__PURE__ */ jsxRuntime.jsx(
12738
- Form$2.Field,
12739
- {
12740
- control: form.control,
12741
- name: "first_name",
12742
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12743
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12744
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12745
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12746
- ] })
12747
- }
12748
- ),
12749
- /* @__PURE__ */ jsxRuntime.jsx(
12750
- Form$2.Field,
12751
- {
12752
- control: form.control,
12753
- name: "last_name",
12754
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12755
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12756
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12757
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12758
- ] })
12759
- }
12760
- )
12761
- ] }),
12762
- /* @__PURE__ */ jsxRuntime.jsx(
12763
- Form$2.Field,
12764
- {
12765
- control: form.control,
12766
- name: "company",
12767
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12768
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12769
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12770
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12771
- ] })
12772
- }
12773
- ),
12774
- /* @__PURE__ */ jsxRuntime.jsx(
12775
- Form$2.Field,
12776
- {
12777
- control: form.control,
12778
- name: "address_1",
12779
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12780
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12781
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12782
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12783
- ] })
12784
- }
12785
- ),
12786
- /* @__PURE__ */ jsxRuntime.jsx(
12787
- Form$2.Field,
12788
- {
12789
- control: form.control,
12790
- name: "address_2",
12791
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12792
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12793
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12794
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12795
- ] })
12796
- }
12797
- ),
12798
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12799
- /* @__PURE__ */ jsxRuntime.jsx(
12800
- Form$2.Field,
12801
- {
12802
- control: form.control,
12803
- name: "postal_code",
12804
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12805
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12806
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12807
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12808
- ] })
12809
- }
12810
- ),
12811
- /* @__PURE__ */ jsxRuntime.jsx(
12812
- Form$2.Field,
12813
- {
12814
- control: form.control,
12815
- name: "city",
12816
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12817
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12818
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12819
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12820
- ] })
12821
- }
12822
- )
12823
- ] }),
12824
- /* @__PURE__ */ jsxRuntime.jsx(
12825
- Form$2.Field,
12826
- {
12827
- control: form.control,
12828
- name: "province",
12829
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12830
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12831
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12832
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12833
- ] })
12834
- }
12835
- ),
12836
- /* @__PURE__ */ jsxRuntime.jsx(
12837
- Form$2.Field,
12838
- {
12839
- control: form.control,
12840
- name: "phone",
12841
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12842
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12843
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12844
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12845
- ] })
12846
- }
12847
- )
12848
- ] }) }),
12793
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12849
12794
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12850
12795
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12851
12796
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -12854,11 +12799,53 @@ const ShippingAddressForm = ({ order }) => {
12854
12799
  }
12855
12800
  ) });
12856
12801
  };
12857
- const schema$1 = addressSchema;
12858
- const BillingAddress = () => {
12802
+ const SalesChannelField = ({ control, order }) => {
12803
+ const salesChannels = useComboboxData({
12804
+ queryFn: async (params) => {
12805
+ return await sdk.admin.salesChannel.list(params);
12806
+ },
12807
+ queryKey: ["sales-channels"],
12808
+ getOptions: (data) => {
12809
+ return data.sales_channels.map((salesChannel) => ({
12810
+ label: salesChannel.name,
12811
+ value: salesChannel.id
12812
+ }));
12813
+ },
12814
+ defaultValue: order.sales_channel_id || void 0
12815
+ });
12816
+ return /* @__PURE__ */ jsxRuntime.jsx(
12817
+ Form$2.Field,
12818
+ {
12819
+ control,
12820
+ name: "sales_channel_id",
12821
+ render: ({ field }) => {
12822
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12823
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12824
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12825
+ Combobox,
12826
+ {
12827
+ options: salesChannels.options,
12828
+ fetchNextPage: salesChannels.fetchNextPage,
12829
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
12830
+ searchValue: salesChannels.searchValue,
12831
+ onSearchValueChange: salesChannels.onSearchValueChange,
12832
+ placeholder: "Select sales channel",
12833
+ ...field
12834
+ }
12835
+ ) }),
12836
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12837
+ ] });
12838
+ }
12839
+ }
12840
+ );
12841
+ };
12842
+ const schema$1 = objectType({
12843
+ sales_channel_id: stringType().min(1)
12844
+ });
12845
+ const ShippingAddress = () => {
12859
12846
  const { id } = reactRouterDom.useParams();
12860
12847
  const { order, isPending, isError, error } = useOrder(id, {
12861
- fields: "+billing_address"
12848
+ fields: "+shipping_address"
12862
12849
  });
12863
12850
  if (isError) {
12864
12851
  throw error;
@@ -12866,26 +12853,26 @@ const BillingAddress = () => {
12866
12853
  const isReady = !isPending && !!order;
12867
12854
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12868
12855
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12869
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12870
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12856
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12857
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12871
12858
  ] }),
12872
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12859
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12873
12860
  ] });
12874
12861
  };
12875
- const BillingAddressForm = ({ order }) => {
12862
+ const ShippingAddressForm = ({ order }) => {
12876
12863
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12877
12864
  const form = reactHookForm.useForm({
12878
12865
  defaultValues: {
12879
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12880
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12881
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12882
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12883
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12884
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12885
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12886
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12887
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12888
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12866
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12867
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12868
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12869
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12870
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12871
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12872
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12873
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12874
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12875
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12889
12876
  },
12890
12877
  resolver: zod.zodResolver(schema)
12891
12878
  });
@@ -12893,7 +12880,20 @@ const BillingAddressForm = ({ order }) => {
12893
12880
  const { handleSuccess } = useRouteModal();
12894
12881
  const onSubmit = form.handleSubmit(async (data) => {
12895
12882
  await mutateAsync(
12896
- { billing_address: data },
12883
+ {
12884
+ shipping_address: {
12885
+ first_name: data.first_name,
12886
+ last_name: data.last_name,
12887
+ company: data.company,
12888
+ address_1: data.address_1,
12889
+ address_2: data.address_2,
12890
+ city: data.city,
12891
+ province: data.province,
12892
+ country_code: data.country_code,
12893
+ postal_code: data.postal_code,
12894
+ phone: data.phone
12895
+ }
12896
+ },
12897
12897
  {
12898
12898
  onSuccess: () => {
12899
12899
  handleSuccess();
@@ -13066,12 +13066,12 @@ const routeModule = {
13066
13066
  loader,
13067
13067
  children: [
13068
13068
  {
13069
- Component: CustomItems,
13070
- path: "/draft-orders/:id/custom-items"
13069
+ Component: BillingAddress,
13070
+ path: "/draft-orders/:id/billing-address"
13071
13071
  },
13072
13072
  {
13073
- Component: Email,
13074
- path: "/draft-orders/:id/email"
13073
+ Component: CustomItems,
13074
+ path: "/draft-orders/:id/custom-items"
13075
13075
  },
13076
13076
  {
13077
13077
  Component: Items,
@@ -13082,12 +13082,12 @@ const routeModule = {
13082
13082
  path: "/draft-orders/:id/metadata"
13083
13083
  },
13084
13084
  {
13085
- Component: Promotions,
13086
- path: "/draft-orders/:id/promotions"
13085
+ Component: Email,
13086
+ path: "/draft-orders/:id/email"
13087
13087
  },
13088
13088
  {
13089
- Component: SalesChannel,
13090
- path: "/draft-orders/:id/sales-channel"
13089
+ Component: Promotions,
13090
+ path: "/draft-orders/:id/promotions"
13091
13091
  },
13092
13092
  {
13093
13093
  Component: Shipping,
@@ -13098,12 +13098,12 @@ const routeModule = {
13098
13098
  path: "/draft-orders/:id/transfer-ownership"
13099
13099
  },
13100
13100
  {
13101
- Component: ShippingAddress,
13102
- path: "/draft-orders/:id/shipping-address"
13101
+ Component: SalesChannel,
13102
+ path: "/draft-orders/:id/sales-channel"
13103
13103
  },
13104
13104
  {
13105
- Component: BillingAddress,
13106
- path: "/draft-orders/:id/billing-address"
13105
+ Component: ShippingAddress,
13106
+ path: "/draft-orders/:id/shipping-address"
13107
13107
  }
13108
13108
  ]
13109
13109
  }