| Línea 1... |
Línea 1... |
| 1 |
import React, { useState } from 'react';
|
1 |
import React, { useState } from 'react';
|
| 2 |
import { useSelector } from 'react-redux';
|
2 |
import { useSelector } from 'react-redux';
|
| 3 |
import Search from '@mui/icons-material/Search';
|
3 |
import Search from '@mui/icons-material/Search';
|
| 4 |
import { Box, styled } from '@mui/material';
|
- |
|
| 5 |
|
4 |
|
| 6 |
import { debounce } from '@utils';
|
5 |
import { debounce } from '@utils';
|
| 7 |
import { useFetch, useSearchQuery } from '@hooks';
|
6 |
import { useFetch, useSearchQuery } from '@hooks';
|
| 8 |
|
7 |
|
| 9 |
import Input from '@components/UI/inputs/Input';
|
8 |
import Input from '@components/UI/inputs/Input';
|
| 10 |
import TitleSection from '@components/UI/TitleSection';
|
9 |
import TitleSection from '@components/UI/TitleSection';
|
| 11 |
import AddProfileModal from '@components/modals/AddProfileModal';
|
10 |
import AddProfileModal from '@components/modals/AddProfileModal';
|
| 12 |
import MyProfilesList from '@components/profile/MyProfilesList';
|
11 |
import MyProfilesList from '@components/profile/MyProfilesList';
|
| 13 |
|
12 |
|
| 14 |
const MyProfilesPage = () => {
|
13 |
const MyProfilesPage = () => {
|
| 15 |
const [isShowAddModal, setIsShowAddModal] = useState(false);
|
14 |
const [isShowAddModal, setIsShowAddModal] = useState(false);
|
| 16 |
|
15 |
|
| 17 |
const toggleModal = () => setIsShowAddModal(!isShowAddModal);
|
16 |
const toggleModal = () => setIsShowAddModal(!isShowAddModal);
|
| 18 |
|
17 |
|
| 19 |
const labels = useSelector(({ intl }) => intl.labels);
|
18 |
const labels = useSelector(({ intl }) => intl.labels);
|
| 20 |
|
19 |
|
| 21 |
const { getStringParams, setParam } = useSearchQuery();
|
20 |
const { getStringParams, setParam } = useSearchQuery();
|
| 22 |
const { data, isLoading, refetch } = useFetch('/profile/my-profiles' + getStringParams());
|
21 |
const { data, isLoading, refetch } = useFetch('/profile/my-profiles' + getStringParams());
|
| 23 |
|
22 |
|
| 24 |
const handleSearch = debounce((e) => setParam('search', e.target.value));
|
23 |
const handleSearch = debounce((e) => setParam('search', e.target.value));
|
| 25 |
|
24 |
|
| 26 |
return (
|
25 |
return (
|
| 27 |
<>
|
26 |
<>
|
| 28 |
<TitleSection title={labels.my_profiles} onAdd={toggleModal} addLabel={labels.add} />
|
27 |
<TitleSection title={labels.my_profiles} onAdd={toggleModal} addLabel={labels.add} />
|
| 29 |
<Input
|
28 |
<Input
|
| 30 |
icon={<Search />}
|
29 |
icon={<Search />}
|
| 31 |
onChange={handleSearch}
|
30 |
onChange={handleSearch}
|
| 32 |
placeholder={labels.search}
|
31 |
placeholder={labels.search}
|
| 33 |
variant='search'
|
32 |
variant='search'
|
| 34 |
color='secondary'
|
33 |
color='secondary'
|
| 35 |
/>
|
34 |
/>
|
| 36 |
<MyProfilesList profiles={data} loading={isLoading} onComplete={refetch} />
|
35 |
<MyProfilesList profiles={data} loading={isLoading} onComplete={refetch} />
|
| 37 |
<AddProfileModal show={isShowAddModal} getProfiles={() => refetch()} onHide={toggleModal} />
|
36 |
<AddProfileModal show={isShowAddModal} getProfiles={() => refetch()} onHide={toggleModal} />
|
| 38 |
</>
|
37 |
</>
|
| 39 |
);
|
38 |
);
|
| 40 |
};
|
39 |
};
|
| 41 |
|
40 |
|
| 42 |
export default MyProfilesPage;
|
41 |
export default MyProfilesPage;
|