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

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.
@@ -9560,27 +9560,6 @@ const ID = () => {
9560
9560
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9561
9561
  ] });
9562
9562
  };
9563
- const CustomItems = () => {
9564
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9565
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9566
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9567
- ] });
9568
- };
9569
- const CustomItemsForm = () => {
9570
- const form = reactHookForm.useForm({
9571
- resolver: zod.zodResolver(schema$5)
9572
- });
9573
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9574
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9575
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9576
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9577
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9578
- ] }) })
9579
- ] }) });
9580
- };
9581
- const schema$5 = objectType({
9582
- email: stringType().email()
9583
- });
9584
9563
  const Email = () => {
9585
9564
  const { id } = reactRouterDom.useParams();
9586
9565
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9603,7 +9582,7 @@ const EmailForm = ({ order }) => {
9603
9582
  defaultValues: {
9604
9583
  email: order.email ?? ""
9605
9584
  },
9606
- resolver: zod.zodResolver(schema$4)
9585
+ resolver: zod.zodResolver(schema$5)
9607
9586
  });
9608
9587
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9609
9588
  const { handleSuccess } = useRouteModal();
@@ -9646,7 +9625,7 @@ const EmailForm = ({ order }) => {
9646
9625
  }
9647
9626
  ) });
9648
9627
  };
9649
- const schema$4 = objectType({
9628
+ const schema$5 = objectType({
9650
9629
  email: stringType().email()
9651
9630
  });
9652
9631
  const NumberInput = React.forwardRef(
@@ -10623,196 +10602,27 @@ const customItemSchema = objectType({
10623
10602
  quantity: numberType(),
10624
10603
  unit_price: unionType([numberType(), stringType()])
10625
10604
  });
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;
10605
+ const CustomItems = () => {
10635
10606
  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 })
10607
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
10608
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
10641
10609
  ] });
10642
10610
  };
10643
- const BillingAddressForm = ({ order }) => {
10644
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
10611
+ const CustomItemsForm = () => {
10645
10612
  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
- );
10613
+ resolver: zod.zodResolver(schema$4)
10674
10614
  });
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
- ) });
10615
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
10616
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
10617
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10618
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10619
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
10620
+ ] }) })
10621
+ ] }) });
10814
10622
  };
10815
- const schema$3 = addressSchema;
10623
+ const schema$4 = objectType({
10624
+ email: stringType().email()
10625
+ });
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,33 +11250,342 @@ function getPromotionCodes(items, shippingMethods) {
11440
11250
  }
11441
11251
  return Array.from(codes);
11442
11252
  }
11443
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
11444
- const Shipping = () => {
11445
- var _a;
11253
+ const SalesChannel = () => {
11446
11254
  const { id } = reactRouterDom.useParams();
11447
- const { order, isPending, isError, error } = useOrder(id, {
11448
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11449
- });
11450
- const {
11451
- order: preview,
11452
- isPending: isPreviewPending,
11453
- isError: isPreviewError,
11454
- error: previewError
11455
- } = useOrderPreview(id);
11456
- useInitiateOrderEdit({ preview });
11457
- const { onCancel } = useCancelOrderEdit({ preview });
11255
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11256
+ id,
11257
+ {
11258
+ fields: "+sales_channel_id"
11259
+ },
11260
+ {
11261
+ enabled: !!id
11262
+ }
11263
+ );
11458
11264
  if (isError) {
11459
11265
  throw error;
11460
11266
  }
11461
- if (isPreviewError) {
11462
- throw previewError;
11463
- }
11464
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11465
- const isReady = preview && !isPreviewPending && order && !isPending;
11466
- return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11467
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11468
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
11469
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
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
+ });
11359
+ const ShippingAddress = () => {
11360
+ const { id } = reactRouterDom.useParams();
11361
+ const { order, isPending, isError, error } = useOrder(id, {
11362
+ fields: "+shipping_address"
11363
+ });
11364
+ if (isError) {
11365
+ throw error;
11366
+ }
11367
+ const isReady = !isPending && !!order;
11368
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11369
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11370
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
11371
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11372
+ ] }),
11373
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
11374
+ ] });
11375
+ };
11376
+ const ShippingAddressForm = ({ order }) => {
11377
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11378
+ const form = reactHookForm.useForm({
11379
+ defaultValues: {
11380
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11381
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11382
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11383
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11384
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11385
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11386
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11387
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11388
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11389
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11390
+ },
11391
+ resolver: zod.zodResolver(schema$2)
11392
+ });
11393
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11394
+ const { handleSuccess } = useRouteModal();
11395
+ const onSubmit = form.handleSubmit(async (data) => {
11396
+ await mutateAsync(
11397
+ {
11398
+ shipping_address: {
11399
+ first_name: data.first_name,
11400
+ last_name: data.last_name,
11401
+ company: data.company,
11402
+ address_1: data.address_1,
11403
+ address_2: data.address_2,
11404
+ city: data.city,
11405
+ province: data.province,
11406
+ country_code: data.country_code,
11407
+ postal_code: data.postal_code,
11408
+ phone: data.phone
11409
+ }
11410
+ },
11411
+ {
11412
+ onSuccess: () => {
11413
+ handleSuccess();
11414
+ },
11415
+ onError: (error) => {
11416
+ ui.toast.error(error.message);
11417
+ }
11418
+ }
11419
+ );
11420
+ });
11421
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11422
+ KeyboundForm,
11423
+ {
11424
+ className: "flex flex-1 flex-col overflow-hidden",
11425
+ onSubmit,
11426
+ children: [
11427
+ /* @__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: [
11428
+ /* @__PURE__ */ jsxRuntime.jsx(
11429
+ Form$2.Field,
11430
+ {
11431
+ control: form.control,
11432
+ name: "country_code",
11433
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11434
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11435
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11436
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11437
+ ] })
11438
+ }
11439
+ ),
11440
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11441
+ /* @__PURE__ */ jsxRuntime.jsx(
11442
+ Form$2.Field,
11443
+ {
11444
+ control: form.control,
11445
+ name: "first_name",
11446
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11447
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11448
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11449
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11450
+ ] })
11451
+ }
11452
+ ),
11453
+ /* @__PURE__ */ jsxRuntime.jsx(
11454
+ Form$2.Field,
11455
+ {
11456
+ control: form.control,
11457
+ name: "last_name",
11458
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11459
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11460
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11461
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11462
+ ] })
11463
+ }
11464
+ )
11465
+ ] }),
11466
+ /* @__PURE__ */ jsxRuntime.jsx(
11467
+ Form$2.Field,
11468
+ {
11469
+ control: form.control,
11470
+ name: "company",
11471
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11472
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11473
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11474
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11475
+ ] })
11476
+ }
11477
+ ),
11478
+ /* @__PURE__ */ jsxRuntime.jsx(
11479
+ Form$2.Field,
11480
+ {
11481
+ control: form.control,
11482
+ name: "address_1",
11483
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11484
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11485
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11486
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11487
+ ] })
11488
+ }
11489
+ ),
11490
+ /* @__PURE__ */ jsxRuntime.jsx(
11491
+ Form$2.Field,
11492
+ {
11493
+ control: form.control,
11494
+ name: "address_2",
11495
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11496
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11497
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11498
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11499
+ ] })
11500
+ }
11501
+ ),
11502
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11503
+ /* @__PURE__ */ jsxRuntime.jsx(
11504
+ Form$2.Field,
11505
+ {
11506
+ control: form.control,
11507
+ name: "postal_code",
11508
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11509
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11510
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11511
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11512
+ ] })
11513
+ }
11514
+ ),
11515
+ /* @__PURE__ */ jsxRuntime.jsx(
11516
+ Form$2.Field,
11517
+ {
11518
+ control: form.control,
11519
+ name: "city",
11520
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11521
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11522
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11523
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11524
+ ] })
11525
+ }
11526
+ )
11527
+ ] }),
11528
+ /* @__PURE__ */ jsxRuntime.jsx(
11529
+ Form$2.Field,
11530
+ {
11531
+ control: form.control,
11532
+ name: "province",
11533
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11534
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11535
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11536
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11537
+ ] })
11538
+ }
11539
+ ),
11540
+ /* @__PURE__ */ jsxRuntime.jsx(
11541
+ Form$2.Field,
11542
+ {
11543
+ control: form.control,
11544
+ name: "phone",
11545
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11546
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11547
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11548
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11549
+ ] })
11550
+ }
11551
+ )
11552
+ ] }) }),
11553
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11554
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11555
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11556
+ ] }) })
11557
+ ]
11558
+ }
11559
+ ) });
11560
+ };
11561
+ const schema$2 = addressSchema;
11562
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11563
+ const Shipping = () => {
11564
+ var _a;
11565
+ const { id } = reactRouterDom.useParams();
11566
+ const { order, isPending, isError, error } = useOrder(id, {
11567
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11568
+ });
11569
+ const {
11570
+ order: preview,
11571
+ isPending: isPreviewPending,
11572
+ isError: isPreviewError,
11573
+ error: previewError
11574
+ } = useOrderPreview(id);
11575
+ useInitiateOrderEdit({ preview });
11576
+ const { onCancel } = useCancelOrderEdit({ preview });
11577
+ if (isError) {
11578
+ throw error;
11579
+ }
11580
+ if (isPreviewError) {
11581
+ throw previewError;
11582
+ }
11583
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11584
+ const isReady = preview && !isPreviewPending && order && !isPending;
11585
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11586
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
11587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
11588
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
11470
11589
  /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
11471
11590
  ] }) }) }),
11472
11591
  /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
@@ -12146,416 +12265,107 @@ const LocationField = ({ control, setValue }) => {
12146
12265
  ] }) });
12147
12266
  }
12148
12267
  }
12149
- );
12150
- };
12151
- const ShippingOptionField = ({
12152
- shippingProfileId,
12153
- preview,
12154
- control
12155
- }) => {
12156
- var _a;
12157
- const locationId = reactHookForm.useWatch({ control, name: "location_id" });
12158
- const shippingOptions = useComboboxData({
12159
- queryKey: ["shipping_options", locationId, shippingProfileId],
12160
- queryFn: async (params) => {
12161
- return await sdk.admin.shippingOption.list({
12162
- ...params,
12163
- stock_location_id: locationId,
12164
- shipping_profile_id: shippingProfileId
12165
- });
12166
- },
12167
- getOptions: (data) => {
12168
- return data.shipping_options.map((option) => {
12169
- var _a2;
12170
- if ((_a2 = option.rules) == null ? void 0 : _a2.find(
12171
- (r) => r.attribute === "is_return" && r.value === "true"
12172
- )) {
12173
- return void 0;
12174
- }
12175
- return {
12176
- label: option.name,
12177
- value: option.id
12178
- };
12179
- }).filter(Boolean);
12180
- },
12181
- enabled: !!locationId && !!shippingProfileId,
12182
- defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
12183
- });
12184
- const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
12185
- return /* @__PURE__ */ jsxRuntime.jsx(
12186
- Form$2.Field,
12187
- {
12188
- control,
12189
- name: "shipping_option_id",
12190
- render: ({ field }) => {
12191
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12192
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12193
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
12194
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12195
- ] }),
12196
- /* @__PURE__ */ jsxRuntime.jsx(
12197
- ConditionalTooltip,
12198
- {
12199
- content: tooltipContent,
12200
- showTooltip: !locationId || !shippingProfileId,
12201
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12202
- Combobox,
12203
- {
12204
- options: shippingOptions.options,
12205
- fetchNextPage: shippingOptions.fetchNextPage,
12206
- isFetchingNextPage: shippingOptions.isFetchingNextPage,
12207
- searchValue: shippingOptions.searchValue,
12208
- onSearchValueChange: shippingOptions.onSearchValueChange,
12209
- placeholder: "Select shipping option",
12210
- ...field,
12211
- disabled: !locationId || !shippingProfileId
12212
- }
12213
- ) }) })
12214
- }
12215
- )
12216
- ] }) });
12217
- }
12218
- }
12219
- );
12220
- };
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
- ) });
12268
+ );
12312
12269
  };
12313
- const SalesChannelField = ({ control, order }) => {
12314
- const salesChannels = useComboboxData({
12270
+ const ShippingOptionField = ({
12271
+ shippingProfileId,
12272
+ preview,
12273
+ control
12274
+ }) => {
12275
+ var _a;
12276
+ const locationId = reactHookForm.useWatch({ control, name: "location_id" });
12277
+ const shippingOptions = useComboboxData({
12278
+ queryKey: ["shipping_options", locationId, shippingProfileId],
12315
12279
  queryFn: async (params) => {
12316
- return await sdk.admin.salesChannel.list(params);
12280
+ return await sdk.admin.shippingOption.list({
12281
+ ...params,
12282
+ stock_location_id: locationId,
12283
+ shipping_profile_id: shippingProfileId
12284
+ });
12317
12285
  },
12318
- queryKey: ["sales-channels"],
12319
12286
  getOptions: (data) => {
12320
- return data.sales_channels.map((salesChannel) => ({
12321
- label: salesChannel.name,
12322
- value: salesChannel.id
12323
- }));
12287
+ return data.shipping_options.map((option) => {
12288
+ var _a2;
12289
+ if ((_a2 = option.rules) == null ? void 0 : _a2.find(
12290
+ (r) => r.attribute === "is_return" && r.value === "true"
12291
+ )) {
12292
+ return void 0;
12293
+ }
12294
+ return {
12295
+ label: option.name,
12296
+ value: option.id
12297
+ };
12298
+ }).filter(Boolean);
12324
12299
  },
12325
- defaultValue: order.sales_channel_id || void 0
12300
+ enabled: !!locationId && !!shippingProfileId,
12301
+ defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
12326
12302
  });
12303
+ const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
12327
12304
  return /* @__PURE__ */ jsxRuntime.jsx(
12328
12305
  Form$2.Field,
12329
12306
  {
12330
12307
  control,
12331
- name: "sales_channel_id",
12308
+ name: "shipping_option_id",
12332
12309
  render: ({ field }) => {
12333
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12334
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
12335
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12336
- Combobox,
12310
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12311
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12312
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
12313
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12314
+ ] }),
12315
+ /* @__PURE__ */ jsxRuntime.jsx(
12316
+ ConditionalTooltip,
12337
12317
  {
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
12318
+ content: tooltipContent,
12319
+ showTooltip: !locationId || !shippingProfileId,
12320
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12321
+ Combobox,
12322
+ {
12323
+ options: shippingOptions.options,
12324
+ fetchNextPage: shippingOptions.fetchNextPage,
12325
+ isFetchingNextPage: shippingOptions.isFetchingNextPage,
12326
+ searchValue: shippingOptions.searchValue,
12327
+ onSearchValueChange: shippingOptions.onSearchValueChange,
12328
+ placeholder: "Select shipping option",
12329
+ ...field,
12330
+ disabled: !locationId || !shippingProfileId
12331
+ }
12332
+ ) }) })
12345
12333
  }
12346
- ) }),
12347
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12348
- ] });
12334
+ )
12335
+ ] }) });
12349
12336
  }
12350
12337
  }
12351
12338
  );
12352
12339
  };
12353
- const schema$2 = objectType({
12354
- sales_channel_id: stringType().min(1)
12355
- });
12356
- const ShippingAddress = () => {
12357
- const { id } = reactRouterDom.useParams();
12358
- const { order, isPending, isError, error } = useOrder(id, {
12359
- fields: "+shipping_address"
12360
- });
12361
- if (isError) {
12362
- throw error;
12363
- }
12364
- const isReady = !isPending && !!order;
12365
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12366
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12367
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12368
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12369
- ] }),
12370
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12371
- ] });
12372
- };
12373
- const ShippingAddressForm = ({ order }) => {
12374
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12375
- const form = reactHookForm.useForm({
12376
- defaultValues: {
12377
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12378
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12379
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12380
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12381
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12382
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12383
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12384
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12385
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12386
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12387
- },
12388
- resolver: zod.zodResolver(schema$1)
12389
- });
12390
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12391
- const { handleSuccess } = useRouteModal();
12392
- const onSubmit = form.handleSubmit(async (data) => {
12393
- await mutateAsync(
12394
- {
12395
- shipping_address: {
12396
- first_name: data.first_name,
12397
- last_name: data.last_name,
12398
- company: data.company,
12399
- address_1: data.address_1,
12400
- address_2: data.address_2,
12401
- city: data.city,
12402
- province: data.province,
12403
- country_code: data.country_code,
12404
- postal_code: data.postal_code,
12405
- phone: data.phone
12406
- }
12407
- },
12408
- {
12409
- onSuccess: () => {
12410
- handleSuccess();
12411
- },
12412
- onError: (error) => {
12413
- ui.toast.error(error.message);
12414
- }
12415
- }
12416
- );
12417
- });
12418
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12419
- KeyboundForm,
12340
+ const CustomAmountField = ({
12341
+ control,
12342
+ currencyCode
12343
+ }) => {
12344
+ return /* @__PURE__ */ jsxRuntime.jsx(
12345
+ Form$2.Field,
12420
12346
  {
12421
- className: "flex flex-1 flex-col overflow-hidden",
12422
- onSubmit,
12423
- children: [
12424
- /* @__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: [
12425
- /* @__PURE__ */ jsxRuntime.jsx(
12426
- Form$2.Field,
12427
- {
12428
- control: form.control,
12429
- name: "country_code",
12430
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12431
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12432
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12433
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12434
- ] })
12435
- }
12436
- ),
12437
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12438
- /* @__PURE__ */ jsxRuntime.jsx(
12439
- Form$2.Field,
12440
- {
12441
- control: form.control,
12442
- name: "first_name",
12443
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12444
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12445
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12446
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12447
- ] })
12448
- }
12449
- ),
12450
- /* @__PURE__ */ jsxRuntime.jsx(
12451
- Form$2.Field,
12452
- {
12453
- control: form.control,
12454
- name: "last_name",
12455
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12456
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12457
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12458
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12459
- ] })
12460
- }
12461
- )
12462
- ] }),
12463
- /* @__PURE__ */ jsxRuntime.jsx(
12464
- Form$2.Field,
12465
- {
12466
- control: form.control,
12467
- name: "company",
12468
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12469
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12470
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12471
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12472
- ] })
12473
- }
12474
- ),
12475
- /* @__PURE__ */ jsxRuntime.jsx(
12476
- Form$2.Field,
12477
- {
12478
- control: form.control,
12479
- name: "address_1",
12480
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12481
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12482
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12483
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12484
- ] })
12485
- }
12486
- ),
12487
- /* @__PURE__ */ jsxRuntime.jsx(
12488
- Form$2.Field,
12489
- {
12490
- control: form.control,
12491
- name: "address_2",
12492
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12493
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12494
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12495
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12496
- ] })
12497
- }
12498
- ),
12499
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12500
- /* @__PURE__ */ jsxRuntime.jsx(
12501
- Form$2.Field,
12502
- {
12503
- control: form.control,
12504
- name: "postal_code",
12505
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12506
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12507
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12508
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12509
- ] })
12510
- }
12511
- ),
12512
- /* @__PURE__ */ jsxRuntime.jsx(
12513
- Form$2.Field,
12514
- {
12515
- control: form.control,
12516
- name: "city",
12517
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12518
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12519
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12520
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12521
- ] })
12522
- }
12523
- )
12347
+ control,
12348
+ name: "custom_amount",
12349
+ render: ({ field: { onChange, ...field } }) => {
12350
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12351
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12352
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12353
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12524
12354
  ] }),
12525
- /* @__PURE__ */ jsxRuntime.jsx(
12526
- Form$2.Field,
12527
- {
12528
- control: form.control,
12529
- name: "province",
12530
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12531
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12532
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12533
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12534
- ] })
12535
- }
12536
- ),
12537
- /* @__PURE__ */ jsxRuntime.jsx(
12538
- Form$2.Field,
12355
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12356
+ ui.CurrencyInput,
12539
12357
  {
12540
- control: form.control,
12541
- name: "phone",
12542
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12543
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12544
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12545
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12546
- ] })
12358
+ ...field,
12359
+ onValueChange: (value) => onChange(value),
12360
+ symbol: getNativeSymbol(currencyCode),
12361
+ code: currencyCode
12547
12362
  }
12548
- )
12549
- ] }) }),
12550
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12551
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12552
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12553
- ] }) })
12554
- ]
12363
+ ) })
12364
+ ] });
12365
+ }
12555
12366
  }
12556
- ) });
12367
+ );
12557
12368
  };
12558
- const schema$1 = 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: [
@@ -13052,10 +13052,6 @@ const routeModule = {
13052
13052
  handle,
13053
13053
  loader,
13054
13054
  children: [
13055
- {
13056
- Component: CustomItems,
13057
- path: "/draft-orders/:id/custom-items"
13058
- },
13059
13055
  {
13060
13056
  Component: Email,
13061
13057
  path: "/draft-orders/:id/email"
@@ -13065,8 +13061,8 @@ const routeModule = {
13065
13061
  path: "/draft-orders/:id/items"
13066
13062
  },
13067
13063
  {
13068
- Component: BillingAddress,
13069
- path: "/draft-orders/:id/billing-address"
13064
+ Component: CustomItems,
13065
+ path: "/draft-orders/:id/custom-items"
13070
13066
  },
13071
13067
  {
13072
13068
  Component: Metadata,
@@ -13076,10 +13072,6 @@ 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"
@@ -13088,9 +13080,17 @@ const routeModule = {
13088
13080
  Component: ShippingAddress,
13089
13081
  path: "/draft-orders/:id/shipping-address"
13090
13082
  },
13083
+ {
13084
+ Component: Shipping,
13085
+ path: "/draft-orders/:id/shipping"
13086
+ },
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
  }