2023-01-13 13:02:48 +03:00
|
|
|
import React, {useState, useEffect} from 'react'
|
2023-01-16 19:57:55 +03:00
|
|
|
import {useDispatch} from 'react-redux'
|
2023-01-13 13:02:48 +03:00
|
|
|
|
2021-11-30 16:00:58 +02:00
|
|
|
import Outstaffing from '../Outstaffing/Outstaffing'
|
|
|
|
import Description from '../Description/Description'
|
2023-01-13 13:02:48 +03:00
|
|
|
import {Footer} from '../Footer/Footer'
|
|
|
|
|
2023-01-16 19:57:55 +03:00
|
|
|
import {profiles, tags} from '../../redux/outstaffingSlice'
|
2023-01-13 13:02:48 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
2023-01-13 13:02:48 +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(() => {
|
2023-01-13 13:02:48 +03:00
|
|
|
setIsLoadingMore(true);
|
2023-01-16 15:24:08 +03:00
|
|
|
apiRequest('/profile', {
|
|
|
|
params: {limit: 1000},
|
2021-11-30 16:00:58 +02:00
|
|
|
}).then((profileArr) => {
|
2023-01-13 13:02:48 +03:00
|
|
|
|
|
|
|
dispatch(profiles(profileArr));
|
2021-11-30 16:00:58 +02:00
|
|
|
setIsLoadingMore(false)
|
2023-01-13 13:02:48 +03:00
|
|
|
});
|
|
|
|
|
2023-01-16 15:24:08 +03:00
|
|
|
apiRequest('/skills/skills-on-main-page', {
|
2021-11-30 16:00:58 +02:00
|
|
|
}).then((skills) => {
|
|
|
|
if (!skills) {
|
|
|
|
return []
|
|
|
|
}
|
2023-01-13 13:02:48 +03:00
|
|
|
|
|
|
|
const keys = Object.keys(skills);
|
|
|
|
const values = Object.values(skills);
|
2021-06-30 17:21:55 +03:00
|
|
|
|
|
|
|
const tempTags = values.map((value, index) =>
|
2023-01-13 13:02:48 +03:00
|
|
|
value.map((val) => {
|
|
|
|
return {id: val.id, value: val.tags, name: keys[index]}
|
|
|
|
})
|
|
|
|
);
|
2021-11-30 16:00:58 +02:00
|
|
|
dispatch(tags(tempTags))
|
|
|
|
})
|
2023-01-16 19:57:55 +03:00
|
|
|
console.log(1)
|
|
|
|
}, [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)
|
2023-01-13 13:02:48 +03:00
|
|
|
};
|
2021-06-07 17:48:07 +03:00
|
|
|
|
2021-05-26 13:35:57 +03:00
|
|
|
return (
|
2023-01-13 13:02:48 +03:00
|
|
|
<>
|
|
|
|
<Outstaffing/>
|
|
|
|
<Description onLoadMore={loadMore} isLoadingMore={isLoadingMore}/>
|
|
|
|
<Footer/>
|
|
|
|
</>
|
2021-11-30 16:00:58 +02:00
|
|
|
)
|
2023-01-13 13:02:48 +03:00
|
|
|
};
|
2021-05-26 13:35:57 +03:00
|
|
|
|
2021-11-30 16:00:58 +02:00
|
|
|
export default Home
|