2021-09-15 17:07:28 +03:00
|
|
|
import React from 'react'
|
2023-01-25 16:50:36 +03:00
|
|
|
import {Link} from 'react-router-dom'
|
|
|
|
import {Achievement} from '../Achievement/Achievement'
|
2021-09-15 17:07:28 +03:00
|
|
|
|
2023-01-25 16:50:36 +03:00
|
|
|
import {LEVELS, SKILLS} from '../../constants/constants'
|
2021-11-30 17:00:58 +03:00
|
|
|
|
|
|
|
import './candidateSidebar.scss'
|
2023-01-25 16:50:36 +03:00
|
|
|
import {urlForLocal} from "../../helper";
|
2022-02-11 16:34:31 +03:00
|
|
|
|
2021-08-11 17:42:56 +03:00
|
|
|
const getYearsString = (years) => {
|
2022-11-22 16:43:17 +03:00
|
|
|
let yearsString;
|
2021-09-15 17:07:28 +03:00
|
|
|
if (years % 10 === 1) {
|
|
|
|
yearsString = 'год'
|
2021-08-11 17:42:56 +03:00
|
|
|
} else if (years === 11 || years === 12 || years === 13 || years === 14) {
|
2021-09-15 17:07:28 +03:00
|
|
|
yearsString = 'лет'
|
|
|
|
} else if (years % 10 === 2 || years % 10 === 3 || years % 10 === 4) {
|
|
|
|
yearsString = 'года'
|
2021-08-17 17:15:04 +03:00
|
|
|
} else {
|
2021-09-15 17:07:28 +03:00
|
|
|
yearsString = 'лет'
|
2021-08-11 17:42:56 +03:00
|
|
|
}
|
2021-09-15 17:07:28 +03:00
|
|
|
return `${years} ${yearsString}`
|
2022-11-22 16:43:17 +03:00
|
|
|
};
|
2021-08-11 17:42:56 +03:00
|
|
|
|
2023-01-25 16:50:36 +03:00
|
|
|
const CandidateSidebar = ({candidate, setActiveSnippet, activeSnippet}) => {
|
|
|
|
const userId = localStorage.getItem('id');
|
2022-05-27 14:39:05 +03:00
|
|
|
const showSnippet = () => {
|
2023-01-25 16:50:36 +03:00
|
|
|
setActiveSnippet((prev) => !prev)
|
2022-11-22 16:43:17 +03:00
|
|
|
};
|
2022-05-27 14:39:05 +03:00
|
|
|
|
2021-05-27 17:44:11 +03:00
|
|
|
return (
|
2023-01-25 16:50:36 +03:00
|
|
|
<div className='candidate-sidebar'>
|
|
|
|
<div className='candidate-sidebar__info'>
|
|
|
|
<div className='candidate-sidebar__position'>
|
|
|
|
<h2>
|
|
|
|
{candidate.specification} {SKILLS[candidate.position_id]},{' '}
|
|
|
|
{LEVELS[candidate.level]}{' '}
|
|
|
|
</h2>
|
|
|
|
</div>
|
|
|
|
{candidate.photo && <img src={urlForLocal(candidate.photo)} alt=''/>}
|
|
|
|
{candidate && candidate.years_of_exp && (
|
|
|
|
<>
|
|
|
|
<p className='candidate-sidebar__experience-title'>Опыт работы</p>
|
|
|
|
<p className='candidate-sidebar__experience'>
|
|
|
|
{getYearsString(candidate.years_of_exp)}
|
|
|
|
</p>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
<Link to={`/candidate/${candidate.id}/form`}>
|
|
|
|
<button className='candidate-sidebar__select'>
|
|
|
|
Выбрать к собеседованию
|
|
|
|
</button>
|
|
|
|
</Link>
|
|
|
|
{userId && (
|
|
|
|
<>
|
|
|
|
<Link to={`/${candidate.id}/calendar`}>
|
|
|
|
<button className='candidate-sidebar__select'>
|
|
|
|
Отчёты
|
|
|
|
</button>
|
|
|
|
</Link>
|
|
|
|
<button
|
|
|
|
className='candidate-sidebar__select'
|
|
|
|
onClick={showSnippet}
|
|
|
|
>
|
|
|
|
{activeSnippet ? "Показать" : "Скрыть"}
|
|
|
|
</button>
|
|
|
|
<div className='candidate-sidebar__achievements'>
|
|
|
|
{candidate &&
|
|
|
|
candidate.achievements &&
|
|
|
|
candidate.achievements.map((item) => {
|
|
|
|
return <Achievement key={item.id} achievement={item.achievement}/>
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</>)}
|
2021-11-30 17:00:58 +03:00
|
|
|
</div>
|
2021-05-27 17:44:11 +03:00
|
|
|
</div>
|
2021-09-15 17:07:28 +03:00
|
|
|
)
|
2022-11-22 16:43:17 +03:00
|
|
|
};
|
2021-05-27 17:44:11 +03:00
|
|
|
|
2021-11-30 17:00:58 +03:00
|
|
|
export default CandidateSidebar
|