From 5c8a8160bd4794d4f1e26f161d3571619ec85088 Mon Sep 17 00:00:00 2001 From: Z1chi Date: Wed, 25 Jan 2023 16:50:36 +0300 Subject: [PATCH] =?UTF-8?q?fixs,=20=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D1=81?= =?UTF-8?q?=D1=82=D0=B5=D0=B9=D1=82=D1=8B=20=D0=B4=D0=BB=D1=8F=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D1=8B=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=86=D0=B8=D0=B8,=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=B0=D0=BB=20=D0=BD=D0=B0=20=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=20=D0=B4=D0=B0=D1=82=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/HOOks/useRequest.js | 13 --- src/components/AuthBox/AuthBox.js | 23 ++-- src/components/Calendar/Calendar.js | 3 +- .../CandidateSidebar/CandidateSidebar.js | 101 +++++++++-------- src/components/Description/Description.js | 104 ++---------------- src/components/LogoutButton/LogoutButton.js | 13 ++- .../OutstaffingBlock/OutstaffingBlock.js | 15 ++- src/components/Select/TagSelect.js | 6 +- src/components/features/quiz/Instructions.js | 1 - src/components/features/quiz/Results.js | 1 - src/components/features/quiz/Task.js | 1 - src/{HOC => hoc}/ErrorBoundary.js | 0 src/{HOC => hoc}/withLogout.js | 0 src/{HOOks => hooks}/useLogout.js | 0 .../AuthForDevelopers/AuthForDevelopers.js | 12 +- src/pages/AuthForPartners/AuthForPartners.js | 13 ++- src/pages/CalendarPage.js | 2 +- src/pages/FormPage/FormPage.js | 3 +- src/pages/Home/Home.js | 2 - .../SingleReportPage/SingleReportPage.js | 1 - src/pages/Summary/Summary.js | 2 - 21 files changed, 107 insertions(+), 209 deletions(-) delete mode 100644 src/HOOks/useRequest.js rename src/{HOC => hoc}/ErrorBoundary.js (100%) rename src/{HOC => hoc}/withLogout.js (100%) rename src/{HOOks => hooks}/useLogout.js (100%) 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 (