From 77420d8c9603cdd9c4473c3db1b6ce9f57365715 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Thu, 12 Dec 2024 15:21:57 +0300 Subject: [PATCH] filter check form --- client/src/components/Filters/Check/index.tsx | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/client/src/components/Filters/Check/index.tsx b/client/src/components/Filters/Check/index.tsx index c524c1fe..b3e0220d 100644 --- a/client/src/components/Filters/Check/index.tsx +++ b/client/src/components/Filters/Check/index.tsx @@ -1,53 +1,57 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; - -import { Field, reduxForm } from 'redux-form'; import { useSelector } from 'react-redux'; +import { useForm } from 'react-hook-form'; import Card from '../../ui/Card'; - -import { renderInputField } from '../../../helpers/form'; - import Info from './Info'; -import { FORM_NAME } from '../../../helpers/constants'; + import { RootState } from '../../../initialState'; -interface CheckProps { - handleSubmit: (...args: unknown[]) => string; - pristine: boolean; - invalid: boolean; +interface FormValues { + name: string; } -const Check = (props: CheckProps) => { - const { pristine, invalid, handleSubmit } = props; +type Props = { + onSubmit?: (data: FormValues) => void; +} +const Check = ({ onSubmit }: Props) => { const { t } = useTranslation(); const processingCheck = useSelector((state: RootState) => state.filtering.processingCheck); - const hostname = useSelector((state: RootState) => state.filtering.check.hostname); + const { + register, + handleSubmit, + formState: { isDirty, isValid }, + } = useForm({ + mode: 'onChange', + defaultValues: { + name: '', + }, + }); + return ( -
+
- - @@ -56,7 +60,6 @@ const Check = (props: CheckProps) => { {hostname && ( <>
- )} @@ -67,4 +70,4 @@ const Check = (props: CheckProps) => { ); }; -export default reduxForm({ form: FORM_NAME.DOMAIN_CHECK })(Check); +export default Check;