diff --git a/src/views/Admin/LogInForm/index.tsx b/src/views/Admin/LogInForm/index.tsx index 3bfc978..d8943b6 100644 --- a/src/views/Admin/LogInForm/index.tsx +++ b/src/views/Admin/LogInForm/index.tsx @@ -4,7 +4,7 @@ import { useHistory } from 'react-router-dom'; import { ILoadingState } from 'types'; import { handleFormSubmit } from 'views/Admin/utils'; import { IErrorStatus } from 'views/Admin/types'; -import { handleLoginError } from 'views/Admin/handlers'; +import { handleError } from 'views/Admin/handlers'; import { handleSuccessfulLogin } from './handlers'; import './main.css'; @@ -31,15 +31,15 @@ const LogInForm: React.FC = ({ setLoading, token, setToken }) => { return (
- handleFormSubmit( + onSubmit={(e) => { + setErrorStatus({ successful: true }); + return handleFormSubmit( e, 'api/login', - (err) => handleLoginError(err, setErrorStatus), - (res: Response) => handleSuccessfulLogin(res, setToken), - { 'Access-Control-Allow-Origin': '*' } - ) - } + (err) => handleError(err, setErrorStatus), + (res: Response) => handleSuccessfulLogin(res, setToken) + ); + }} > @@ -47,8 +47,9 @@ const LogInForm: React.FC = ({ setLoading, token, setToken }) => { + {!errorStatus.successful ?

{errorStatus.errorMessage}

: ''} + - {!errorStatus.successful ?

{errorStatus.errorMessage}

: ''} ); }; diff --git a/src/views/Admin/RemoveList/index.tsx b/src/views/Admin/RemoveList/index.tsx index be63f51..fa79187 100644 --- a/src/views/Admin/RemoveList/index.tsx +++ b/src/views/Admin/RemoveList/index.tsx @@ -27,6 +27,7 @@ const RemoveList: React.FC = ({ setLoading, token, setToken }) => {