This commit is contained in:
kurpfish
2021-08-17 17:15:04 +03:00
parent d21ae2db20
commit deecc0905a
8 changed files with 116 additions and 12 deletions

View File

@ -1,5 +1,5 @@
footer {
padding: 0 5rem;
padding: 2rem 5rem;
}
footer>div {

View File

@ -2,7 +2,7 @@
display: flex;
flex-direction: column;
align-items: center;
margin-top: 180px;
margin-top: 120px;
}
.form > label {

View File

@ -1,4 +1,5 @@
import React from 'react';
import OutsideClickHandler from 'react-outside-click-handler';
import { useDispatch, useSelector } from 'react-redux';
import { selectItems, selectedItems, filteredCandidates } from '../../redux/outstaffingSlice';
import { fetchItemsForId } from '../../server/server';
@ -50,6 +51,11 @@ const OutstaffingBlock = ({ dataTags = [], selected, img, header, positionId, is
});
return (
<OutsideClickHandler
onOutsideClick={() => {
isSelected && onSelect(null)
}}
>
<div className={`${style.outstaffing__box} ${isSelected?style.outstaffing__box__selected:''}`} >
<div className={`${style.outstaffing__box__img} ${selected ? style.border : ''}`} onClick={()=>handlePositionClick({dispatch, positionId, isSelected, onSelect})}>
<h3>{header}</h3>
@ -68,6 +74,7 @@ const OutstaffingBlock = ({ dataTags = [], selected, img, header, positionId, is
)}
</div>
</div>
</OutsideClickHandler>
);
};

View File

@ -4,13 +4,15 @@ import maleBig from '../../images/medium_male_big.png';
import style from './Sidebar.module.css';
const getYearsString = (years) => {
let yearsString = 'года';
let yearsString;
if (years%10 === 1) {
yearsString = 'год';
} else if (years === 11 || years === 12 || years === 13 || years === 14) {
yearsString = 'лет';
} else if (years%10 === 2 || years%10 === 3 || years%10 === 4) {
yearsString = 'года';
} else {
yearsString = 'лет';
}
return `${years} ${yearsString}`;
}
@ -24,7 +26,7 @@ const Sidebar = ({ candidate }) => {
<p className={style.candidateSidebar__info__e}>Опыт работы</p>
<p className={style.candidateSidebar__info__y}>{getYearsString(candidate.years_of_exp)}</p>
</> }
<Link to={`/candidate/${candidate.id}/form`}>
<Link to={`/candidate/${candidate.id}/form`}>
<button className={style.candidateSidebar__info__btn}>Выбрать к собеседованию</button>
</Link>
</div>

View File

@ -0,0 +1,11 @@
export const withAuthRedirect = actionCall => (link, index) => {
return actionCall(link, index)
.then(res => {
if(res.status && res.status == 401) {
localStorage.clear();
}
return res;
})
.catch(err => localStorage.clear())
}

View File

@ -1,4 +1,6 @@
export const fetchProfile = async (link, index) => {
import { withAuthRedirect } from "./authRedirect"
export const fetchProfile = withAuthRedirect(async (link, index) => {
try {
const response = await fetch(`${link}${index}`, {
method: 'GET',
@ -12,9 +14,9 @@ export const fetchProfile = async (link, index) => {
return data
} catch (error) {}
}
})
export const fetchSkills = async (link) => {
export const fetchSkills = withAuthRedirect(async (link) => {
try {
const response = await fetch(link, {
method: 'GET',
@ -28,9 +30,9 @@ export const fetchSkills = async (link) => {
return data
} catch (error) {}
}
})
export const fetchItemsForId = async (link, id) => {
export const fetchItemsForId = withAuthRedirect(async (link, id) => {
console.log(`Bearer ${localStorage.getItem('auth_token')}`);
try {
const response = await fetch(`${link}${id}`, {
@ -45,9 +47,9 @@ export const fetchItemsForId = async (link, id) => {
return data
} catch (error) {}
}
})
export const fetchForm = async (link, info) => {
export const fetchForm = withAuthRedirect(async (link, info) => {
try {
const response = await fetch(link, {
method: 'POST',
@ -62,7 +64,7 @@ export const fetchForm = async (link, info) => {
return response
} catch (error) {}
}
})
export const fetchAuth = async ({ username, password, dispatch, catchError }) => {
const baseURL = process.env.REACT_APP_BASE_URL;