67 lines
1.5 KiB
JavaScript
Raw Normal View History

import React, {useState, useEffect} from 'react'
import {useDispatch, useSelector} from 'react-redux'
2021-11-30 16:00:58 +02:00
import Outstaffing from '../Outstaffing/Outstaffing'
import Description from '../Description/Description'
import {Footer} from '../Footer/Footer'
import {profiles, tags, auth} from '../../redux/outstaffingSlice'
import {getRole} from '../../redux/roleSlice'
import {useRequest} from "../../hooks/useRequest";
2021-06-07 17:48:07 +03:00
2021-07-02 16:02:47 +03:00
const Home = () => {
2021-06-03 17:15:22 +03:00
const [isLoadingMore, setIsLoadingMore] = useState(false);
const [index, setIndex] = useState(4);
const dispatch = useDispatch();
const {apiRequest} = useRequest();
2021-06-28 17:57:28 +03:00
2021-06-30 17:21:55 +03:00
useEffect(() => {
setIsLoadingMore(true);
apiRequest('/profile', {
params: {limit: 1000},
2021-11-30 16:00:58 +02:00
}).then((profileArr) => {
dispatch(profiles(profileArr));
2021-11-30 16:00:58 +02:00
setIsLoadingMore(false)
});
apiRequest('/skills/skills-on-main-page', {
2021-11-30 16:00:58 +02:00
}).then((skills) => {
if (!skills) {
return []
}
const keys = Object.keys(skills);
const values = Object.values(skills);
2021-06-30 17:21:55 +03:00
const tempTags = values.map((value, index) =>
value.map((val) => {
return {id: val.id, value: val.tags, name: keys[index]}
})
);
2021-11-30 16:00:58 +02:00
dispatch(tags(tempTags))
})
}, [dispatch, index]);
2021-06-28 17:57:28 +03:00
2021-06-29 17:58:15 +03:00
const loadMore = (count) => {
2021-11-30 16:00:58 +02:00
setIndex((prev) => prev + count)
};
2021-06-07 17:48:07 +03:00
2021-05-26 13:35:57 +03:00
return (
<>
<Outstaffing/>
<Description onLoadMore={loadMore} isLoadingMore={isLoadingMore}/>
<Footer/>
</>
2021-11-30 16:00:58 +02:00
)
};
2021-05-26 13:35:57 +03:00
2021-11-30 16:00:58 +02:00
export default Home