add async requests
This commit is contained in:
parent
b277082497
commit
1fac7bf50e
@ -36,27 +36,25 @@ const tabsList = [
|
|||||||
img: front,
|
img: front,
|
||||||
text: '# Популярный стек',
|
text: '# Популярный стек',
|
||||||
header: 'Фронтенд',
|
header: 'Фронтенд',
|
||||||
tags: ['Vue.js', 'ReactJS', 'Angular', 'JavaScript', 'Html', 'Css', 'MobX'],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Backend',
|
name: 'Backend',
|
||||||
img: back,
|
img: back,
|
||||||
text: '# Популярный стек',
|
text: '# Популярный стек',
|
||||||
header: 'Бэкенд',
|
header: 'Бэкенд',
|
||||||
tags: ['Node.js', 'Express', 'Php', 'Ruby on Rails', 'Python', 'Wordpress', ' Java'],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Design',
|
name: 'Design',
|
||||||
img: design,
|
img: design,
|
||||||
text: '# Популярный стек',
|
text: '# Популярный стек',
|
||||||
header: 'Дизайн',
|
header: 'Дизайн',
|
||||||
tags: ['Figma', 'Avocode', 'PhotoShop', 'Xara', 'Pinegrow', 'Macaw', 'KompoZer'],
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
const [tabs, setTabs] = useState([]);
|
const [tabs, setTabs] = useState([]);
|
||||||
const [candidates, setCandidates] = useState([]);
|
const [candidates, setCandidates] = useState([]);
|
||||||
|
const [tags, setTags] = useState([]);
|
||||||
|
|
||||||
const [selectedTab, setSelectedTab] = useState('');
|
const [selectedTab, setSelectedTab] = useState('');
|
||||||
|
|
||||||
@ -65,8 +63,21 @@ const Home = () => {
|
|||||||
setCandidates(candidatesList);
|
setCandidates(candidatesList);
|
||||||
|
|
||||||
fetch('https://guild.craft-group.xyz/api/skills/skills-on-main-page')
|
fetch('https://guild.craft-group.xyz/api/skills/skills-on-main-page')
|
||||||
.then((res) => res.json())
|
.then((response) => response.json())
|
||||||
.then((resJson) => console.log(resJson));
|
.then((res) => {
|
||||||
|
const keys = Object.keys(res);
|
||||||
|
const values = Object.values(res);
|
||||||
|
|
||||||
|
console.log(values);
|
||||||
|
|
||||||
|
const tempTags = values.map((item, index) =>
|
||||||
|
item.map((tag) => {
|
||||||
|
return { id: tag.id, value: tag.tags, name: keys[index] };
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
setTags(tempTags);
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleBlockClick = (name) => {
|
const handleBlockClick = (name) => {
|
||||||
@ -75,7 +86,7 @@ const Home = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Outstaffing onhandleTabBar={(name) => handleBlockClick(name)} selected={selectedTab} tabs={tabs} />
|
<Outstaffing onhandleTabBar={(name) => handleBlockClick(name)} selected={selectedTab} tabs={tabs} tags={tags} />
|
||||||
<Description
|
<Description
|
||||||
candidatesListArr={selectedTab ? candidates.filter((item) => item.name === selectedTab) : candidates}
|
candidatesListArr={selectedTab ? candidates.filter((item) => item.name === selectedTab) : candidates}
|
||||||
/>
|
/>
|
||||||
|
@ -3,16 +3,13 @@ import style from './Outstaffing.module.css';
|
|||||||
import OutstaffingBlock from './OutstaffingBlock';
|
import OutstaffingBlock from './OutstaffingBlock';
|
||||||
import TagSelect from '../Select/TagSelect';
|
import TagSelect from '../Select/TagSelect';
|
||||||
|
|
||||||
const Outstaffing = ({ onhandleTabBar, selected, tabs }) => {
|
const Outstaffing = ({ onhandleTabBar, selected, tabs, tags }) => {
|
||||||
const [selectedItems, setSelectedItems] = useState([]);
|
const [selectedItems, setSelectedItems] = useState([]);
|
||||||
|
|
||||||
const handleBlockClick = (item) => {
|
const handleBlockClick = (item) => {
|
||||||
if (!selectedItems.find((el) => item === el.value)) {
|
if (!selectedItems.find((el) => item === el.value)) {
|
||||||
setSelectedItems([...selectedItems, { value: item, label: item }]);
|
setSelectedItems([...selectedItems, { value: item, label: item }]);
|
||||||
}
|
}
|
||||||
// else {
|
|
||||||
// setSelectedItems(selectedItems.filter((el) => item !== el.value));
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
@ -41,6 +38,7 @@ const Outstaffing = ({ onhandleTabBar, selected, tabs }) => {
|
|||||||
<div className="col-12 col-xl-4">
|
<div className="col-12 col-xl-4">
|
||||||
<OutstaffingBlock
|
<OutstaffingBlock
|
||||||
data={tabs.find((item) => item.name === 'Frontend')}
|
data={tabs.find((item) => item.name === 'Frontend')}
|
||||||
|
dataTags={tags.flat().filter((tag) => tag.name === 'skills_front')}
|
||||||
onClick={(item) => handleBlockClick(item)}
|
onClick={(item) => handleBlockClick(item)}
|
||||||
onTabBarClick={(name) => onhandleTabBar(name)}
|
onTabBarClick={(name) => onhandleTabBar(name)}
|
||||||
selected={selected === 'Frontend'}
|
selected={selected === 'Frontend'}
|
||||||
@ -49,6 +47,7 @@ const Outstaffing = ({ onhandleTabBar, selected, tabs }) => {
|
|||||||
<div className="col-12 col-xl-4">
|
<div className="col-12 col-xl-4">
|
||||||
<OutstaffingBlock
|
<OutstaffingBlock
|
||||||
data={tabs.find((item) => item.name === 'Backend')}
|
data={tabs.find((item) => item.name === 'Backend')}
|
||||||
|
dataTags={tags.flat().filter((tag) => tag.name === 'skills_back')}
|
||||||
onClick={(item) => handleBlockClick(item)}
|
onClick={(item) => handleBlockClick(item)}
|
||||||
onTabBarClick={(name) => onhandleTabBar(name)}
|
onTabBarClick={(name) => onhandleTabBar(name)}
|
||||||
selected={selected === 'Backend'}
|
selected={selected === 'Backend'}
|
||||||
@ -57,6 +56,7 @@ const Outstaffing = ({ onhandleTabBar, selected, tabs }) => {
|
|||||||
<div className="col-12 col-xl-4">
|
<div className="col-12 col-xl-4">
|
||||||
<OutstaffingBlock
|
<OutstaffingBlock
|
||||||
data={tabs.find((item) => item.name === 'Design')}
|
data={tabs.find((item) => item.name === 'Design')}
|
||||||
|
dataTags={tags.flat().filter((tag) => tag.name === 'skills_design')}
|
||||||
onClick={(item) => handleBlockClick(item)}
|
onClick={(item) => handleBlockClick(item)}
|
||||||
onTabBarClick={(name) => onhandleTabBar(name)}
|
onTabBarClick={(name) => onhandleTabBar(name)}
|
||||||
selected={selected === 'Design'}
|
selected={selected === 'Design'}
|
||||||
@ -66,7 +66,7 @@ const Outstaffing = ({ onhandleTabBar, selected, tabs }) => {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<TagSelect
|
<TagSelect
|
||||||
options={tabs}
|
options={tags}
|
||||||
selectedItems={selectedItems}
|
selectedItems={selectedItems}
|
||||||
tagSubmit={handleSubmit}
|
tagSubmit={handleSubmit}
|
||||||
setSelectedItems={setSelectedItems}
|
setSelectedItems={setSelectedItems}
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import style from './Outstaffing.module.css';
|
import style from './Outstaffing.module.css';
|
||||||
|
|
||||||
const OutstaffingBlock = ({ data = {}, onClick, onTabBarClick, selected }) => {
|
const OutstaffingBlock = ({ dataTags = [], data = {}, onClick, onTabBarClick, selected }) => {
|
||||||
const { img, text, tags, name, header } = data;
|
const { header, img, text, name } = data;
|
||||||
|
|
||||||
let classes;
|
let classes;
|
||||||
|
|
||||||
if (name === 'Backend') {
|
dataTags.forEach((el) => {
|
||||||
classes = style.back;
|
if (el.name === 'skills_back') {
|
||||||
} else if (name === 'Design') {
|
classes = style.back;
|
||||||
classes = style.des;
|
} else if (el.name === 'skills_design') {
|
||||||
} else if (name === 'Frontend') {
|
classes = style.des;
|
||||||
classes = style.front;
|
} else if (el.name === 'skills_front') {
|
||||||
}
|
classes = style.front;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.outstaffing__box}>
|
<div className={style.outstaffing__box}>
|
||||||
@ -24,11 +27,11 @@ const OutstaffingBlock = ({ data = {}, onClick, onTabBarClick, selected }) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className={`${selected ? style.mobile__block : style.mobile__none}`}>
|
<div className={`${selected ? style.mobile__block : style.mobile__none}`}>
|
||||||
<p className={style.outstaffing__box__text}>{text}</p>
|
<p className={style.outstaffing__box__text}>{text}</p>
|
||||||
{tags && (
|
{dataTags && (
|
||||||
<ul className={style.items}>
|
<ul className={style.items}>
|
||||||
{tags.map((item) => (
|
{dataTags.map((item) => (
|
||||||
<li key={item} onClick={() => onClick(item)}>
|
<li key={item.id} onClick={() => onClick(item.value)}>
|
||||||
{item}
|
{item.value}
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -18,11 +18,9 @@ const TagSelect = ({ selectedItems, tagSubmit, options, setSelectedItems }) => {
|
|||||||
name="tags"
|
name="tags"
|
||||||
className={style.select}
|
className={style.select}
|
||||||
classNamePrefix={style.select}
|
classNamePrefix={style.select}
|
||||||
options={options
|
options={options.flat().map((item) => {
|
||||||
.flatMap((el) => el.tags)
|
return { value: item.value, label: item.value };
|
||||||
.map((item) => {
|
})}
|
||||||
return { value: item, label: item };
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
<button onClick={tagSubmit} type="submit">
|
<button onClick={tagSubmit} type="submit">
|
||||||
Поиск
|
Поиск
|
||||||
|
Loading…
Reference in New Issue
Block a user