import React, { useEffect } from 'react'; import { useHistory, useParams, Link } from 'react-router-dom'; import { useSelector, useDispatch } from 'react-redux'; import { currentCandidate, selectCurrentCandidate } from '../../redux/outstaffingSlice'; import arrow from '../../images/right-arrow.png'; import rectangle from '../../images/rectangle_secondPage.png'; import Sidebar from '../Sidebar/Sidebar'; import SectionSkills from './SectionSkills'; import front from '../../images/front_end.png'; import back from '../../images/back_end.png'; import design from '../../images/design.png'; import { fetchItemsForId } from '../../server/server'; import './candidate.css'; const Candidate = () => { const history = useHistory(); const { id: candidateId } = useParams(); const dispatch = useDispatch(); useEffect(() => { window.scrollTo(0, 0) }, []) useEffect(() => { fetchItemsForId(`${process.env.REACT_APP_API_URL}/api/profile/`, Number(candidateId)).then((el) => dispatch(currentCandidate(el)) ); }, [dispatch, candidateId]); const currentCandidateObj = useSelector(selectCurrentCandidate); const { position_id, skillValues, vc_text: text } = currentCandidateObj; const setStyles = () => { const styles = { classes: '', header: '', img: '', }; switch (Number(position_id)) { case 1: { styles.classes = 'back'; styles.header = 'Backend'; styles.img = back; break; } case 2: { styles.classes = 'des'; styles.header = 'Frontend'; styles.img = front; break; } case 3: { styles.classes = 'front'; styles.header = 'Design'; styles.img = design; break; } default: break; } return styles; }; function createMarkup(text) { return { __html: text.split('
').join('') }; } const { header, img, classes } = setStyles(); return (# Описание опыта
{text ? ( ) : ({currentCandidateObj.vc_text ? currentCandidateObj.vc_text : 'Описание отсутствует...' }
)}