Убираю варнинги при сборке, прохожусь притером, сокращаю код

This commit is contained in:
Дмитрий Савенко 2023-01-10 18:48:02 +03:00
parent c4d44e3855
commit 1234427b12
7 changed files with 66 additions and 65 deletions

View File

@ -1,14 +1,20 @@
export function createMarkup(text) {
return {__html: text.split('</p>').join('</p>')}
return {__html: text.split('</p>').join('</p>')}
}
export function transformHtml(text) {
let startHtml = {__html: text.split('<h2>').join('<br><h2>').split('<br>')}
startHtml = startHtml.__html.filter((el)=> {
return (el != null && el != "" || el === 0)
})
const finalHtml = startHtml.map((item) => {
return `<div class='experience__block'><div class="summary__sections__head"><h3>Описание опыта работы</h3><button>Редактировать раздел</button></div><div class="experience__content">${item.split('<h3>')[0]}</div></div>`
})
return {__html: finalHtml.join('')}
let startHtml = {__html: text.split('<h2>').join('<br><h2>').split('<br>')};
startHtml = startHtml.__html.filter((el) =>
el !== null && el !== "" || el === 0
);
const finalHtml = startHtml.map((item) =>
`<div class='experience__block'>
<div class="summary__sections__head">
<h3>Описание опыта работы</h3>
<button>Редактировать раздел</button>
</div>
<div class="experience__content">${item.split('<h3>')[0]}</div>
</div>`
);
return {__html: finalHtml.join('')}
}

View File

@ -1,6 +1,6 @@
import React, { useState } from 'react'
import React from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useHistory, useParams, Link } from 'react-router-dom'
import { useHistory, useParams } from 'react-router-dom'
import {
currentCandidate,
selectCurrentCandidate,
@ -22,14 +22,14 @@ import { getRole } from '../redux/roleSlice'
const goBack = (history) => {
history.goBack()
}
};
const FormPage = () => {
const params = useParams()
const history = useHistory()
const dispatch = useDispatch()
const candidate = useSelector(selectCurrentCandidate)
const role = useSelector(getRole)
const params = useParams();
const history = useHistory();
const dispatch = useDispatch();
const candidate = useSelector(selectCurrentCandidate);
const role = useSelector(getRole);
if (!candidate.id) {
fetchGet({
@ -56,7 +56,7 @@ const FormPage = () => {
</div>
<div className='form-page__candidate'>
<div className='form-page__avatar'>
<img src={candidate.photo} />
<img src={candidate.photo} alt='candidate avatar'/>
</div>
<div className='form-page__candidate-info'>
<div className='form-page__position'>
@ -66,7 +66,7 @@ const FormPage = () => {
</span>
</div>
<div className='form-page__selected'>
<img src={rectangle} />
<img src={rectangle} alt='rectangle'/>
<span>Выбранный кандидат</span>
</div>
</div>
@ -84,7 +84,7 @@ const FormPage = () => {
Заявка на собеседование через телеграм
</div>
<div className='form-page__telegram-icon'>
<a href='https://t.me/st0kir' target='_blank'>
<a href='https://t.me/st0kir' target='_blank' rel="noreferrer">
<SVG src={telegramIcon} />
</a>
</div>
@ -94,6 +94,6 @@ const FormPage = () => {
</div>
</WithLogout>
)
}
};
export default FormPage

View File

@ -22,7 +22,7 @@ const tasks = [
text: 'Задача «83 Навигационная система Поиск по почтовому индексу Добавить экран поиска по почтовому индексу» не может быть завершена, т.к. работа над задачей «82 Навигационная система Разработать модуль поиска по почтовому индексу» ещё не начата',
hours: 3
}
]
];
const SingleReportPage = () => {
return (
@ -30,7 +30,7 @@ const SingleReportPage = () => {
<div className='single-report-page'>
<div className='single-report-page__back'>
<div className='single-report-page__back-arrow'>
<img src={arrowLeft} />
<img src={arrowLeft} alt='arrowLeft'/>
</div>
<div className='single-report-page__back-text'>
Вернуться к списку
@ -103,6 +103,6 @@ const SingleReportPage = () => {
</div>
</WithLogout>
)
}
};
export default SingleReportPage

View File

@ -1,9 +1,9 @@
import React, {useEffect, useState} from 'react';
import { ProfileHeader } from "../components/Profile/ProfileHeader";
import {ProfileHeader} from "../components/Profile/ProfileHeader";
import {getProfileInfo} from "../redux/outstaffingSlice";
import { useSelector } from "react-redux";
import {useSelector} from "react-redux";
import {transformHtml} from "../helper";
import { Footer } from '../components/Footer/Footer'
import {Footer} from '../components/Footer/Footer'
import arrow from "../images/right-arrow.png";
import rightArrow from "../images/arrowRight.png"
@ -13,16 +13,16 @@ import '../components/Profile/summary.scss'
import {fetchGet} from "../server/server";
export const Summary = () => {
const profileInfo = useSelector(getProfileInfo)
const profileInfo = useSelector(getProfileInfo);
const [openGit, setOpenGit] = useState(false);
const [gitInfo, setGitInfo] = useState([])
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(
<div className='summary'>
<ProfileHeader/>
@ -35,7 +35,7 @@ export const Summary = () => {
</div>}
<div className='summary__info'>
<div className='summary__person'>
<img src={profileInfo.photo} className='summary__avatar' />
<img src={profileInfo.photo} className='summary__avatar' alt='avatar'/>
<p className='summary__name'>{profileInfo.fio} {profileInfo.specification}</p>
</div>
{!openGit &&
@ -80,11 +80,11 @@ export const Summary = () => {
</div>
</div>
<div className='gitItem__info__specification'>
<span></span>
<span className='gitItem__lineSkill'/>
<p>{itemGit.main_stack}</p>
</div>
</div>
<a className='gitItem__link' href={itemGit.link} target="_blank">
<a className='gitItem__link' href={itemGit.link} target="_blank" rel="noreferrer">
<img src={rightArrow} alt='arrowRight' />
</a>
</div>
@ -97,5 +97,5 @@ export const Summary = () => {
<Footer/>
</div>
)
}
};

View File

@ -1,6 +1,5 @@
import {Link, Redirect} from 'react-router-dom'
import {Redirect} from 'react-router-dom'
import {HeaderPageTestsQuiz} from '../../components/features/quiz/HeaderPageTests'
import {Progressbar} from '../../components/features/quiz/ProgressbarQuiz'
import {TaskQuiz} from '../../components/features/quiz/Task'
import {useSelector} from "react-redux";
import {selectedTest} from "../../redux/quizSlice";
@ -19,4 +18,4 @@ export const QuizTestPage = () => {
<TaskQuiz/>
</>
)
}
};

View File

@ -1,4 +1,4 @@
import {Link, Redirect} from "react-router-dom"
import {Redirect} from "react-router-dom"
import {HeaderPageTestsQuiz} from "../../components/features/quiz/HeaderPageTests"
import {Results} from "../../components/features/quiz/Results";
import {useSelector} from "react-redux";
@ -20,4 +20,4 @@ export const ResultPage = () => {
<Results/>
</>
)
}
};

View File

@ -1,5 +1,5 @@
import {createAsyncThunk, createSlice} from '@reduxjs/toolkit';
import {fetchGet, fetchPost} from './../server/server'
import {fetchGet} from './../server/server'
import axios from "axios";
@ -17,17 +17,16 @@ export const setUserInfo = createAsyncThunk(
'userInfo',
async (id) => {
try{
const response = await fetchGet({
link: `${process.env.REACT_APP_API_URL}/api/profile/get-main-data?user_id=${id}`,
Origin: `${process.env.REACT_APP_BASE_URL}`,
}
return await fetchGet({
link: `${process.env.REACT_APP_API_URL}/api/profile/get-main-data?user_id=${id}`,
Origin: `${process.env.REACT_APP_BASE_URL}`,
}
)
return response
}catch (e) {
console.log(e)
}
}
)
);
export const fetchUserAnswersMany = createAsyncThunk(
'answersUserMany',
@ -38,13 +37,13 @@ export const fetchUserAnswersMany = createAsyncThunk(
headers: {
Authorization: `Bearer ${localStorage.getItem('auth_token')}`,
}
})
});
return response.data
}catch (e) {
console.log(e)
}
}
)
);
export const fetchUserAnswerOne = createAsyncThunk(
'answersUserOne',
async (checkedValues) => {
@ -54,24 +53,23 @@ export const fetchUserAnswerOne = createAsyncThunk(
headers: {
Authorization: `Bearer ${localStorage.getItem('auth_token')}`,
}
})
});
return response.data
}catch (e) {
console.log(e)
}
}
)
);
export const fetchGetAnswers = createAsyncThunk(
'answers',
async (question_id) => {
const resp = await fetchGet({
link: `${process.env.REACT_APP_API_URL}/api/answer/get-answers?question_id=${question_id}`,
Origin: `${process.env.REACT_APP_BASE_URL}`,
}
return await fetchGet({
link: `${process.env.REACT_APP_API_URL}/api/answer/get-answers?question_id=${question_id}`,
Origin: `${process.env.REACT_APP_BASE_URL}`,
}
)
return resp
}
)
);
// export const fetchGetQuestion = createAsyncThunk(
// 'questions',
// async (uuid) => {
@ -86,22 +84,21 @@ export const fetchGetAnswers = createAsyncThunk(
export const fetchResultTest = createAsyncThunk(
'result',
async (uuid) => {
const resp = await fetchGet({
link: `${process.env.REACT_APP_API_URL}/api/user-questionnaire/questionnaire-completed?user_questionnaire_uuid=${uuid}`,
Origin: `${process.env.REACT_APP_BASE_URL}`,
}
return await fetchGet({
link: `${process.env.REACT_APP_API_URL}/api/user-questionnaire/questionnaire-completed?user_questionnaire_uuid=${uuid}`,
Origin: `${process.env.REACT_APP_BASE_URL}`,
}
)
return resp
}
)
);
export const quizSlice = createSlice({
name: 'quiz',
initialState,
reducers: {
setQuestionnairesList: (state, action) => {
state.dataQuestionnairesOfUser = action.payload
state.dataQuestionnairesOfUser = action.payload;
state.passedTests = action.payload.filter(item=>item.status === 2)
},
setSelectedTest: (state, action) => {
@ -123,11 +120,10 @@ export const quizSlice = createSlice({
export const {setQuestionnairesList, setSelectedTest} = quizSlice.actions;
// export const selectQuestions = (state) => state.quiz.questions;
export const selectAnswer = (state) => state.quiz.answer;
export const selectQuestionnairesOfUser = (state) => state.quiz.dataQuestionnairesOfUser;
export const selectResult = (state) => state.quiz.result;
export const selectIsLoading = (state) => state.quiz.isLoading;
export const selectedTest = (state) => state.quiz.selectedTest;
export const selectPassedTests = (state) => state.quiz.passedTests;
export const selectUserInfo = (state) => state.quiz.userInfo;