From a8fcdab9e906f8ff37bb106c20e8364f371c9997 Mon Sep 17 00:00:00 2001 From: David Crespo Date: Tue, 10 Sep 2024 13:56:55 -0500 Subject: [PATCH] Get rid of useless RHF `useForm` wrapper (#2426) change all useForm imports to real RHF one --- app/components/form/fields/TlsCertsField.tsx | 3 +-- app/forms/disk-attach.tsx | 4 +++- app/forms/disk-create.tsx | 4 ++-- app/forms/firewall-rules-common.tsx | 8 ++++++-- app/forms/firewall-rules-create.tsx | 3 ++- app/forms/firewall-rules-edit.tsx | 8 ++------ app/forms/floating-ip-create.tsx | 3 ++- app/forms/floating-ip-edit.tsx | 3 ++- app/forms/idp/create.tsx | 3 ++- app/forms/idp/edit.tsx | 3 ++- app/forms/image-edit.tsx | 2 +- app/forms/image-from-snapshot.tsx | 3 ++- app/forms/image-upload.tsx | 3 ++- app/forms/instance-create.tsx | 4 ++-- app/forms/ip-pool-create.tsx | 2 +- app/forms/ip-pool-edit.tsx | 3 ++- app/forms/ip-pool-range-add.tsx | 4 ++-- app/forms/network-interface-create.tsx | 3 ++- app/forms/network-interface-edit.tsx | 3 ++- app/forms/project-access.tsx | 4 +++- app/forms/project-create.tsx | 2 +- app/forms/project-edit.tsx | 2 +- app/forms/silo-access.tsx | 3 ++- app/forms/silo-create.tsx | 2 +- app/forms/snapshot-create.tsx | 3 ++- app/forms/ssh-key-create.tsx | 2 +- app/forms/subnet-create.tsx | 3 ++- app/forms/subnet-edit.tsx | 3 ++- app/forms/vpc-create.tsx | 3 ++- app/forms/vpc-edit.tsx | 3 ++- app/forms/vpc-router-create.tsx | 3 ++- app/forms/vpc-router-edit.tsx | 3 ++- app/forms/vpc-router-route-create.tsx | 3 ++- app/forms/vpc-router-route-edit.tsx | 3 ++- app/hooks/index.ts | 1 - app/hooks/use-form.ts | 19 ------------------- app/pages/LoginPage.tsx | 2 +- app/pages/system/SiloImagesPage.tsx | 3 +-- app/pages/system/networking/IpPoolPage.tsx | 3 ++- app/pages/system/silos/SiloIpPoolsTab.tsx | 3 ++- 40 files changed, 73 insertions(+), 69 deletions(-) delete mode 100644 app/hooks/use-form.ts diff --git a/app/components/form/fields/TlsCertsField.tsx b/app/components/form/fields/TlsCertsField.tsx index 29188be002..dec73aa26b 100644 --- a/app/components/form/fields/TlsCertsField.tsx +++ b/app/components/form/fields/TlsCertsField.tsx @@ -6,13 +6,12 @@ * Copyright Oxide Computer Company */ import { useState } from 'react' -import { useController, type Control } from 'react-hook-form' +import { useController, useForm, type Control } from 'react-hook-form' import type { Merge } from 'type-fest' import type { CertificateCreate } from '@oxide/api' import type { SiloCreateFormValues } from '~/forms/silo-create' -import { useForm } from '~/hooks' import { Button } from '~/ui/lib/Button' import { FieldLabel } from '~/ui/lib/FieldLabel' import * as MiniTable from '~/ui/lib/MiniTable' diff --git a/app/forms/disk-attach.tsx b/app/forms/disk-attach.tsx index 7895c81b91..ce9608aeb0 100644 --- a/app/forms/disk-attach.tsx +++ b/app/forms/disk-attach.tsx @@ -5,11 +5,13 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' + import { useApiQuery, type ApiError } from '@oxide/api' import { ComboboxField } from '~/components/form/fields/ComboboxField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useProjectSelector } from '~/hooks' +import { useProjectSelector } from '~/hooks' const defaultValues = { name: '' } diff --git a/app/forms/disk-create.tsx b/app/forms/disk-create.tsx index 20a08d8375..0951d0322d 100644 --- a/app/forms/disk-create.tsx +++ b/app/forms/disk-create.tsx @@ -7,7 +7,7 @@ */ import { filesize } from 'filesize' import { useMemo } from 'react' -import { useController, type Control } from 'react-hook-form' +import { useController, useForm, type Control } from 'react-hook-form' import { useNavigate, type NavigateFunction } from 'react-router-dom' import { @@ -28,7 +28,7 @@ import { ListboxField } from '~/components/form/fields/ListboxField' import { NameField } from '~/components/form/fields/NameField' import { RadioField } from '~/components/form/fields/RadioField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useProjectSelector } from '~/hooks' +import { useProjectSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { FormDivider } from '~/ui/lib/Divider' import { FieldLabel } from '~/ui/lib/FieldLabel' diff --git a/app/forms/firewall-rules-common.tsx b/app/forms/firewall-rules-common.tsx index 3c9906ace8..0dc745d1f9 100644 --- a/app/forms/firewall-rules-common.tsx +++ b/app/forms/firewall-rules-common.tsx @@ -6,7 +6,12 @@ * Copyright Oxide Computer Company */ -import { useController, type Control, type ControllerRenderProps } from 'react-hook-form' +import { + useController, + useForm, + type Control, + type ControllerRenderProps, +} from 'react-hook-form' import { usePrefetchedApiQuery, @@ -27,7 +32,6 @@ import { NumberField } from '~/components/form/fields/NumberField' import { RadioField } from '~/components/form/fields/RadioField' import { TextField, TextFieldInner } from '~/components/form/fields/TextField' import { useVpcSelector } from '~/hooks' -import { useForm } from '~/hooks/use-form' import { Badge } from '~/ui/lib/Badge' import { Button } from '~/ui/lib/Button' import { FormDivider } from '~/ui/lib/Divider' diff --git a/app/forms/firewall-rules-create.tsx b/app/forms/firewall-rules-create.tsx index 1670214483..e8f6fd5dce 100644 --- a/app/forms/firewall-rules-create.tsx +++ b/app/forms/firewall-rules-create.tsx @@ -6,6 +6,7 @@ * Copyright Oxide Computer Company */ import { useMemo } from 'react' +import { useForm } from 'react-hook-form' import { useNavigate, useParams, type LoaderFunctionArgs } from 'react-router-dom' import * as R from 'remeda' @@ -19,7 +20,7 @@ import { } from '@oxide/api' import { SideModalForm } from '~/components/form/SideModalForm' -import { getVpcSelector, useForm, useVpcSelector } from '~/hooks' +import { getVpcSelector, useVpcSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/firewall-rules-edit.tsx b/app/forms/firewall-rules-edit.tsx index 9d99ea8747..a05eedcfd4 100644 --- a/app/forms/firewall-rules-edit.tsx +++ b/app/forms/firewall-rules-edit.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import { @@ -17,12 +18,7 @@ import { import { trigger404 } from '~/components/ErrorBoundary' import { SideModalForm } from '~/components/form/SideModalForm' -import { - getFirewallRuleSelector, - useFirewallRuleSelector, - useForm, - useVpcSelector, -} from '~/hooks' +import { getFirewallRuleSelector, useFirewallRuleSelector, useVpcSelector } from '~/hooks' import { invariant } from '~/util/invariant' import { pb } from '~/util/path-builder' diff --git a/app/forms/floating-ip-create.tsx b/app/forms/floating-ip-create.tsx index 6bc8fc8cb0..1cc3713d5b 100644 --- a/app/forms/floating-ip-create.tsx +++ b/app/forms/floating-ip-create.tsx @@ -7,6 +7,7 @@ */ import * as Accordion from '@radix-ui/react-accordion' import { useState } from 'react' +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { @@ -22,7 +23,7 @@ import { DescriptionField } from '~/components/form/fields/DescriptionField' import { ListboxField } from '~/components/form/fields/ListboxField' import { NameField } from '~/components/form/fields/NameField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useProjectSelector } from '~/hooks' +import { useProjectSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { Badge } from '~/ui/lib/Badge' import { Message } from '~/ui/lib/Message' diff --git a/app/forms/floating-ip-edit.tsx b/app/forms/floating-ip-edit.tsx index d0120aa6a1..9c96756fe8 100644 --- a/app/forms/floating-ip-edit.tsx +++ b/app/forms/floating-ip-edit.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import { @@ -18,7 +19,7 @@ import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { SideModalForm } from '~/components/form/SideModalForm' import { addToast } from '~/stores/toast' -import { getFloatingIpSelector, useFloatingIpSelector, useForm } from 'app/hooks' +import { getFloatingIpSelector, useFloatingIpSelector } from 'app/hooks' import { pb } from 'app/util/path-builder' EditFloatingIpSideModalForm.loader = async ({ params }: LoaderFunctionArgs) => { diff --git a/app/forms/idp/create.tsx b/app/forms/idp/create.tsx index e32d24c6fa..1ddfea8225 100644 --- a/app/forms/idp/create.tsx +++ b/app/forms/idp/create.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { useApiMutation, useApiQueryClient } from '@oxide/api' @@ -14,7 +15,7 @@ import { FileField } from '~/components/form/fields/FileField' import { NameField } from '~/components/form/fields/NameField' import { TextField } from '~/components/form/fields/TextField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useSiloSelector } from '~/hooks' +import { useSiloSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { readBlobAsBase64 } from '~/util/file' import { pb } from '~/util/path-builder' diff --git a/app/forms/idp/edit.tsx b/app/forms/idp/edit.tsx index dea56cd58f..84938958c9 100644 --- a/app/forms/idp/edit.tsx +++ b/app/forms/idp/edit.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import { apiQueryClient, usePrefetchedApiQuery } from '@oxide/api' @@ -14,7 +15,7 @@ import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { TextField } from '~/components/form/fields/TextField' import { SideModalForm } from '~/components/form/SideModalForm' -import { getIdpSelector, useForm, useIdpSelector } from '~/hooks' +import { getIdpSelector, useIdpSelector } from '~/hooks' import { DateTime } from '~/ui/lib/DateTime' import { PropertiesTable } from '~/ui/lib/PropertiesTable' import { ResourceLabel } from '~/ui/lib/SideModal' diff --git a/app/forms/image-edit.tsx b/app/forms/image-edit.tsx index ace71abf7d..af65b13b9b 100644 --- a/app/forms/image-edit.tsx +++ b/app/forms/image-edit.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import { apiQueryClient, usePrefetchedApiQuery, type Image } from '@oxide/api' @@ -17,7 +18,6 @@ import { SideModalForm } from '~/components/form/SideModalForm' import { getProjectImageSelector, getSiloImageSelector, - useForm, useProjectImageSelector, useSiloImageSelector, } from '~/hooks' diff --git a/app/forms/image-from-snapshot.tsx b/app/forms/image-from-snapshot.tsx index 14126fc975..fadf1525ca 100644 --- a/app/forms/image-from-snapshot.tsx +++ b/app/forms/image-from-snapshot.tsx @@ -6,6 +6,7 @@ * Copyright Oxide Computer Company */ import { filesize } from 'filesize' +import { useForm } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import { @@ -20,7 +21,7 @@ import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { TextField } from '~/components/form/fields/TextField' import { SideModalForm } from '~/components/form/SideModalForm' -import { getProjectSnapshotSelector, useForm, useProjectSnapshotSelector } from '~/hooks' +import { getProjectSnapshotSelector, useProjectSnapshotSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { PropertiesTable } from '~/ui/lib/PropertiesTable' import { pb } from '~/util/path-builder' diff --git a/app/forms/image-upload.tsx b/app/forms/image-upload.tsx index 1f584e8fce..4cf292738f 100644 --- a/app/forms/image-upload.tsx +++ b/app/forms/image-upload.tsx @@ -11,6 +11,7 @@ import { filesize } from 'filesize' import pMap from 'p-map' import pRetry from 'p-retry' import { useRef, useState } from 'react' +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { @@ -34,7 +35,7 @@ import { NameField } from '~/components/form/fields/NameField' import { RadioField } from '~/components/form/fields/RadioField' import { TextField } from '~/components/form/fields/TextField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useProjectSelector } from '~/hooks' +import { useProjectSelector } from '~/hooks' import { Message } from '~/ui/lib/Message' import { Modal } from '~/ui/lib/Modal' import { Progress } from '~/ui/lib/Progress' diff --git a/app/forms/instance-create.tsx b/app/forms/instance-create.tsx index b76a5cb19c..a6832ed7b6 100644 --- a/app/forms/instance-create.tsx +++ b/app/forms/instance-create.tsx @@ -7,7 +7,7 @@ */ import * as Accordion from '@radix-ui/react-accordion' import { useEffect, useMemo, useState } from 'react' -import { useController, useWatch, type Control } from 'react-hook-form' +import { useController, useForm, useWatch, type Control } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import type { SetRequired } from 'type-fest' @@ -55,7 +55,7 @@ import { TextField } from '~/components/form/fields/TextField' import { Form } from '~/components/form/Form' import { FullPageForm } from '~/components/form/FullPageForm' import { HL } from '~/components/HL' -import { getProjectSelector, useForm, useProjectSelector } from '~/hooks' +import { getProjectSelector, useProjectSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { Badge } from '~/ui/lib/Badge' import { Button } from '~/ui/lib/Button' diff --git a/app/forms/ip-pool-create.tsx b/app/forms/ip-pool-create.tsx index f3d633fbc1..c91e8d8d31 100644 --- a/app/forms/ip-pool-create.tsx +++ b/app/forms/ip-pool-create.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { useApiMutation, useApiQueryClient, type IpPoolCreate } from '@oxide/api' @@ -12,7 +13,6 @@ import { useApiMutation, useApiQueryClient, type IpPoolCreate } from '@oxide/api import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/ip-pool-edit.tsx b/app/forms/ip-pool-edit.tsx index b794327469..b16ccf827d 100644 --- a/app/forms/ip-pool-edit.tsx +++ b/app/forms/ip-pool-edit.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import { @@ -17,7 +18,7 @@ import { import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { SideModalForm } from '~/components/form/SideModalForm' -import { getIpPoolSelector, useForm, useIpPoolSelector } from '~/hooks' +import { getIpPoolSelector, useIpPoolSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/ip-pool-range-add.tsx b/app/forms/ip-pool-range-add.tsx index c06babb6fa..753a8d466c 100644 --- a/app/forms/ip-pool-range-add.tsx +++ b/app/forms/ip-pool-range-add.tsx @@ -5,14 +5,14 @@ * * Copyright Oxide Computer Company */ -import { type FieldErrors } from 'react-hook-form' +import { useForm, type FieldErrors } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { useApiMutation, useApiQueryClient, type IpRange } from '@oxide/api' import { TextField } from '~/components/form/fields/TextField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useIpPoolSelector } from '~/hooks' +import { useIpPoolSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { Message } from '~/ui/lib/Message' import { pb } from '~/util/path-builder' diff --git a/app/forms/network-interface-create.tsx b/app/forms/network-interface-create.tsx index c3e452d322..99b9c51df4 100644 --- a/app/forms/network-interface-create.tsx +++ b/app/forms/network-interface-create.tsx @@ -6,6 +6,7 @@ * Copyright Oxide Computer Company */ import { useMemo } from 'react' +import { useForm } from 'react-hook-form' import { useApiQuery, type ApiError, type InstanceNetworkInterfaceCreate } from '@oxide/api' @@ -15,7 +16,7 @@ import { NameField } from '~/components/form/fields/NameField' import { SubnetListbox } from '~/components/form/fields/SubnetListbox' import { TextField } from '~/components/form/fields/TextField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useProjectSelector } from '~/hooks' +import { useProjectSelector } from '~/hooks' import { FormDivider } from '~/ui/lib/Divider' const defaultValues: InstanceNetworkInterfaceCreate = { diff --git a/app/forms/network-interface-edit.tsx b/app/forms/network-interface-edit.tsx index d274bab439..d417e082da 100644 --- a/app/forms/network-interface-edit.tsx +++ b/app/forms/network-interface-edit.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import * as R from 'remeda' import { @@ -17,7 +18,7 @@ import { import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useInstanceSelector } from '~/hooks' +import { useInstanceSelector } from '~/hooks' type EditNetworkInterfaceFormProps = { editing: InstanceNetworkInterface diff --git a/app/forms/project-access.tsx b/app/forms/project-access.tsx index 1f02b7c1f0..3b66f4a89c 100644 --- a/app/forms/project-access.tsx +++ b/app/forms/project-access.tsx @@ -5,6 +5,8 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' + import { updateRole, useActorsNotInPolicy, @@ -14,7 +16,7 @@ import { import { ListboxField } from '~/components/form/fields/ListboxField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useProjectSelector } from '~/hooks' +import { useProjectSelector } from '~/hooks' import { actorToItem, diff --git a/app/forms/project-create.tsx b/app/forms/project-create.tsx index 9c4b2f1567..020894826c 100644 --- a/app/forms/project-create.tsx +++ b/app/forms/project-create.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { useApiMutation, useApiQueryClient, type ProjectCreate } from '@oxide/api' @@ -12,7 +13,6 @@ import { useApiMutation, useApiQueryClient, type ProjectCreate } from '@oxide/ap import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/project-edit.tsx b/app/forms/project-edit.tsx index a610c95c0d..727bc66f87 100644 --- a/app/forms/project-edit.tsx +++ b/app/forms/project-edit.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import { @@ -17,7 +18,6 @@ import { import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/silo-access.tsx b/app/forms/silo-access.tsx index 1001d9d5ab..6eb2e2f701 100644 --- a/app/forms/silo-access.tsx +++ b/app/forms/silo-access.tsx @@ -5,6 +5,8 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' + import { updateRole, useActorsNotInPolicy, @@ -14,7 +16,6 @@ import { import { ListboxField } from '~/components/form/fields/ListboxField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm } from '~/hooks' import { actorToItem, diff --git a/app/forms/silo-create.tsx b/app/forms/silo-create.tsx index 8e34dd0727..9508386bae 100644 --- a/app/forms/silo-create.tsx +++ b/app/forms/silo-create.tsx @@ -6,6 +6,7 @@ * Copyright Oxide Computer Company */ import { useEffect } from 'react' +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { useApiMutation, useApiQueryClient, type SiloCreate } from '@oxide/api' @@ -18,7 +19,6 @@ import { RadioField } from '~/components/form/fields/RadioField' import { TextField } from '~/components/form/fields/TextField' import { TlsCertsField } from '~/components/form/fields/TlsCertsField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm } from '~/hooks' import { addToast } from '~/stores/toast' import { FormDivider } from '~/ui/lib/Divider' import { FieldLabel } from '~/ui/lib/FieldLabel' diff --git a/app/forms/snapshot-create.tsx b/app/forms/snapshot-create.tsx index 0080251420..6b89ff8219 100644 --- a/app/forms/snapshot-create.tsx +++ b/app/forms/snapshot-create.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { @@ -20,7 +21,7 @@ import { ComboboxField } from '~/components/form/fields/ComboboxField' import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useProjectSelector } from '~/hooks' +import { useProjectSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/ssh-key-create.tsx b/app/forms/ssh-key-create.tsx index 54a1e49c73..14e5b399a3 100644 --- a/app/forms/ssh-key-create.tsx +++ b/app/forms/ssh-key-create.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { useApiMutation, useApiQueryClient, type SshKeyCreate } from '@oxide/api' @@ -13,7 +14,6 @@ import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { TextField } from '~/components/form/fields/TextField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/subnet-create.tsx b/app/forms/subnet-create.tsx index a1c94a1577..5c7fc17e53 100644 --- a/app/forms/subnet-create.tsx +++ b/app/forms/subnet-create.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { useApiMutation, useApiQueryClient, type VpcSubnetCreate } from '@oxide/api' @@ -19,7 +20,7 @@ import { useCustomRouterItems, } from '~/components/form/fields/useItemsList' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useVpcSelector } from '~/hooks' +import { useVpcSelector } from '~/hooks' import { FormDivider } from '~/ui/lib/Divider' import { pb } from '~/util/path-builder' diff --git a/app/forms/subnet-edit.tsx b/app/forms/subnet-edit.tsx index a8b5863c97..59b38e4819 100644 --- a/app/forms/subnet-edit.tsx +++ b/app/forms/subnet-edit.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import { @@ -24,7 +25,7 @@ import { useCustomRouterItems, } from '~/components/form/fields/useItemsList' import { SideModalForm } from '~/components/form/SideModalForm' -import { getVpcSubnetSelector, useForm, useVpcSubnetSelector } from '~/hooks' +import { getVpcSubnetSelector, useVpcSubnetSelector } from '~/hooks' import { FormDivider } from '~/ui/lib/Divider' import { pb } from '~/util/path-builder' diff --git a/app/forms/vpc-create.tsx b/app/forms/vpc-create.tsx index 92bff170d6..4c60d95495 100644 --- a/app/forms/vpc-create.tsx +++ b/app/forms/vpc-create.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { useApiMutation, useApiQueryClient, type VpcCreate } from '@oxide/api' @@ -13,7 +14,7 @@ import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { TextField } from '~/components/form/fields/TextField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useProjectSelector } from '~/hooks' +import { useProjectSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/vpc-edit.tsx b/app/forms/vpc-edit.tsx index b50a73ab40..411050df6e 100644 --- a/app/forms/vpc-edit.tsx +++ b/app/forms/vpc-edit.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import { @@ -17,7 +18,7 @@ import { import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { SideModalForm } from '~/components/form/SideModalForm' -import { getVpcSelector, useForm, useVpcSelector } from '~/hooks' +import { getVpcSelector, useVpcSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/vpc-router-create.tsx b/app/forms/vpc-router-create.tsx index 089d47aa6f..7d99fe54cf 100644 --- a/app/forms/vpc-router-create.tsx +++ b/app/forms/vpc-router-create.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { useApiMutation, useApiQueryClient, type VpcRouterCreate } from '@oxide/api' @@ -12,7 +13,7 @@ import { useApiMutation, useApiQueryClient, type VpcRouterCreate } from '@oxide/ import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { SideModalForm } from '~/components/form/SideModalForm' -import { useForm, useVpcSelector } from '~/hooks' +import { useVpcSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/vpc-router-edit.tsx b/app/forms/vpc-router-edit.tsx index eff66fd6b5..e070490c30 100644 --- a/app/forms/vpc-router-edit.tsx +++ b/app/forms/vpc-router-edit.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs, @@ -22,7 +23,7 @@ import { import { DescriptionField } from '~/components/form/fields/DescriptionField' import { NameField } from '~/components/form/fields/NameField' import { SideModalForm } from '~/components/form/SideModalForm' -import { getVpcRouterSelector, useForm, useVpcRouterSelector } from '~/hooks' +import { getVpcRouterSelector, useVpcRouterSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/vpc-router-route-create.tsx b/app/forms/vpc-router-route-create.tsx index 0ca0241d1e..b2a5ff1119 100644 --- a/app/forms/vpc-router-route-create.tsx +++ b/app/forms/vpc-router-route-create.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { useApiMutation, useApiQueryClient, type RouterRouteCreate } from '@oxide/api' @@ -15,7 +16,7 @@ import { NameField } from '~/components/form/fields/NameField' import { TextField } from '~/components/form/fields/TextField' import { SideModalForm } from '~/components/form/SideModalForm' import { fields, targetValueDescription } from '~/forms/vpc-router-route/shared' -import { useForm, useVpcRouterSelector } from '~/hooks' +import { useVpcRouterSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { pb } from '~/util/path-builder' diff --git a/app/forms/vpc-router-route-edit.tsx b/app/forms/vpc-router-route-edit.tsx index 7554fe9cce..fe4fc636d3 100644 --- a/app/forms/vpc-router-route-edit.tsx +++ b/app/forms/vpc-router-route-edit.tsx @@ -5,6 +5,7 @@ * * Copyright Oxide Computer Company */ +import { useForm } from 'react-hook-form' import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import * as R from 'remeda' @@ -26,7 +27,7 @@ import { routeFormMessage, targetValueDescription, } from '~/forms/vpc-router-route/shared' -import { getVpcRouterRouteSelector, useForm, useVpcRouterRouteSelector } from '~/hooks' +import { getVpcRouterRouteSelector, useVpcRouterRouteSelector } from '~/hooks' import { addToast } from '~/stores/toast' import { Message } from '~/ui/lib/Message' import { pb } from '~/util/path-builder' diff --git a/app/hooks/index.ts b/app/hooks/index.ts index 3c2b3cb2bd..22497b9f6e 100644 --- a/app/hooks/index.ts +++ b/app/hooks/index.ts @@ -6,7 +6,6 @@ * Copyright Oxide Computer Company */ -export * from './use-form' export * from './use-is-overflow' export * from './use-key' export * from './use-params' diff --git a/app/hooks/use-form.ts b/app/hooks/use-form.ts deleted file mode 100644 index 9768ee3370..0000000000 --- a/app/hooks/use-form.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * Copyright Oxide Computer Company - */ -import { useForm as _useForm, type FieldValues, type UseFormProps } from 'react-hook-form' - -/** - * Same as built-in `useForm` except we can hard-code some props and prevent the - * caller from setting them. - * See https://react-hook-form.com/docs/useform#mode - */ -export function useForm( - props?: Omit, 'mode'> -) { - return _useForm({ mode: 'onSubmit', ...props }) -} diff --git a/app/pages/LoginPage.tsx b/app/pages/LoginPage.tsx index dfa905db0f..37cb2cb365 100644 --- a/app/pages/LoginPage.tsx +++ b/app/pages/LoginPage.tsx @@ -6,12 +6,12 @@ * Copyright Oxide Computer Company */ import { useEffect } from 'react' +import { useForm } from 'react-hook-form' import { useNavigate, useSearchParams } from 'react-router-dom' import { useApiMutation, type UsernamePasswordCredentials } from '@oxide/api' import { TextFieldInner } from '~/components/form/fields/TextField' -import { useForm } from '~/hooks' import { addToast } from '~/stores/toast' import { Button } from '~/ui/lib/Button' import { Identicon } from '~/ui/lib/Identicon' diff --git a/app/pages/system/SiloImagesPage.tsx b/app/pages/system/SiloImagesPage.tsx index 88ac4f12d9..45bc82f54a 100644 --- a/app/pages/system/SiloImagesPage.tsx +++ b/app/pages/system/SiloImagesPage.tsx @@ -7,7 +7,7 @@ */ import { createColumnHelper } from '@tanstack/react-table' import { useCallback, useMemo, useState } from 'react' -import { type FieldValues } from 'react-hook-form' +import { useForm, type FieldValues } from 'react-hook-form' import { Outlet } from 'react-router-dom' import { @@ -23,7 +23,6 @@ import { DocsPopover } from '~/components/DocsPopover' import { ComboboxField } from '~/components/form/fields/ComboboxField' import { toListboxItem } from '~/components/form/fields/ImageSelectField' import { ListboxField } from '~/components/form/fields/ListboxField' -import { useForm } from '~/hooks' import { confirmDelete } from '~/stores/confirm-delete' import { addToast } from '~/stores/toast' import { makeLinkCell } from '~/table/cells/LinkCell' diff --git a/app/pages/system/networking/IpPoolPage.tsx b/app/pages/system/networking/IpPoolPage.tsx index 100e814598..9d670b7b9f 100644 --- a/app/pages/system/networking/IpPoolPage.tsx +++ b/app/pages/system/networking/IpPoolPage.tsx @@ -8,6 +8,7 @@ import { createColumnHelper } from '@tanstack/react-table' import { useCallback, useMemo, useState } from 'react' +import { useForm } from 'react-hook-form' import { Outlet, useNavigate, type LoaderFunctionArgs } from 'react-router-dom' import { @@ -28,7 +29,7 @@ import { ComboboxField } from '~/components/form/fields/ComboboxField' import { HL } from '~/components/HL' import { MoreActionsMenu } from '~/components/MoreActionsMenu' import { QueryParamTabs } from '~/components/QueryParamTabs' -import { getIpPoolSelector, useForm, useIpPoolSelector } from '~/hooks' +import { getIpPoolSelector, useIpPoolSelector } from '~/hooks' import { confirmAction } from '~/stores/confirm-action' import { confirmDelete } from '~/stores/confirm-delete' import { addToast } from '~/stores/toast' diff --git a/app/pages/system/silos/SiloIpPoolsTab.tsx b/app/pages/system/silos/SiloIpPoolsTab.tsx index 0218d7ee78..5d525fdc47 100644 --- a/app/pages/system/silos/SiloIpPoolsTab.tsx +++ b/app/pages/system/silos/SiloIpPoolsTab.tsx @@ -8,13 +8,14 @@ import { createColumnHelper } from '@tanstack/react-table' import { useCallback, useMemo, useState } from 'react' +import { useForm } from 'react-hook-form' import { useApiMutation, useApiQuery, useApiQueryClient, type SiloIpPool } from '@oxide/api' import { Networking24Icon } from '@oxide/design-system/icons/react' import { ComboboxField } from '~/components/form/fields/ComboboxField' import { HL } from '~/components/HL' -import { useForm, useSiloSelector } from '~/hooks' +import { useSiloSelector } from '~/hooks' import { confirmAction } from '~/stores/confirm-action' import { addToast } from '~/stores/toast' import { DefaultPoolCell } from '~/table/cells/DefaultPoolCell'