guild_front/src/components/Outstaffing/Outstaffing.js

88 lines
2.6 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
const Outstaffing = () => {
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(() => {
const tempData = ['Ruby on Rails', 'Nginx', 'Docker', 'PostgreSQL', 'Vue.js', 'Typescript', 'ReactJS'];
setData(tempData);
}, []);
2021-06-01 17:28:09 +03:00
const handleBlockClick = (index) => {
if (selectedItems.find((item) => item.value === data[index])) {
return;
// setSelectedItems(selectedItems.filter((item) => item.value !== data[index]));
} else {
setSelectedItems([...selectedItems, { value: data[index], label: data[index] }]);
}
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
image={front}
data={data}
header={'# Популярный стек'}
onClick={(index) => handleBlockClick(index)}
/>
2021-06-01 15:25:01 +03:00
</div>
<div className="col-4">
2021-06-01 17:28:09 +03:00
<OutstaffingBlock
image={back}
data={data}
header={'# Популярный стек'}
onClick={(index) => handleBlockClick(index)}
/>
2021-06-01 15:25:01 +03:00
</div>
<div className="col-4">
2021-06-01 17:28:09 +03:00
<OutstaffingBlock
image={design}
data={data}
header={'# Популярный стек'}
onClick={(index) => handleBlockClick(index)}
/>
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;