guild_front/src/components/Outstaffing/Outstaffing.js

105 lines
3.1 KiB
JavaScript
Raw Normal View History

2021-06-01 17:28:09 +03:00
import React, { useState, useEffect } from 'react';
2021-06-01 15:25:01 +03:00
import style from './Outstaffing.module.css';
import front from '../../images/front_end.png';
import back from '../../images/back_end.png';
import design from '../../images/design.png';
import OutstaffingBlock from './OutstaffingBlock';
2021-06-01 17:28:09 +03:00
import TagSelect from '../Select/TagSelect';
2021-06-01 15:25:01 +03:00
2021-06-03 17:15:22 +03:00
const Outstaffing = ({ onhandleTabBar }) => {
2021-06-01 15:25:01 +03:00
const [data, setData] = useState([]);
2021-06-01 17:28:09 +03:00
const [selectedItems, setSelectedItems] = useState([]);
2021-06-01 15:25:01 +03:00
useEffect(() => {
2021-06-02 14:04:26 +03:00
const tags = [
{
2021-06-03 17:15:22 +03:00
name: 'frontend',
2021-06-02 18:25:25 +03:00
img: front,
header: '# Популярный стек',
tags: ['Vue.js', 'ReactJS', 'Angular', 'JavaScript', 'Html', 'Css', 'MobX'],
2021-06-02 14:04:26 +03:00
},
{
2021-06-03 17:15:22 +03:00
name: 'backend',
2021-06-02 18:25:25 +03:00
img: back,
header: '# Популярный стек',
tags: ['Node.js', 'Express', 'Php', 'Ruby on Rails', 'Python', 'Wordpress', ' Java'],
2021-06-02 14:04:26 +03:00
},
{
name: 'design',
2021-06-02 18:25:25 +03:00
img: design,
header: '# Популярный стек',
tags: ['Figma', 'Avocode', 'PhotoShop', 'Xara', 'Pinegrow', 'Macaw', 'KompoZer'],
2021-06-02 14:04:26 +03:00
},
];
setData(tags);
2021-06-01 15:25:01 +03:00
}, []);
2021-06-02 14:04:26 +03:00
const handleBlockClick = (item) => {
if (!selectedItems.find((el) => item === el.value)) {
setSelectedItems([...selectedItems, { value: item, label: item }]);
2021-06-01 17:28:09 +03:00
}
2021-06-02 14:04:26 +03:00
// else {
// setSelectedItems(selectedItems.filter((el) => item !== el.value));
// }
2021-06-01 15:25:01 +03:00
};
const handleSubmit = () => {
2021-06-01 17:28:09 +03:00
const filterItems = JSON.stringify(selectedItems.map((item) => item.value));
2021-06-01 15:25:01 +03:00
alert(`Back-end: ${filterItems}`);
2021-06-01 17:28:09 +03:00
setSelectedItems([]);
2021-06-01 15:25:01 +03:00
};
return (
<>
<section className={style.outstaffing}>
<div className="container">
<div className="row">
<div className="col-12">
<div className={style.outstaffing__title}>
<h2>
<span>Аутстаффинг</span> it-персонала
</h2>
</div>
</div>
</div>
<div className="row">
<div className="col-4">
2021-06-01 17:28:09 +03:00
<OutstaffingBlock
2021-06-03 17:15:22 +03:00
data={data.find((item) => item.name === 'frontend')}
2021-06-02 14:04:26 +03:00
onClick={(item) => handleBlockClick(item)}
2021-06-03 17:15:22 +03:00
onClickhandleTabBar={(name) => onhandleTabBar(name)}
2021-06-01 17:28:09 +03:00
/>
2021-06-01 15:25:01 +03:00
</div>
<div className="col-4">
2021-06-01 17:28:09 +03:00
<OutstaffingBlock
2021-06-03 17:15:22 +03:00
data={data.find((item) => item.name === 'backend')}
2021-06-02 14:04:26 +03:00
onClick={(item) => handleBlockClick(item)}
2021-06-03 17:15:22 +03:00
onClickhandleTabBar={(name) => onhandleTabBar(name)}
2021-06-01 17:28:09 +03:00
/>
2021-06-01 15:25:01 +03:00
</div>
<div className="col-4">
2021-06-01 17:28:09 +03:00
<OutstaffingBlock
2021-06-02 14:04:26 +03:00
data={data.find((item) => item.name === 'design')}
onClick={(item) => handleBlockClick(item)}
2021-06-03 17:15:22 +03:00
onClickhandleTabBar={(name) => onhandleTabBar(name)}
2021-06-01 17:28:09 +03:00
/>
2021-06-01 15:25:01 +03:00
</div>
</div>
</div>
</section>
2021-06-01 17:28:09 +03:00
<TagSelect
options={data}
selectedItems={selectedItems}
tagSubmit={handleSubmit}
setSelectedItems={setSelectedItems}
/>
2021-06-01 15:25:01 +03:00
</>
);
};
export default Outstaffing;