3719 |
stevensc |
1 |
import React from 'react';
|
|
|
2 |
import Search from '@mui/icons-material/Search';
|
|
|
3 |
import { useSelector } from 'react-redux';
|
|
|
4 |
|
|
|
5 |
import { debounce } from '@utils';
|
|
|
6 |
import { useFetch, useSearchQuery } from '@hooks';
|
|
|
7 |
|
|
|
8 |
import Input from '@components/UI/inputs/Input';
|
|
|
9 |
import TitleSection from '@components/UI/TitleSection';
|
|
|
10 |
import MyConnectionsList from '@components/connections/MyConnectionsList';
|
|
|
11 |
import Pagination from '@components/common/Pagination';
|
|
|
12 |
|
|
|
13 |
const MyConnectionsPage = () => {
|
|
|
14 |
const labels = useSelector(({ intl }) => intl.labels);
|
|
|
15 |
|
|
|
16 |
const { getStringParams, setParam } = useSearchQuery();
|
|
|
17 |
const { data, isLoading, refetch } = useFetch(`/connection/my-connections${getStringParams()}`);
|
|
|
18 |
|
|
|
19 |
const handleSearch = debounce((e) => setParam('search', e.target.value));
|
|
|
20 |
|
|
|
21 |
return (
|
|
|
22 |
<>
|
|
|
23 |
<TitleSection title={labels.first_level_persons} />
|
|
|
24 |
<Input icon={<Search />} onChange={handleSearch} variant='search' />
|
|
|
25 |
<MyConnectionsList
|
|
|
26 |
connections={data.current?.items}
|
|
|
27 |
loading={isLoading}
|
|
|
28 |
onComplete={refetch}
|
|
|
29 |
/>
|
|
|
30 |
<Pagination
|
|
|
31 |
pages={data.total?.pages}
|
|
|
32 |
page={data.current?.page}
|
|
|
33 |
onChange={(page) => setParam('page', page)}
|
|
|
34 |
/>
|
|
|
35 |
</>
|
|
|
36 |
);
|
|
|
37 |
};
|
|
|
38 |
|
|
|
39 |
export default MyConnectionsPage;
|