@medusajs/draft-order 2.10.2-preview-20250901090155 → 2.10.2-preview-20250901120156

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.
@@ -10617,196 +10617,6 @@ const customItemSchema = objectType({
10617
10617
  quantity: numberType(),
10618
10618
  unit_price: unionType([numberType(), stringType()])
10619
10619
  });
10620
- const BillingAddress = () => {
10621
- const { id } = useParams();
10622
- const { order, isPending, isError, error } = useOrder(id, {
10623
- fields: "+billing_address"
10624
- });
10625
- if (isError) {
10626
- throw error;
10627
- }
10628
- const isReady = !isPending && !!order;
10629
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
10630
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
10631
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
10632
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
10633
- ] }),
10634
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
10635
- ] });
10636
- };
10637
- const BillingAddressForm = ({ order }) => {
10638
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
10639
- const form = useForm({
10640
- defaultValues: {
10641
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
10642
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
10643
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
10644
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
10645
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
10646
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
10647
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
10648
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
10649
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
10650
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
10651
- },
10652
- resolver: zodResolver(schema$3)
10653
- });
10654
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10655
- const { handleSuccess } = useRouteModal();
10656
- const onSubmit = form.handleSubmit(async (data) => {
10657
- await mutateAsync(
10658
- { billing_address: data },
10659
- {
10660
- onSuccess: () => {
10661
- handleSuccess();
10662
- },
10663
- onError: (error) => {
10664
- toast.error(error.message);
10665
- }
10666
- }
10667
- );
10668
- });
10669
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
10670
- KeyboundForm,
10671
- {
10672
- className: "flex flex-1 flex-col overflow-hidden",
10673
- onSubmit,
10674
- children: [
10675
- /* @__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: [
10676
- /* @__PURE__ */ jsx(
10677
- Form$2.Field,
10678
- {
10679
- control: form.control,
10680
- name: "country_code",
10681
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10682
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
10683
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
10684
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10685
- ] })
10686
- }
10687
- ),
10688
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10689
- /* @__PURE__ */ jsx(
10690
- Form$2.Field,
10691
- {
10692
- control: form.control,
10693
- name: "first_name",
10694
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10695
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
10696
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10697
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10698
- ] })
10699
- }
10700
- ),
10701
- /* @__PURE__ */ jsx(
10702
- Form$2.Field,
10703
- {
10704
- control: form.control,
10705
- name: "last_name",
10706
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10707
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
10708
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10709
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10710
- ] })
10711
- }
10712
- )
10713
- ] }),
10714
- /* @__PURE__ */ jsx(
10715
- Form$2.Field,
10716
- {
10717
- control: form.control,
10718
- name: "company",
10719
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10720
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
10721
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10722
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10723
- ] })
10724
- }
10725
- ),
10726
- /* @__PURE__ */ jsx(
10727
- Form$2.Field,
10728
- {
10729
- control: form.control,
10730
- name: "address_1",
10731
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10732
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
10733
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10734
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10735
- ] })
10736
- }
10737
- ),
10738
- /* @__PURE__ */ jsx(
10739
- Form$2.Field,
10740
- {
10741
- control: form.control,
10742
- name: "address_2",
10743
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10744
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
10745
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10746
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10747
- ] })
10748
- }
10749
- ),
10750
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10751
- /* @__PURE__ */ jsx(
10752
- Form$2.Field,
10753
- {
10754
- control: form.control,
10755
- name: "postal_code",
10756
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10757
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
10758
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10759
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10760
- ] })
10761
- }
10762
- ),
10763
- /* @__PURE__ */ jsx(
10764
- Form$2.Field,
10765
- {
10766
- control: form.control,
10767
- name: "city",
10768
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10769
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
10770
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10771
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10772
- ] })
10773
- }
10774
- )
10775
- ] }),
10776
- /* @__PURE__ */ jsx(
10777
- Form$2.Field,
10778
- {
10779
- control: form.control,
10780
- name: "province",
10781
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10782
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
10783
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10784
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10785
- ] })
10786
- }
10787
- ),
10788
- /* @__PURE__ */ jsx(
10789
- Form$2.Field,
10790
- {
10791
- control: form.control,
10792
- name: "phone",
10793
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
10794
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
10795
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
10796
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10797
- ] })
10798
- }
10799
- )
10800
- ] }) }),
10801
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
10802
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10803
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10804
- ] }) })
10805
- ]
10806
- }
10807
- ) });
10808
- };
10809
- const schema$3 = addressSchema;
10810
10620
  const InlineTip = forwardRef(
10811
10621
  ({ variant = "tip", label, className, children, ...props }, ref) => {
10812
10622
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -11434,6 +11244,112 @@ function getPromotionCodes(items, shippingMethods) {
11434
11244
  }
11435
11245
  return Array.from(codes);
11436
11246
  }
11247
+ const SalesChannel = () => {
11248
+ const { id } = useParams();
11249
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11250
+ id,
11251
+ {
11252
+ fields: "+sales_channel_id"
11253
+ },
11254
+ {
11255
+ enabled: !!id
11256
+ }
11257
+ );
11258
+ if (isError) {
11259
+ throw error;
11260
+ }
11261
+ const ISrEADY = !!draft_order && !isPending;
11262
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11263
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11264
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11265
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11266
+ ] }),
11267
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11268
+ ] });
11269
+ };
11270
+ const SalesChannelForm = ({ order }) => {
11271
+ const form = useForm({
11272
+ defaultValues: {
11273
+ sales_channel_id: order.sales_channel_id || ""
11274
+ },
11275
+ resolver: zodResolver(schema$3)
11276
+ });
11277
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11278
+ const { handleSuccess } = useRouteModal();
11279
+ const onSubmit = form.handleSubmit(async (data) => {
11280
+ await mutateAsync(
11281
+ {
11282
+ sales_channel_id: data.sales_channel_id
11283
+ },
11284
+ {
11285
+ onSuccess: () => {
11286
+ toast.success("Sales channel updated");
11287
+ handleSuccess();
11288
+ },
11289
+ onError: (error) => {
11290
+ toast.error(error.message);
11291
+ }
11292
+ }
11293
+ );
11294
+ });
11295
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11296
+ KeyboundForm,
11297
+ {
11298
+ className: "flex flex-1 flex-col overflow-hidden",
11299
+ onSubmit,
11300
+ children: [
11301
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11302
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11303
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11304
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11305
+ ] }) })
11306
+ ]
11307
+ }
11308
+ ) });
11309
+ };
11310
+ const SalesChannelField = ({ control, order }) => {
11311
+ const salesChannels = useComboboxData({
11312
+ queryFn: async (params) => {
11313
+ return await sdk.admin.salesChannel.list(params);
11314
+ },
11315
+ queryKey: ["sales-channels"],
11316
+ getOptions: (data) => {
11317
+ return data.sales_channels.map((salesChannel) => ({
11318
+ label: salesChannel.name,
11319
+ value: salesChannel.id
11320
+ }));
11321
+ },
11322
+ defaultValue: order.sales_channel_id || void 0
11323
+ });
11324
+ return /* @__PURE__ */ jsx(
11325
+ Form$2.Field,
11326
+ {
11327
+ control,
11328
+ name: "sales_channel_id",
11329
+ render: ({ field }) => {
11330
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11331
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11332
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11333
+ Combobox,
11334
+ {
11335
+ options: salesChannels.options,
11336
+ fetchNextPage: salesChannels.fetchNextPage,
11337
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11338
+ searchValue: salesChannels.searchValue,
11339
+ onSearchValueChange: salesChannels.onSearchValueChange,
11340
+ placeholder: "Select sales channel",
11341
+ ...field
11342
+ }
11343
+ ) }),
11344
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11345
+ ] });
11346
+ }
11347
+ }
11348
+ );
11349
+ };
11350
+ const schema$3 = objectType({
11351
+ sales_channel_id: stringType().min(1)
11352
+ });
11437
11353
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11438
11354
  const Shipping = () => {
11439
11355
  var _a;
@@ -12212,141 +12128,35 @@ const ShippingOptionField = ({
12212
12128
  }
12213
12129
  );
12214
12130
  };
12215
- const CustomAmountField = ({
12216
- control,
12217
- currencyCode
12218
- }) => {
12219
- return /* @__PURE__ */ jsx(
12220
- Form$2.Field,
12221
- {
12222
- control,
12223
- name: "custom_amount",
12224
- render: ({ field: { onChange, ...field } }) => {
12225
- return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12226
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12227
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12228
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12229
- ] }),
12230
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12231
- CurrencyInput,
12232
- {
12233
- ...field,
12234
- onValueChange: (value) => onChange(value),
12235
- symbol: getNativeSymbol(currencyCode),
12236
- code: currencyCode
12237
- }
12238
- ) })
12239
- ] });
12240
- }
12241
- }
12242
- );
12243
- };
12244
- const SalesChannel = () => {
12245
- const { id } = useParams();
12246
- const { draft_order, isPending, isError, error } = useDraftOrder(
12247
- id,
12248
- {
12249
- fields: "+sales_channel_id"
12250
- },
12251
- {
12252
- enabled: !!id
12253
- }
12254
- );
12255
- if (isError) {
12256
- throw error;
12257
- }
12258
- const ISrEADY = !!draft_order && !isPending;
12259
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12260
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12261
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12262
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12263
- ] }),
12264
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12265
- ] });
12266
- };
12267
- const SalesChannelForm = ({ order }) => {
12268
- const form = useForm({
12269
- defaultValues: {
12270
- sales_channel_id: order.sales_channel_id || ""
12271
- },
12272
- resolver: zodResolver(schema$2)
12273
- });
12274
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12275
- const { handleSuccess } = useRouteModal();
12276
- const onSubmit = form.handleSubmit(async (data) => {
12277
- await mutateAsync(
12278
- {
12279
- sales_channel_id: data.sales_channel_id
12280
- },
12281
- {
12282
- onSuccess: () => {
12283
- toast.success("Sales channel updated");
12284
- handleSuccess();
12285
- },
12286
- onError: (error) => {
12287
- toast.error(error.message);
12288
- }
12289
- }
12290
- );
12291
- });
12292
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12293
- KeyboundForm,
12294
- {
12295
- className: "flex flex-1 flex-col overflow-hidden",
12296
- onSubmit,
12297
- children: [
12298
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12299
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12300
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12301
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12302
- ] }) })
12303
- ]
12304
- }
12305
- ) });
12306
- };
12307
- const SalesChannelField = ({ control, order }) => {
12308
- const salesChannels = useComboboxData({
12309
- queryFn: async (params) => {
12310
- return await sdk.admin.salesChannel.list(params);
12311
- },
12312
- queryKey: ["sales-channels"],
12313
- getOptions: (data) => {
12314
- return data.sales_channels.map((salesChannel) => ({
12315
- label: salesChannel.name,
12316
- value: salesChannel.id
12317
- }));
12318
- },
12319
- defaultValue: order.sales_channel_id || void 0
12320
- });
12131
+ const CustomAmountField = ({
12132
+ control,
12133
+ currencyCode
12134
+ }) => {
12321
12135
  return /* @__PURE__ */ jsx(
12322
12136
  Form$2.Field,
12323
12137
  {
12324
12138
  control,
12325
- name: "sales_channel_id",
12326
- render: ({ field }) => {
12327
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12328
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12139
+ name: "custom_amount",
12140
+ render: ({ field: { onChange, ...field } }) => {
12141
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12142
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12143
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12144
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12145
+ ] }),
12329
12146
  /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12330
- Combobox,
12147
+ CurrencyInput,
12331
12148
  {
12332
- options: salesChannels.options,
12333
- fetchNextPage: salesChannels.fetchNextPage,
12334
- isFetchingNextPage: salesChannels.isFetchingNextPage,
12335
- searchValue: salesChannels.searchValue,
12336
- onSearchValueChange: salesChannels.onSearchValueChange,
12337
- placeholder: "Select sales channel",
12338
- ...field
12149
+ ...field,
12150
+ onValueChange: (value) => onChange(value),
12151
+ symbol: getNativeSymbol(currencyCode),
12152
+ code: currencyCode
12339
12153
  }
12340
- ) }),
12341
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12154
+ ) })
12342
12155
  ] });
12343
12156
  }
12344
12157
  }
12345
12158
  );
12346
12159
  };
12347
- const schema$2 = objectType({
12348
- sales_channel_id: stringType().min(1)
12349
- });
12350
12160
  const ShippingAddress = () => {
12351
12161
  const { id } = useParams();
12352
12162
  const { order, isPending, isError, error } = useOrder(id, {
@@ -12379,7 +12189,7 @@ const ShippingAddressForm = ({ order }) => {
12379
12189
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12380
12190
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12381
12191
  },
12382
- resolver: zodResolver(schema$1)
12192
+ resolver: zodResolver(schema$2)
12383
12193
  });
12384
12194
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12385
12195
  const { handleSuccess } = useRouteModal();
@@ -12549,7 +12359,7 @@ const ShippingAddressForm = ({ order }) => {
12549
12359
  }
12550
12360
  ) });
12551
12361
  };
12552
- const schema$1 = addressSchema;
12362
+ const schema$2 = addressSchema;
12553
12363
  const TransferOwnership = () => {
12554
12364
  const { id } = useParams();
12555
12365
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12573,7 +12383,7 @@ const TransferOwnershipForm = ({ order }) => {
12573
12383
  defaultValues: {
12574
12384
  customer_id: order.customer_id || ""
12575
12385
  },
12576
- resolver: zodResolver(schema)
12386
+ resolver: zodResolver(schema$1)
12577
12387
  });
12578
12388
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12579
12389
  const { handleSuccess } = useRouteModal();
@@ -13023,9 +12833,199 @@ const Illustration = () => {
13023
12833
  }
13024
12834
  );
13025
12835
  };
13026
- const schema = objectType({
12836
+ const schema$1 = objectType({
13027
12837
  customer_id: stringType().min(1)
13028
12838
  });
12839
+ const BillingAddress = () => {
12840
+ const { id } = useParams();
12841
+ const { order, isPending, isError, error } = useOrder(id, {
12842
+ fields: "+billing_address"
12843
+ });
12844
+ if (isError) {
12845
+ throw error;
12846
+ }
12847
+ const isReady = !isPending && !!order;
12848
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12849
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12850
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
12851
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12852
+ ] }),
12853
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
12854
+ ] });
12855
+ };
12856
+ const BillingAddressForm = ({ order }) => {
12857
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12858
+ const form = useForm({
12859
+ defaultValues: {
12860
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12861
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12862
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12863
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12864
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12865
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12866
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12867
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12868
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12869
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12870
+ },
12871
+ resolver: zodResolver(schema)
12872
+ });
12873
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12874
+ const { handleSuccess } = useRouteModal();
12875
+ const onSubmit = form.handleSubmit(async (data) => {
12876
+ await mutateAsync(
12877
+ { billing_address: data },
12878
+ {
12879
+ onSuccess: () => {
12880
+ handleSuccess();
12881
+ },
12882
+ onError: (error) => {
12883
+ toast.error(error.message);
12884
+ }
12885
+ }
12886
+ );
12887
+ });
12888
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12889
+ KeyboundForm,
12890
+ {
12891
+ className: "flex flex-1 flex-col overflow-hidden",
12892
+ onSubmit,
12893
+ children: [
12894
+ /* @__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: [
12895
+ /* @__PURE__ */ jsx(
12896
+ Form$2.Field,
12897
+ {
12898
+ control: form.control,
12899
+ name: "country_code",
12900
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12901
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12902
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12903
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12904
+ ] })
12905
+ }
12906
+ ),
12907
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12908
+ /* @__PURE__ */ jsx(
12909
+ Form$2.Field,
12910
+ {
12911
+ control: form.control,
12912
+ name: "first_name",
12913
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12914
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12915
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12916
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12917
+ ] })
12918
+ }
12919
+ ),
12920
+ /* @__PURE__ */ jsx(
12921
+ Form$2.Field,
12922
+ {
12923
+ control: form.control,
12924
+ name: "last_name",
12925
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12926
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12927
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12928
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12929
+ ] })
12930
+ }
12931
+ )
12932
+ ] }),
12933
+ /* @__PURE__ */ jsx(
12934
+ Form$2.Field,
12935
+ {
12936
+ control: form.control,
12937
+ name: "company",
12938
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12939
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12940
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12941
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12942
+ ] })
12943
+ }
12944
+ ),
12945
+ /* @__PURE__ */ jsx(
12946
+ Form$2.Field,
12947
+ {
12948
+ control: form.control,
12949
+ name: "address_1",
12950
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12951
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12952
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12953
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12954
+ ] })
12955
+ }
12956
+ ),
12957
+ /* @__PURE__ */ jsx(
12958
+ Form$2.Field,
12959
+ {
12960
+ control: form.control,
12961
+ name: "address_2",
12962
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12963
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12964
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12965
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12966
+ ] })
12967
+ }
12968
+ ),
12969
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12970
+ /* @__PURE__ */ jsx(
12971
+ Form$2.Field,
12972
+ {
12973
+ control: form.control,
12974
+ name: "postal_code",
12975
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12976
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12977
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12978
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12979
+ ] })
12980
+ }
12981
+ ),
12982
+ /* @__PURE__ */ jsx(
12983
+ Form$2.Field,
12984
+ {
12985
+ control: form.control,
12986
+ name: "city",
12987
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12988
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12989
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12990
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12991
+ ] })
12992
+ }
12993
+ )
12994
+ ] }),
12995
+ /* @__PURE__ */ jsx(
12996
+ Form$2.Field,
12997
+ {
12998
+ control: form.control,
12999
+ name: "province",
13000
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13001
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13002
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13003
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13004
+ ] })
13005
+ }
13006
+ ),
13007
+ /* @__PURE__ */ jsx(
13008
+ Form$2.Field,
13009
+ {
13010
+ control: form.control,
13011
+ name: "phone",
13012
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13013
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13014
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13015
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13016
+ ] })
13017
+ }
13018
+ )
13019
+ ] }) }),
13020
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13021
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13022
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13023
+ ] }) })
13024
+ ]
13025
+ }
13026
+ ) });
13027
+ };
13028
+ const schema = addressSchema;
13029
13029
  const widgetModule = { widgets: [] };
13030
13030
  const routeModule = {
13031
13031
  routes: [
@@ -13058,10 +13058,6 @@ const routeModule = {
13058
13058
  Component: Items,
13059
13059
  path: "/draft-orders/:id/items"
13060
13060
  },
13061
- {
13062
- Component: BillingAddress,
13063
- path: "/draft-orders/:id/billing-address"
13064
- },
13065
13061
  {
13066
13062
  Component: Metadata,
13067
13063
  path: "/draft-orders/:id/metadata"
@@ -13070,14 +13066,14 @@ const routeModule = {
13070
13066
  Component: Promotions,
13071
13067
  path: "/draft-orders/:id/promotions"
13072
13068
  },
13073
- {
13074
- Component: Shipping,
13075
- path: "/draft-orders/:id/shipping"
13076
- },
13077
13069
  {
13078
13070
  Component: SalesChannel,
13079
13071
  path: "/draft-orders/:id/sales-channel"
13080
13072
  },
13073
+ {
13074
+ Component: Shipping,
13075
+ path: "/draft-orders/:id/shipping"
13076
+ },
13081
13077
  {
13082
13078
  Component: ShippingAddress,
13083
13079
  path: "/draft-orders/:id/shipping-address"
@@ -13085,6 +13081,10 @@ const routeModule = {
13085
13081
  {
13086
13082
  Component: TransferOwnership,
13087
13083
  path: "/draft-orders/:id/transfer-ownership"
13084
+ },
13085
+ {
13086
+ Component: BillingAddress,
13087
+ path: "/draft-orders/:id/billing-address"
13088
13088
  }
13089
13089
  ]
13090
13090
  }