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