Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

feat(forms): migrate auth forms to useAppForm

Sergey Kozyrenkoa3f2a73ca090
diff --git a/frontend/src/features/authentication/email-change-form.tsx b/frontend/src/features/authentication/email-change-form.tsx
index cbca2709..c8603522 100644
--- a/frontend/src/features/authentication/email-change-form.tsx
+++ b/frontend/src/features/authentication/email-change-form.tsx
@@ -1,6 +1,4 @@
-import { zodResolver } from '@hookform/resolvers/zod';
import { useState } from 'react';
-import { useForm } from 'react-hook-form';
import { toast } from 'sonner';
import * as z from 'zod';
@@ -9,6 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '
import { FormSubmitButton } from '@/components/ui/form-submit-button';
import { Input } from '@/components/ui/input';
import { InputPassword } from '@/components/ui/input-password';
+import { useAppForm } from '@/hooks/use-app-form';
import { api, resolveApiErrorMessage } from '@/lib/axios';
import { useUser } from '@/providers/user-provider';
@@ -41,12 +40,12 @@ export function EmailChangeForm({ onCancel, onSuccess }: EmailChangeFormProps) {
const [error, setError] = useState<null | string>(null);
const { patchUser, refreshAuthInfo } = useUser();
- const form = useForm<EmailChangeFormValues>({
+ const form = useAppForm<EmailChangeFormValues>({
defaultValues: {
currentPassword: '',
newEmail: '',
},
- resolver: zodResolver(emailChangeSchema),
+ schema: emailChangeSchema,
});
const handleSubmit = async (values: EmailChangeFormValues) => {
diff --git a/frontend/src/features/authentication/login-form.tsx b/frontend/src/features/authentication/login-form.tsx
index 6174efd7..5c75e2d9 100644
--- a/frontend/src/features/authentication/login-form.tsx
+++ b/frontend/src/features/authentication/login-form.tsx
@@ -1,6 +1,4 @@
-import { zodResolver } from '@hookform/resolvers/zod';
import { useState } from 'react';
-import { useForm } from 'react-hook-form';
import { useNavigate } from 'react-router-dom';
import { z } from 'zod';
@@ -13,6 +11,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '
import { FormSubmitButton } from '@/components/ui/form-submit-button';
import { Input } from '@/components/ui/input';
import { InputPassword } from '@/components/ui/input-password';
+import { useAppForm } from '@/hooks/use-app-form';
import { routes } from '@/lib/routes';
import { useUser } from '@/providers/user-provider';
@@ -63,12 +62,12 @@ interface LoginFormProps {
}
function LoginForm({ providers, returnUrl = routes.newFlow }: LoginFormProps) {
- const form = useForm<z.infer<typeof formSchema>>({
+ const form = useAppForm<z.infer<typeof formSchema>>({
defaultValues: {
mail: '',
password: '',
},
- resolver: zodResolver(formSchema),
+ schema: formSchema,
});
const [isSubmitting, setIsSubmitting] = useState(false);
const [error, setError] = useState<null | string>(null);
diff --git a/frontend/src/features/authentication/name-change-form.tsx b/frontend/src/features/authentication/name-change-form.tsx
index cccc4b5f..6e321596 100644
--- a/frontend/src/features/authentication/name-change-form.tsx
+++ b/frontend/src/features/authentication/name-change-form.tsx
@@ -1,6 +1,4 @@
-import { zodResolver } from '@hookform/resolvers/zod';
import { useState } from 'react';
-import { useForm } from 'react-hook-form';
import { toast } from 'sonner';
import * as z from 'zod';
@@ -8,6 +6,7 @@ import { Button } from '@/components/ui/button';
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
import { FormSubmitButton } from '@/components/ui/form-submit-button';
import { Input } from '@/components/ui/input';
+import { useAppForm } from '@/hooks/use-app-form';
import { api, resolveApiErrorMessage } from '@/lib/axios';
import { useUser } from '@/providers/user-provider';
@@ -35,11 +34,11 @@ export function NameChangeForm({ onCancel, onSuccess }: NameChangeFormProps) {
const [error, setError] = useState<null | string>(null);
const { authInfo, patchUser, refreshAuthInfo } = useUser();
- const form = useForm<NameChangeFormValues>({
+ const form = useAppForm<NameChangeFormValues>({
defaultValues: {
name: authInfo?.user?.name ?? '',
},
- resolver: zodResolver(nameChangeSchema),
+ schema: nameChangeSchema,
});
const handleSubmit = async (values: NameChangeFormValues) => {
diff --git a/frontend/src/features/authentication/password-change-form.tsx b/frontend/src/features/authentication/password-change-form.tsx
index fce450e4..84b5656b 100644
--- a/frontend/src/features/authentication/password-change-form.tsx
+++ b/frontend/src/features/authentication/password-change-form.tsx
@@ -1,6 +1,4 @@
-import { zodResolver } from '@hookform/resolvers/zod';
import { type ComponentProps, useState } from 'react';
-import { useForm } from 'react-hook-form';
import { toast } from 'sonner';
import * as z from 'zod';
@@ -8,6 +6,7 @@ import { Button } from '@/components/ui/button';
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
import { FormSubmitButton } from '@/components/ui/form-submit-button';
import { InputPassword } from '@/components/ui/input-password';
+import { useAppForm } from '@/hooks/use-app-form';
import { api, resolveApiErrorMessage } from '@/lib/axios';
import { cn } from '@/lib/utils';
@@ -74,13 +73,13 @@ export function PasswordChangeForm({
}: PasswordChangeFormProps) {
const [error, setError] = useState<null | string>(null);
- const form = useForm<PasswordChangeFormValues>({
+ const form = useAppForm<PasswordChangeFormValues>({
defaultValues: {
confirmPassword: '',
currentPassword: '',
newPassword: '',
},
- resolver: zodResolver(passwordChangeSchema),
+ schema: passwordChangeSchema,
});
const handleSubmit = async (values: PasswordChangeFormValues) => {