Rev 3416 | Rev 3694 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React, { useState } from 'react'
import { useSelector } from 'react-redux'
import { Search } from '@mui/icons-material'
import { debounce } from '@utils'
import { useFetch, useSearchQuery } from '@hooks'
import Input from '@components/UI/inputs/Input'
import TitleSection from '@components/UI/TitleSection'
import MyCompaniesList from '@components/company/MyCompaniesList'
import AddCompanyModal from '@components/modals/AddCompanyModal'
const MyCompanies = () => {
const [showCompanyModal, setShowCompanyModal] = useState(false)
const labels = useSelector(({ intl }) => intl.labels)
const { getStringParams, setParam } = useSearchQuery()
const {
data: companies,
isLoading,
refetch
} = useFetch('/company/my-companies' + getStringParams())
const handleSearch = debounce((e) => setParam('search', e.target.value))
const toggleShowCompanyModal = () => setShowCompanyModal(!showCompanyModal)
return (
<>
<TitleSection
title={labels.my_companies}
onAdd={toggleShowCompanyModal}
addLabel={`${labels.add} ${labels.company?.toLowerCase()}`}
/>
<Input icon={<Search />} onChange={handleSearch} variant='search' />
<MyCompaniesList
companies={companies}
loading={isLoading}
onComplete={refetch}
/>
<AddCompanyModal
show={showCompanyModal}
onHide={toggleShowCompanyModal}
fetchCompanies={refetch}
/>
</>
)
}
export default MyCompanies