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