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} -
+ setUsername(e.target.value)} /> setPassword(e.target.value)} /> {error && ( diff --git a/src/components/Calendar/Calendar.js b/src/components/Calendar/Calendar.js index 36705682..09d26c94 100644 --- a/src/components/Calendar/Calendar.js +++ b/src/components/Calendar/Calendar.js @@ -12,6 +12,7 @@ import {selectCurrentCandidate} from '../../redux/outstaffingSlice' import rectangle from '../../images/rectangle_secondPage.png' import './calendar.scss' +import {urlForLocal} from "../../helper"; const Calendar = () => { @@ -42,7 +43,7 @@ const Calendar = () => {
- img + {photo && img}

{abbreviatedName}

diff --git a/src/components/CandidateSidebar/CandidateSidebar.js b/src/components/CandidateSidebar/CandidateSidebar.js index f8640e9e..876a2c10 100644 --- a/src/components/CandidateSidebar/CandidateSidebar.js +++ b/src/components/CandidateSidebar/CandidateSidebar.js @@ -1,10 +1,11 @@ import React from 'react' -import { Link } from 'react-router-dom' -import { Achievement } from '../Achievement/Achievement' +import {Link} from 'react-router-dom' +import {Achievement} from '../Achievement/Achievement' -import { LEVELS, SKILLS } from '../../constants/constants' +import {LEVELS, SKILLS} from '../../constants/constants' import './candidateSidebar.scss' +import {urlForLocal} from "../../helper"; const getYearsString = (years) => { let yearsString; @@ -20,60 +21,58 @@ const getYearsString = (years) => { return `${years} ${yearsString}` }; -const CandidateSidebar = ({ candidate, setActiveSnippet, activeSnippet }) => { - const userId = localStorage.getItem('id') ; +const CandidateSidebar = ({candidate, setActiveSnippet, activeSnippet}) => { + const userId = localStorage.getItem('id'); const showSnippet = () => { - setActiveSnippet((prev)=>!prev) + setActiveSnippet((prev) => !prev) }; return ( -
-
-
-

- {candidate.specification} {SKILLS[candidate.position_id]},{' '} - {LEVELS[candidate.level]}{' '} -

+
+
+
+

+ {candidate.specification} {SKILLS[candidate.position_id]},{' '} + {LEVELS[candidate.level]}{' '} +

+
+ {candidate.photo && } + {candidate && candidate.years_of_exp && ( + <> +

Опыт работы

+

+ {getYearsString(candidate.years_of_exp)} +

+ + )} + + + + {userId && ( + <> + + + + +
+ {candidate && + candidate.achievements && + candidate.achievements.map((item) => { + return + })} +
+ )}
- - {candidate && candidate.years_of_exp && ( - <> -

Опыт работы

-

- {getYearsString(candidate.years_of_exp)} -

- - )} - - - - {userId && ( - <> - - - - {/* */} - - {/* */} -
- {candidate && - candidate.achievements && - candidate.achievements.map((item) => { - return - })} -
- )}
-
) }; diff --git a/src/components/Description/Description.js b/src/components/Description/Description.js index d02631a5..a8458d8c 100644 --- a/src/components/Description/Description.js +++ b/src/components/Description/Description.js @@ -2,11 +2,10 @@ import React from 'react' import {useSelector} from 'react-redux' import {Link} from 'react-router-dom' -import {Loader} from '../Loader/Loader' -import ErrorBoundary from "../../HOC/ErrorBoundary"; +import ErrorBoundary from "../../hoc/ErrorBoundary"; import {LEVELS, SKILLS} from '../../constants/constants' -import {selectProfiles, selectFilteredCandidates,} from '../../redux/outstaffingSlice' +import {selectProfiles} from '../../redux/outstaffingSlice' import {urlForLocal} from '../../helper' @@ -19,105 +18,17 @@ import './description.scss' const Description = ({onLoadMore, isLoadingMore}) => { const candidatesListArr = useSelector(selectProfiles); - const filteredListArr = useSelector(selectFilteredCandidates); - - - - if (!filteredListArr) { - return ( -
-
-
- - {candidatesListArr && Array.isArray(candidatesListArr) && candidatesListArr.length > 0 ? ( - candidatesListArr.map((el) => ( -
-
- {el.photo && } -
-
-

- - {el.specification} {SKILLS[el.position_id]},{' '} - {LEVELS[el.level]}{' '} - -

- - {el.vc_text_short ? ( -
- {el.vc_text_short} -
- ) : ( -

- Описание отсутствует... -

- )} -
-
- - - -
-
-
-
    - {Array.isArray(el?.skillValues) && el.skillValues.map((e) => ( -
  • - {e.skill.name} -
  • - ))} -
- -
-
-
- )) - ) : ( -
- {isLoadingMore - ? 'В данный момент в категории нет свободных специалистов' - : 'Загрузка...'} -
- )} -
-
- -
-
-
-
- -
-
-
-
-
-
- ) - } return (
- {filteredListArr && Array.isArray(filteredListArr) && filteredListArr.length > 0 - ? filteredListArr.map((el) => ( + {candidatesListArr && Array.isArray(candidatesListArr) && candidatesListArr.length > 0 + ? candidatesListArr.map((el) => (
- urlForLocal(el?.photo)} alt=''/> + {el.photo && }

@@ -217,10 +128,9 @@ const Description = ({onLoadMore, isLoadingMore}) => {
- {candidatesListArr && - filteredListArr.length === 0 ? ( + {candidatesListArr && ( - ) : null} + )}
diff --git a/src/components/LogoutButton/LogoutButton.js b/src/components/LogoutButton/LogoutButton.js index 12cc5389..3f435b84 100644 --- a/src/components/LogoutButton/LogoutButton.js +++ b/src/components/LogoutButton/LogoutButton.js @@ -1,25 +1,28 @@ import React, {useState} from 'react' import {useNavigate} from 'react-router-dom' -import {useDispatch, useSelector} from 'react-redux' +import {useSelector} from 'react-redux' +import {useLogout} from "../../hooks/useLogout"; + import {Loader} from '../Loader/Loader' -import {auth} from '../../redux/outstaffingSlice' + import {getRole} from '../../redux/roleSlice' import './logoutButton.scss' + export const LogoutButton = () => { const [isLoggingOut, setIsLoggingOut] = useState(false); - const dispatch = useDispatch(); + const userRole = useSelector(getRole); const navigate = useNavigate(); + const {logout} = useLogout(); return (