diff --git a/src/HOOks/useRequest.js b/src/HOOks/useRequest.js deleted file mode 100644 index b44de460..00000000 --- a/src/HOOks/useRequest.js +++ /dev/null @@ -1,13 +0,0 @@ -import axios from 'axios'; -import {getToken, urlHasParams} from "../helper"; -import {useLogout} from "./useLogout"; - - - -export const useRequest = () => { - - - - - return {apiRequest} -}; \ No newline at end of file diff --git a/src/components/AuthBox/AuthBox.js b/src/components/AuthBox/AuthBox.js index ba997562..8b2e7909 100644 --- a/src/components/AuthBox/AuthBox.js +++ b/src/components/AuthBox/AuthBox.js @@ -5,7 +5,7 @@ import {withSwalInstance} from 'sweetalert2-react' import swal from 'sweetalert2' import {Loader} from '../Loader/Loader' -import ErrorBoundary from "../../HOC/ErrorBoundary"; +import ErrorBoundary from "../../hoc/ErrorBoundary"; import {auth, selectAuth, setUserInfo} from '../../redux/outstaffingSlice' import {loading} from '../../redux/loaderSlice' @@ -19,20 +19,19 @@ import ellipse from '../../images/ellipse.png' import './authBox.scss' +const {useRef} = require("react"); + const SweetAlert = withSwalInstance(swal); export const AuthBox = ({title, altTitle, roleChangeLink}) => { const dispatch = useDispatch(); - + const ref = useRef(); const navigate = useNavigate(); const isAuth = useSelector(selectAuth); const isLoading = useSelector(selectIsLoading); - - const [username, setUsername] = useState(''); - const [password, setPassword] = useState(''); const [error, setError] = useState(null); if (isAuth) { @@ -47,15 +46,13 @@ export const AuthBox = ({title, altTitle, roleChangeLink}) => { const submitHandler = () => { + let formData = new FormData(ref.current) if (!isLoading) { dispatch(loading(true)); apiRequest('/user/login', { method: 'POST', - data: JSON.stringify({ - username, - password - }) + data: formData }).then((res) => { if (!res.access_token) { @@ -90,23 +87,21 @@ export const AuthBox = ({title, altTitle, roleChangeLink}) => { {title} -