-
- >
+
+ >
)
};
diff --git a/src/components/features/bookkeeping/ActContent/ActContent.js b/src/components/features/bookkeeping/ActContent/ActContent.js
index 34ff850a..f79ccc38 100644
--- a/src/components/features/bookkeeping/ActContent/ActContent.js
+++ b/src/components/features/bookkeeping/ActContent/ActContent.js
@@ -1,102 +1,101 @@
-import React, { useEffect, useState } from 'react';
-import { ContentTitle } from "../ContentTitle/ContentTitle"
-import { ContentButton } from "../ContentButton/ContentButton"
-import { BookkeepingFormField } from "../BookkeepingFormField/BookkeepingFormField"
-import { BookkepingSelect } from '../BookkepingSelect/BookkepingSelect';
-import { BookkepingInput } from '../BookkepingInput/BookkepingInput';
-import { fetchGet } from '../../../../server/server'
-import { Link } from "react-router-dom"
+import React, {useEffect, useState} from 'react';
+import {Link} from "react-router-dom"
+import {ContentTitle} from "../ContentTitle/ContentTitle"
+import {ContentButton} from "../ContentButton/ContentButton"
+import {BookkeepingFormField} from "../BookkeepingFormField/BookkeepingFormField"
+import {BookkepingSelect} from '../BookkepingSelect/BookkepingSelect';
+import {BookkepingInput} from '../BookkepingInput/BookkepingInput';
+
+import {useRequest} from "../../../../hooks/useRequest";
+
import "./actContent.css"
-export const ActContent = ()=> {
-
- const [templates, setTemplates] = useState([])
- const [selectedTemplate, setSelectedTemplate] = useState()
- const [templatedFields, setTemplatedFields] = useState([])
+export const ActContent = () => {
- useEffect(() => {
- fetchGet({
- link: `${process.env.REACT_APP_API_URL}/api/template/get-template-list`,
- }).then((res) => {
- setTemplates(res)
- })
- }, [])
+ const [templates, setTemplates] = useState([]);
+ const [selectedTemplate, setSelectedTemplate] = useState();
+ const [templatedFields, setTemplatedFields] = useState([]);
- useEffect(() => {
- if (selectedTemplate === undefined) {
- return
- }
- fetchGet({
- link: `${process.env.REACT_APP_API_URL}/api/template/get-template-fields?template_id=${selectedTemplate}`,
- })
- .then((res) => {
- setTemplatedFields(res[0].templateDocumentFields)
- })
- }, [selectedTemplate])
+ const {apiRequest} = useRequest();
+
+ useEffect(() => {
+ apiRequest('/template/get-template-list')
+ .then(res => setTemplates(res))
+ }, []);
+
+ useEffect(() => {
+ if (selectedTemplate === undefined) {
+ return
+ }
+ apiRequest(`/template/get-template-fields?template_id=${selectedTemplate}`)
+ .then(res => setTemplatedFields(res[0].templateDocumentFields))
+ }, [selectedTemplate]);
-
+ return (
+
+
+
+
- )
-}
\ No newline at end of file
+
+ )
+};
\ No newline at end of file
diff --git a/src/components/features/bookkeeping/ContractContent/ContractContent.js b/src/components/features/bookkeeping/ContractContent/ContractContent.js
index 1569fbaa..93804d46 100644
--- a/src/components/features/bookkeeping/ContractContent/ContractContent.js
+++ b/src/components/features/bookkeeping/ContractContent/ContractContent.js
@@ -1,97 +1,98 @@
-import React, { useEffect, useState } from "react";
-import { ContentTitle } from "../ContentTitle/ContentTitle"
-import { ContentButton } from "../ContentButton/ContentButton"
-import { BookkeepingFormField } from "../BookkeepingFormField/BookkeepingFormField"
-import { BookkepingSelect } from '../BookkepingSelect/BookkepingSelect';
-import { BookkepingInput } from '../BookkepingInput/BookkepingInput';
-import { fetchGet } from '../../../../server/server'
-import { Link } from "react-router-dom"
+import React, {useEffect, useState} from "react";
+import {ContentTitle} from "../ContentTitle/ContentTitle"
+import {ContentButton} from "../ContentButton/ContentButton"
+import {BookkeepingFormField} from "../BookkeepingFormField/BookkeepingFormField"
+import {BookkepingSelect} from '../BookkepingSelect/BookkepingSelect';
+import {BookkepingInput} from '../BookkepingInput/BookkepingInput';
+import {Link} from "react-router-dom"
+import {useRequest} from "../../../../hooks/useRequest";
export const ContractContent = () => {
- const [templates, setTemplates] = useState([])
- const [selectedTemplate, setSelectedTemplate] = useState()
- const [templatedFields, setTemplatedFields] = useState([])
-
- useEffect(() => {
- fetchGet({
- link: `${process.env.REACT_APP_API_URL}/api/document/get-document-list`,
- }).then((res) => {
- setTemplates(res)
- })
- }, [])
+ const [templates, setTemplates] = useState([]);
+ const [selectedTemplate, setSelectedTemplate] = useState();
+ const [templatedFields, setTemplatedFields] = useState([]);
- useEffect(() => {
- if (selectedTemplate === undefined) {
- return
- }
- fetchGet({
- link: `${process.env.REACT_APP_API_URL}/api/document/get-document?document_id=${selectedTemplate}`,
- })
- .then((res) => {
- setTemplatedFields(res[0].templateDocumentFields)
- })
- }, [selectedTemplate])
+ const {apiRequest} = useRequest();
- return (
-
-
-
-
-
+ useEffect(() => {
+ apiRequest(`/document/get-document-list`)
+ .then(res => setTemplates(res))
+ }, []);
-
-
+ return (
+
+
+
+
+
+
+
+
-
- )
-}
\ No newline at end of file
+
+ )
+};
\ No newline at end of file
diff --git a/src/components/features/quiz/HeaderQuiz.js b/src/components/features/quiz/HeaderQuiz.js
index 76be63a6..febcfe65 100644
--- a/src/components/features/quiz/HeaderQuiz.js
+++ b/src/components/features/quiz/HeaderQuiz.js
@@ -1,50 +1,46 @@
-import {useEffect} from 'react'
-import {useDispatch} from 'react-redux'
-import {useSelector} from 'react-redux'
-import {fetchGet} from '../../../server/server'
+import React, {useEffect} from 'react'
+import {useDispatch, useSelector} from 'react-redux'
+import {selectUserInfo, setQuestionnairesList, setUserInfo} from "../../../redux/quizSlice";
+import {useRequest} from "../../../hooks/useRequest";
import './quiz.scss'
-import {selectUserInfo, setQuestionnairesList, setUserInfo,} from "../../../redux/quizSlice";
export const HeaderQuiz = ({header}) => {
- const dispatch = useDispatch()
- const userId = localStorage.getItem('id');
- const userInfo = useSelector(selectUserInfo);
+ const dispatch = useDispatch();
+ const userId = localStorage.getItem('id');
+ const userInfo = useSelector(selectUserInfo);
- useEffect(() => {
- dispatch(setUserInfo(userId))
- }, [dispatch])
+ const {apiRequest} = useRequest();
- useEffect(() => {
- fetchGet({
- link: `${process.env.REACT_APP_API_URL}/api/user-questionnaire/questionnaires-list?user_id=${userId}`,
- Origin: `${process.env.REACT_APP_BASE_URL}`,
- }
- ).then(response => {
- dispatch(setQuestionnairesList(response))
- })
- }, [dispatch])
+ useEffect(() => {
+ dispatch(setUserInfo(userId))
+ }, [dispatch]);
- return (
-
- { userInfo?.status === 500 ?
{userInfo.message}
:
-
-
- {!userInfo ?
Loading...
:
- <>
- {header &&
Добрый день, {userInfo.fio}
}
-
-
+ useEffect(() => {
+ apiRequest(`/user-questionnaire/questionnaires-list?user_id=${userId}`)
+ .then(res => dispatch(setQuestionnairesList(res)))
+ }, [dispatch]);
+
+ return (
+
+ {userInfo?.status === 500 ?
{userInfo.message}
:
+
+
+ {!userInfo ?
Loading...
:
+ <>
+ {header &&
Добрый день, {userInfo.fio}
}
+
+
-
-
{userInfo.fio}
-
{userInfo.position_name}
-
- >
- }
+
+
{userInfo.fio}
+
{userInfo.position_name}
+
+ >
+ }
+
-
- }
-
- )
-}
+ }
+
+ )
+};
diff --git a/src/components/features/quiz/Instructions.js b/src/components/features/quiz/Instructions.js
index 1b266508..08a7c057 100644
--- a/src/components/features/quiz/Instructions.js
+++ b/src/components/features/quiz/Instructions.js
@@ -5,23 +5,26 @@ import './quiz.scss'
import {useEffect, useState} from "react";
import {useSelector} from "react-redux";
import {selectedTest} from "../../../redux/quizSlice";
-import {fetchGet} from "../../../server/server";
+
+import {useRequest} from "../../../hooks/useRequest";
export const Instruction = () => {
- const [countQuestions, setCountQuestions] = useState(null)
- const test = useSelector(selectedTest)
+ const [countQuestions, setCountQuestions] = useState(null);
+ const test = useSelector(selectedTest);
- useEffect(async () => {
+ const {apiRequest} = useRequest();
- const response = await fetchGet({
- link: `${process.env.REACT_APP_API_URL}/api/user-questionnaire/get-question-number?user_questionnaire_uuid=${test.uuid}`,
- Origin: `${process.env.REACT_APP_BASE_URL}`,
- }
- )
- setCountQuestions(response.question_number)
+ useEffect( () => {
- }, [])
+ apiRequest('/user-questionnaire/get-question-number', {
+ params: {user_questionnaire_uuid: test.uuid},
+
+ }
+ ).then((res)=> setCountQuestions(res.question_number))
+
+
+ }, []);
return (
@@ -49,5 +52,5 @@ export const Instruction = () => {
)
-}
+};
diff --git a/src/components/features/quiz/Results.js b/src/components/features/quiz/Results.js
index ba7612b8..d475fd05 100644
--- a/src/components/features/quiz/Results.js
+++ b/src/components/features/quiz/Results.js
@@ -1,37 +1,35 @@
import React, {useEffect, useState} from 'react';
import {useDispatch, useSelector} from "react-redux";
import {fetchResultTest, selectedTest, selectResult} from "../../../redux/quizSlice";
-import {fetchGet} from "../../../server/server";
+import {useRequest} from "../../../hooks/useRequest";
export const Results = () => {
- const result = useSelector(selectResult);
- const test = useSelector(selectedTest);
- const [maxScore, setMaxScore] = useState('');
- const dispatch = useDispatch();
+ const result = useSelector(selectResult);
+ const test = useSelector(selectedTest);
+ const [maxScore, setMaxScore] = useState('');
+ const dispatch = useDispatch();
+ const {apiRequest} = useRequest();
- useEffect(async () => {
- dispatch(fetchResultTest(test.uuid));
- const response = await fetchGet({
- link: `${process.env.REACT_APP_API_URL}/api/user-questionnaire/get-points-number?user_questionnaire_uuid=${test.uuid}`,
- Origin: `${process.env.REACT_APP_BASE_URL}`,
- }
- );
- setMaxScore(response.sum_point)
- }, []);
+ useEffect(async () => {
+ dispatch(fetchResultTest(test.uuid));
+ apiRequest(`/user-questionnaire/get-points-number?user_questionnaire_uuid=${test.uuid}`)
+ .then((res) => setMaxScore(res.sum_point));
- return (
-
+ }, []);
+
+ return (
+
{
- !result ?
Ожидайте результата...
:
+ !result ?
Ожидайте результата...
:
-
+
Благодарим за прохождение теста
Ваш Результат: {result.score} из {maxScore}
-
+ className="result__score">{result.score} из {maxScore}
+
}
-
- );
+
+ );
};
diff --git a/src/components/features/quiz/Task.js b/src/components/features/quiz/Task.js
index 8658d14c..2ba3b07a 100644
--- a/src/components/features/quiz/Task.js
+++ b/src/components/features/quiz/Task.js
@@ -1,11 +1,11 @@
import React, {useEffect, useState} from 'react'
-import { useNavigate} from "react-router-dom"
+import {useNavigate} from "react-router-dom"
import {useSelector, useDispatch} from 'react-redux'
import {
- fetchGetAnswers,
- selectAnswer,
- selectedTest
+ fetchGetAnswers,
+ selectAnswer,
+ selectedTest
} from '../../../redux/quizSlice'
import {Progressbar} from './ProgressbarQuiz'
@@ -13,140 +13,141 @@ import {GetOptionTask} from './GetOptionTask'
import {fetchUserAnswersMany, fetchUserAnswerOne} from './../../../redux/quizSlice'
-import {fetchGet} from "../../../server/server";
import './quiz.scss'
+import {useRequest} from "../../../hooks/useRequest";
export const TaskQuiz = () => {
- const navigate = useNavigate();
- const dispatch = useDispatch();
+ const navigate = useNavigate();
+ const dispatch = useDispatch();
- const listAnswers = useSelector(selectAnswer);
- const dataTest = useSelector(selectedTest);
+ const listAnswers = useSelector(selectAnswer);
+ const dataTest = useSelector(selectedTest);
- const [index, setIndex] = useState(0);
- const [checkedValues, setCheckedValues] = useState([]);
- const [stripValue, setStripValue] = useState(0);
- const [inputValue, setInputValue] = useState('');
- const [questions, setQuestions] = useState([]);
+ const [index, setIndex] = useState(0);
+ const [checkedValues, setCheckedValues] = useState([]);
+ const [stripValue, setStripValue] = useState(0);
+ const [inputValue, setInputValue] = useState('');
+ const [questions, setQuestions] = useState([]);
- const id = localStorage.getItem('id');
+ const {apiRequest} = useRequest();
- useEffect( () => {
- const response = fetchGet({
- link: `${process.env.REACT_APP_API_URL}/api/question/get-questions?uuid=${dataTest.uuid}`,
- Origin: `${process.env.REACT_APP_BASE_URL}`,
- }
- );
- setQuestions(response);
- dispatch(fetchGetAnswers(response[0].id));
- setStripValue((+index + 1) * 100 / response.length)
- }, [dispatch]);
+ const id = localStorage.getItem('id');
- const nextQuestion = async (e) => {
- e.preventDefault();
+ useEffect(() => {
+ apiRequest(`/question/get-questions?uuid=${dataTest.uuid}`)
+ .then((response) => {
+ setQuestions(response);
+ dispatch(fetchGetAnswers(response[0].id));
+ setStripValue((+index + 1) * 100 / response.length)
+ })
+ }, [dispatch]);
- //Проверка на валидацию ответов
- if (checkedValues.length || inputValue) {
- switch (questions[index].question_type_id) {
- case '3':
- dispatch(fetchUserAnswersMany(checkedValues));
- break;
- case '2':
- case '1':
- case '4':
- dispatch(fetchUserAnswerOne(checkedValues));
- break;
- default:
- break;
- }
+ const nextQuestion = async (e) => {
+ e.preventDefault();
- //Проверка на существование следующего запроса
- if (index < questions.length - 1) {
- await dispatch(fetchGetAnswers(questions[index + 1].id));
- setIndex(prev => prev >= questions.length - 1 ? prev : prev + 1);
- setStripValue((prev => prev + (100 / questions.length)));
- setCheckedValues([]);
- setInputValue('')
- } else {
- navigate(`/quiz-result`);
- alert("Тест пройден!")
- }
-
- } else {
- alert("Вы не ответили на вопрос")
- }
- };
-
- const handleChange = (e) => {
- const checked = e.target.checked;
+ //Проверка на валидацию ответов
+ if (checkedValues.length || inputValue) {
switch (questions[index].question_type_id) {
- case '3':
- checked ? setCheckedValues(prev => [...prev, {
- user_id: id,
- user_questionnaire_uuid: dataTest.uuid,
- question_id: questions[index].id,
- response_body: e.target.value
- }]) :
- setCheckedValues(prev => [...prev.filter(item => item.response_body !== e.target.value)]);
- break;
- case '1':
- case '2':
- case '4':
- setCheckedValues([{
- user_id: id,
- user_questionnaire_uuid: dataTest.uuid,
- question_id: questions[index].id,
- response_body: e.target.value
- }])
+ case '3':
+ dispatch(fetchUserAnswersMany(checkedValues));
+ break;
+ case '2':
+ case '1':
+ case '4':
+ dispatch(fetchUserAnswerOne(checkedValues));
+ break;
+ default:
+ break;
}
- };
+
+ //Проверка на существование следующего запроса
+ if (index < questions.length - 1) {
+ await dispatch(fetchGetAnswers(questions[index + 1].id));
+ setIndex(prev => prev >= questions.length - 1 ? prev : prev + 1);
+ setStripValue((prev => prev + (100 / questions.length)));
+ setCheckedValues([]);
+ setInputValue('')
+ } else {
+ navigate(`/quiz-result`);
+ alert("Тест пройден!")
+ }
+
+ } else {
+ alert("Вы не ответили на вопрос")
+ }
+ };
+
+ const handleChange = (e) => {
+ const checked = e.target.checked;
+ switch (questions[index].question_type_id) {
+ case '3':
+ checked ? setCheckedValues(prev => [...prev, {
+ user_id: id,
+ user_questionnaire_uuid: dataTest.uuid,
+ question_id: questions[index].id,
+ response_body: e.target.value
+ }]) :
+ setCheckedValues(prev => [...prev.filter(item => item.response_body !== e.target.value)]);
+ break;
+ case '1':
+ case '2':
+ case '4':
+ setCheckedValues([{
+ user_id: id,
+ user_questionnaire_uuid: dataTest.uuid,
+ question_id: questions[index].id,
+ response_body: e.target.value
+ }])
+ }
+ };
- return (
-
+ return (
+
- {!questions.length || !stripValue || !listAnswers.length ?
-
Loading....
- :
-
+ {!questions.length || !stripValue || !listAnswers.length ?
+
Loading....
+ :
+
- {/* */}
+ {/* */}
{questions[index].question_body}
-
+
-
- }
+
+ }
-
- )
+
+ )
};
diff --git a/src/hooks/useLogout.js b/src/hooks/useLogout.js
index 5d46922a..84fd7afe 100644
--- a/src/hooks/useLogout.js
+++ b/src/hooks/useLogout.js
@@ -1,4 +1,3 @@
-import React from "react";
import {useDispatch, useSelector} from "react-redux";
import {getRole} from "../redux/roleSlice";
import {useNavigate} from "react-router-dom";
@@ -12,7 +11,6 @@ export const useLogout = () => {
const logout = () => {
localStorage.clear();
dispatch(auth(false));
- console.log('logout')
navigate(userRole === 'ROLE_DEV' ? '/authdev' : '/auth')
};
diff --git a/src/hooks/useRequest.js b/src/hooks/useRequest.js
index 07fa0054..fd0c78f2 100644
--- a/src/hooks/useRequest.js
+++ b/src/hooks/useRequest.js
@@ -1,7 +1,5 @@
-import React from "react";
import axios from 'axios';
import {getToken, urlHasParams} from "../helper";
-import {useNavigate} from "react-router";
import {useLogout} from "./useLogout";
@@ -38,7 +36,6 @@ export const useRequest = () => {
})
.then(response => new Promise(resolve => {
if (response.data.redirect || response.status === 401) {
- console.log(response, 'LOGUTATAT')
logout()
}
return resolve(response)
diff --git a/src/pages/FormPage.js b/src/pages/FormPage.js
index e4b769d1..1c525ded 100644
--- a/src/pages/FormPage.js
+++ b/src/pages/FormPage.js
@@ -4,13 +4,11 @@ import {useParams, useNavigate} from 'react-router-dom'
import {
currentCandidate,
selectCurrentCandidate,
- auth
} from '../redux/outstaffingSlice'
import SVG from 'react-inlinesvg'
import {WithLogout} from '../hoc/withLogout'
import Form from '../components/Form/Form'
import {LEVELS, SKILLS} from '../components/constants/constants'
-import {fetchGet} from '../server/server'
import {Footer} from '../components/Footer/Footer'
import arrow from '../images/right-arrow.png'
@@ -18,7 +16,7 @@ import rectangle from '../images/rectangle_secondPage.png'
import telegramIcon from '../images/telegram-icon.svg'
import './formPage.scss'
-import {getRole} from '../redux/roleSlice'
+import {useRequest} from "../hooks/useRequest";
const FormPage = () => {
@@ -26,20 +24,19 @@ const FormPage = () => {
const navigate = useNavigate();
const dispatch = useDispatch();
const candidate = useSelector(selectCurrentCandidate);
- const role = useSelector(getRole);
+
+
+ const {apiRequest} = useRequest();
const goBack = () => {
navigate(-1)
};
if (!candidate.id) {
- fetchGet({
- link: `${process.env.REACT_APP_API_URL}/api/profile/`,
- params: Number(params.id),
- navigate,
- role,
- logout: () => dispatch(auth(false))
- }).then((el) => dispatch(currentCandidate(el)))
+ apiRequest('/api/profile', {
+ params: Number(params.id)
+ })
+ .then((el) => dispatch(currentCandidate(el)))
}
return (
diff --git a/src/pages/Summary/Summary.js b/src/pages/Summary/Summary.js
index a8705472..537df491 100644
--- a/src/pages/Summary/Summary.js
+++ b/src/pages/Summary/Summary.js
@@ -1,104 +1,101 @@
import React, {useEffect, useState} from 'react';
+import {useSelector} from "react-redux";
import {ProfileHeader} from "../../components/ProfileHeader/ProfileHeader";
import {getProfileInfo} from "../../redux/outstaffingSlice";
-import {useSelector} from "react-redux";
-import {transformHtml} from "../../helper";
import {Footer} from '../../components/Footer/Footer'
+import {transformHtml} from "../../helper";
+
+import {useRequest} from "../../hooks/useRequest";
import arrow from "../../images/right-arrow.png";
import rightArrow from "../../images/arrowRight.png"
import gitImgItem from "../../images/gitItemImg.png"
-import {fetchGet} from "../../server/server";
-
import './summary.scss'
-
-
export const Summary = () => {
- const profileInfo = useSelector(getProfileInfo);
- const [openGit, setOpenGit] = useState(false);
- const [gitInfo, setGitInfo] = useState([]);
- useEffect(() => {
- fetchGet({
- link: `${process.env.REACT_APP_API_URL}/api/profile/portfolio-projects?card_id=${localStorage.getItem('cardId')}`,
- }).then((responseGit) => {
- setGitInfo(responseGit)
- })
- }, []);
- return(
-
-
-
-
-
Ваше резюме {openGit && - Git}
- {openGit &&
setOpenGit(false)}>
-
-
Вернуться
-
}
-
-
-
-
{profileInfo.fio} {profileInfo.specification}
-
- {!openGit &&
-
- }
-
-
- {!openGit &&
-
-
-
Основной стек
-
-
-
-
- {profileInfo.skillValues && profileInfo.skillValues.map((skill) => {
- return {skill.skill.name}
- })}
-
-
-
- }
- {profileInfo.vc_text && !openGit &&
-
-
- }
- {openGit &&
-
-
-
Страница портфолио кода разработчика
-
-
-
- {gitInfo.length && gitInfo.map((itemGit) => {
- return
-
-
-
-
-
{itemGit.title}
-
{itemGit.description}
-
-
-
-
-
{itemGit.main_stack}
-
-
-
-
-
-
- })
- }
-
-
- }
+ const profileInfo = useSelector(getProfileInfo);
+ const [openGit, setOpenGit] = useState(false);
+ const [gitInfo, setGitInfo] = useState([]);
+
+ const {apiRequest} = useRequest();
+ useEffect(() => {
+ apiRequest(`/profile/portfolio-projects?card_id=${localStorage.getItem('cardId')}`)
+ .then(responseGit => setGitInfo(responseGit))
+ }, [apiRequest]);
+ return (
+
+
+
+
+
Ваше резюме {openGit && - Git}
+ {openGit &&
setOpenGit(false)}>
+
+
Вернуться
+
}
+
+
+
+
{profileInfo.fio} {profileInfo.specification}
+
+ {!openGit &&
+
+ }
-
+
+ {!openGit &&
+
+
+
Основной стек
+
+
+
+
+ {profileInfo.skillValues && profileInfo.skillValues.map((skill) =>
+ {skill.skill.name}
+ )}
+
+
+
+ }
+ {profileInfo.vc_text && !openGit &&
+
+
+ }
+ {openGit &&
+
+
+
Страница портфолио кода разработчика
+
+
+
+ {gitInfo.length && gitInfo.map((itemGit) => {
+ return
+
+
+
+
+
{itemGit.title}
+
{itemGit.description}
+
+
+
+
+
{itemGit.main_stack}
+
+
+
+
+
+
+ })
+ }
+
+
+ }
- )
+
+
+ )
};