2021-06-07 17:48:07 +03:00
|
|
|
import React, { useState, useEffect } from 'react';
|
2021-07-05 12:33:24 +03:00
|
|
|
import { useDispatch } from 'react-redux';
|
2021-06-01 15:25:01 +03:00
|
|
|
import Outstaffing from '../Outstaffing/Outstaffing';
|
|
|
|
import Description from '../Description/Description';
|
2021-07-02 16:02:47 +03:00
|
|
|
import { fetchProfile, fetchSkills } from '../../server/server';
|
2021-07-05 12:33:24 +03:00
|
|
|
import { profiles, tags } from '../../redux/outstaffingSlice';
|
2021-06-07 17:48:07 +03:00
|
|
|
|
2021-07-02 16:02:47 +03:00
|
|
|
const Home = () => {
|
|
|
|
const [index, setIndex] = useState(2);
|
2021-06-03 17:15:22 +03:00
|
|
|
|
2021-06-30 17:21:55 +03:00
|
|
|
const dispatch = useDispatch();
|
2021-06-28 17:57:28 +03:00
|
|
|
|
2021-06-30 17:21:55 +03:00
|
|
|
useEffect(() => {
|
2021-07-02 16:02:47 +03:00
|
|
|
fetchProfile(`https://guild.craft-group.xyz/api/profile?limit=`, index)
|
2021-06-30 17:21:55 +03:00
|
|
|
.then((profileArr) => dispatch(profiles(profileArr)))
|
2021-06-29 17:58:15 +03:00
|
|
|
.catch((e) => console.log(e));
|
2021-06-30 17:21:55 +03:00
|
|
|
|
|
|
|
fetchSkills('https://guild.craft-group.xyz/api/skills/skills-on-main-page').then((skills) => {
|
|
|
|
const keys = Object.keys(skills);
|
|
|
|
const values = Object.values(skills);
|
|
|
|
|
|
|
|
const tempTags = values.map((value, index) =>
|
|
|
|
value.map((val) => {
|
|
|
|
return { id: val.id, value: val.tags, name: keys[index] };
|
|
|
|
})
|
|
|
|
);
|
|
|
|
dispatch(tags(tempTags));
|
|
|
|
});
|
2021-07-02 16:02:47 +03:00
|
|
|
}, [dispatch, index]);
|
2021-06-28 17:57:28 +03:00
|
|
|
|
2021-06-29 17:58:15 +03:00
|
|
|
const loadMore = (count) => {
|
2021-07-02 16:02:47 +03:00
|
|
|
setIndex((prev) => prev + count);
|
2021-06-03 17:15:22 +03:00
|
|
|
};
|
2021-06-07 17:48:07 +03:00
|
|
|
|
2021-05-26 13:35:57 +03:00
|
|
|
return (
|
2021-05-26 15:59:00 +03:00
|
|
|
<>
|
2021-07-01 14:25:17 +03:00
|
|
|
<Outstaffing />
|
2021-07-03 17:37:30 +03:00
|
|
|
<Description onLoadMore={loadMore} />
|
2021-05-26 15:59:00 +03:00
|
|
|
</>
|
2021-05-26 13:35:57 +03:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Home;
|