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 Spinner from '../../components/UI/Spinner';
|
|
|
9 |
import Input from '../../components/UI/inputs/Input';
|
|
|
10 |
import ProfileItem from '../../components/profile/ProfileItem';
|
|
|
11 |
import EmptySection from '../../components/UI/EmptySection';
|
|
|
12 |
import TitleSection from '../../components/UI/TitleSection';
|
|
|
13 |
import Pagination from '@components/common/Pagination';
|
|
|
14 |
|
|
|
15 |
const ImpersonatePage = () => {
|
|
|
16 |
const { getParam, setParam } = useSearchQuery();
|
|
|
17 |
const { data, isLoading } = useFetch('/impersonate?search=' + getParam('search'));
|
|
|
18 |
const labels = useSelector(({ intl }) => intl.labels);
|
|
|
19 |
|
|
|
20 |
const handleSearch = debounce((value) => setParam('keyword', value), 500);
|
|
|
21 |
|
|
|
22 |
return (
|
|
|
23 |
<>
|
|
|
24 |
<TitleSection title='Usuarios disponibles a personalizar' />
|
|
|
25 |
|
|
|
26 |
<Input icon={<Search />} onChange={handleSearch} variant='search' />
|
|
|
27 |
|
|
|
28 |
{isLoading ? (
|
|
|
29 |
<Spinner />
|
|
|
30 |
) : (
|
|
|
31 |
<ul className='companies-list mt-3'>
|
|
|
32 |
{data.current?.items?.length > 0 ? (
|
|
|
33 |
data.current?.items?.map(({ image, name, email, network, link_impersonate }, id) => (
|
|
|
34 |
<ProfileItem
|
|
|
35 |
isTopData
|
|
|
36 |
key={id}
|
|
|
37 |
image={image}
|
|
|
38 |
name={name}
|
|
|
39 |
email={email}
|
|
|
40 |
network={network}
|
|
|
41 |
link_impersonate={link_impersonate}
|
|
|
42 |
/>
|
|
|
43 |
))
|
|
|
44 |
) : (
|
|
|
45 |
<EmptySection align='left' message={labels.datatable_szerorecords} />
|
|
|
46 |
)}
|
|
|
47 |
</ul>
|
|
|
48 |
)}
|
|
|
49 |
<Pagination
|
|
|
50 |
pages={data.total?.pages}
|
|
|
51 |
page={data.current?.page}
|
|
|
52 |
onChange={(newPage) => setParam('page', newPage)}
|
|
|
53 |
/>
|
|
|
54 |
</>
|
|
|
55 |
);
|
|
|
56 |
};
|
|
|
57 |
|
|
|
58 |
export default ImpersonatePage;
|