Merge pull request #17 from apuc/authentication
dbclick positionId reset
This commit is contained in:
commit
e83d99211e
@ -8,10 +8,22 @@ import front from '../../images/front_end.png';
|
|||||||
import back from '../../images/back_end.png';
|
import back from '../../images/back_end.png';
|
||||||
import design from '../../images/design.png';
|
import design from '../../images/design.png';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const createSelectPositionHandler = ({ selectedPositionId, setSelectedPositionId }) => id => {
|
||||||
|
if(id===selectedPositionId) {
|
||||||
|
setSelectedPositionId(null)
|
||||||
|
} else {
|
||||||
|
setSelectedPositionId(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Outstaffing = () => {
|
const Outstaffing = () => {
|
||||||
const [selectedPositionId, setSelectedPositionId] = useState(null);
|
const [selectedPositionId, setSelectedPositionId] = useState(null);
|
||||||
const tagsArr = useSelector(selectTags);
|
const tagsArr = useSelector(selectTags);
|
||||||
|
|
||||||
|
const onSelectPosition = createSelectPositionHandler({ selectedPositionId, setSelectedPositionId });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<section className={style.outstaffing}>
|
<section className={style.outstaffing}>
|
||||||
@ -34,7 +46,7 @@ const Outstaffing = () => {
|
|||||||
header="Фронтенд"
|
header="Фронтенд"
|
||||||
positionId='2'
|
positionId='2'
|
||||||
isSelected={selectedPositionId==='2'}
|
isSelected={selectedPositionId==='2'}
|
||||||
onSelect={id=>setSelectedPositionId(id)}
|
onSelect={id=>onSelectPosition(id)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-12 col-xl-4">
|
<div className="col-12 col-xl-4">
|
||||||
@ -44,7 +56,7 @@ const Outstaffing = () => {
|
|||||||
header="Бэкенд"
|
header="Бэкенд"
|
||||||
positionId='1'
|
positionId='1'
|
||||||
isSelected={selectedPositionId==='1'}
|
isSelected={selectedPositionId==='1'}
|
||||||
onSelect={id=>setSelectedPositionId(id)}
|
onSelect={id=>onSelectPosition(id)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-12 col-xl-4">
|
<div className="col-12 col-xl-4">
|
||||||
@ -54,7 +66,7 @@ const Outstaffing = () => {
|
|||||||
header="Дизайн"
|
header="Дизайн"
|
||||||
positionId='5'
|
positionId='5'
|
||||||
isSelected={selectedPositionId==='5'}
|
isSelected={selectedPositionId==='5'}
|
||||||
onSelect={id=>setSelectedPositionId(id)}
|
onSelect={id=>onSelectPosition(id)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,11 +4,20 @@ import { selectItems, selectedItems, filteredCandidates } from '../../redux/outs
|
|||||||
import { fetchItemsForId } from '../../server/server';
|
import { fetchItemsForId } from '../../server/server';
|
||||||
import style from './Outstaffing.module.css';
|
import style from './Outstaffing.module.css';
|
||||||
|
|
||||||
const handlePositionClick = ({dispatch, positionId}) => {
|
import { fetchProfile } from '../../server/server';
|
||||||
|
|
||||||
|
const handlePositionClick = ({dispatch, positionId, isSelected}) => {
|
||||||
|
|
||||||
|
if(isSelected) {
|
||||||
|
fetchProfile(`${process.env.REACT_APP_API_URL}/api/profile?limit=`, 4).then((profileArr) =>
|
||||||
|
dispatch(filteredCandidates(profileArr))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
fetchItemsForId(`${process.env.REACT_APP_API_URL}/api/profile?position_id=`, positionId).then((el) =>
|
fetchItemsForId(`${process.env.REACT_APP_API_URL}/api/profile?position_id=`, positionId).then((el) =>
|
||||||
dispatch(filteredCandidates(el))
|
dispatch(filteredCandidates(el))
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const OutstaffingBlock = ({ dataTags = [], selected, img, header, positionId, isSelected, onSelect }) => {
|
const OutstaffingBlock = ({ dataTags = [], selected, img, header, positionId, isSelected, onSelect }) => {
|
||||||
@ -37,7 +46,7 @@ const OutstaffingBlock = ({ dataTags = [], selected, img, header, positionId, is
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`${style.outstaffing__box} ${isSelected?style.outstaffing__box__selected:''}`} onClick={()=>onSelect(positionId)}>
|
<div className={`${style.outstaffing__box} ${isSelected?style.outstaffing__box__selected:''}`} onClick={()=>onSelect(positionId)}>
|
||||||
<div className={`${style.outstaffing__box__img} ${selected ? style.border : ''}`} onClick={()=>handlePositionClick({dispatch, positionId})}>
|
<div className={`${style.outstaffing__box__img} ${selected ? style.border : ''}`} onClick={()=>handlePositionClick({dispatch, positionId, isSelected})}>
|
||||||
<h3>{header}</h3>
|
<h3>{header}</h3>
|
||||||
<img className={classes} src={img} alt="img" />
|
<img className={classes} src={img} alt="img" />
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user