Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2806 | Rev 2873 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2806 Rev 2864
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'
Línea 3... Línea 4...
3
 
4
 
4
import { useFetch } from '@hooks'
5
import { debounce } from '@utils'
Línea 5... Línea -...
5
import { debounce } from '@app/utils'
-
 
6
 
-
 
7
import EmptySection from '@components/UI/EmptySection'
-
 
8
import SearchBar from '@components/UI/SearchBar'
6
import { useFetch, useSearchParams } from '@hooks'
-
 
7
 
-
 
8
import TitleSection from '@components/UI/TitleSection'
9
import Spinner from '@components/UI/Spinner'
9
import Input from '@components/UI/inputs/Input'
10
import TitleSection from '@components/UI/TitleSection'
-
 
Línea 11... Línea 10...
11
import AddCompanyModal from '@components/modals/AddCompanyModal'
10
import MyCompaniesList from '@components/company/MyCompaniesList'
12
import ProfileItem from '@components/profile/ProfileItem'
-
 
13
 
11
import AddCompanyModal from '@components/modals/AddCompanyModal'
14
const MyCompanies = () => {
12
 
Línea -... Línea 13...
-
 
13
const MyCompanies = () => {
15
  const [search, setSearch] = useState('')
14
  const [showCompanyModal, setShowCompanyModal] = useState(false)
16
  const [showCompanyModal, setShowCompanyModal] = useState(false)
15
  const labels = useSelector(({ intl }) => intl.labels)
17
  const labels = useSelector(({ intl }) => intl.labels)
16
 
18
 
17
  const { params, setParams } = useSearchParams()
19
  const {
18
  const {
Línea 20... Línea 19...
20
    data: companies,
19
    data: companies,
Línea 21... Línea 20...
21
    isLoading,
20
    isLoading,
Línea 22... Línea 21...
22
    refetch
21
    refetch
23
  } = useFetch(`/company/my-companies?search=${search}`)
22
  } = useFetch('/company/my-companies' + params)
24
 
23
 
25
  const toggleShowCompanyModal = () => setShowCompanyModal(!showCompanyModal)
24
  const handleSearch = debounce((value) => setParams('search', value), 500)
26
 
25
 
27
  const handleSearch = debounce((value) => setSearch(value), 500)
26
  const toggleShowCompanyModal = () => setShowCompanyModal(!showCompanyModal)
28
 
27
 
Línea 29... Línea 28...
29
  return (
28
  return (
Línea 30... Línea 29...
30
    <>
29
    <>
31
      <TitleSection
-
 
32
        title={labels.my_companies}
30
      <TitleSection
33
        onAdd={toggleShowCompanyModal}
-
 
34
        addLabel={`${labels.add} ${labels.company?.toLowerCase()}`}
-
 
35
      />
31
        title={labels.my_companies}
36
 
-
 
37
      <SearchBar onChange={handleSearch} />
-
 
38
 
32
        onAdd={toggleShowCompanyModal}
39
      <ul className='companies-list'>
-
 
40
        {isLoading ? <Spinner /> : null}
-
 
41
        {companies.length ? (
-
 
42
          companies.map(({ id, link_my_company, ...rest }) => (
-
 
43
            <ProfileItem
-
 
44
              key={id}
33
        addLabel={`${labels.add} ${labels.company?.toLowerCase()}`}
Línea 45... Línea 34...
45
              link_admin={link_my_company}
34
      />
46
              btnAcceptTitle={labels.view_company}
35
 
47
              {...rest}
36
      <Input icon={<Search />} onChange={handleSearch} />
48
            />
37