diff --git a/client/src/login/Login/Form.tsx b/client/src/login/Login/Form.tsx index f95666aa..f4773e6e 100644 --- a/client/src/login/Login/Form.tsx +++ b/client/src/login/Login/Form.tsx @@ -1,67 +1,88 @@ import React from 'react'; +import { useForm } from 'react-hook-form'; +import { useTranslation } from 'react-i18next'; -import { Field, reduxForm } from 'redux-form'; -import { Trans, withTranslation } from 'react-i18next'; -import flow from 'lodash/flow'; - -import { renderInputField } from '../../helpers/form'; -import { validateRequiredValue } from '../../helpers/validators'; -import { FORM_NAME } from '../../helpers/constants'; - -interface LoginFormProps { - handleSubmit: (...args: unknown[]) => string; - submitting: boolean; - invalid: boolean; - processing: boolean; - t: (...args: unknown[]) => string; +type FormValues = { + username: string; + password: string; } -const Form = (props: LoginFormProps) => { - const { handleSubmit, processing, invalid, t } = props; +type LoginFormProps = { + onSubmit: (data: FormValues) => void; + processing: boolean; +} + +const Form = ({ onSubmit, processing }: LoginFormProps) => { + const { t } = useTranslation(); + const { + register, + handleSubmit, + formState: { errors, isValid }, + } = useForm({ + mode: 'onChange', + defaultValues: { + username: '', + password: '', + }, + }); return ( -
+
- + {errors.username && ( + + {errors.username.message} + + )}
- + {errors.password && ( + + {errors.password.message} + + )}
-
@@ -69,4 +90,4 @@ const Form = (props: LoginFormProps) => { ); }; -export default flow([withTranslation(), reduxForm({ form: FORM_NAME.LOGIN })])(Form); +export default Form; \ No newline at end of file