Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2939 Rev 3416
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'
3
import { Search } from "@mui/icons-material";
4
 
4
 
5
import { debounce } from '@utils'
5
import { debounce } from "@utils";
6
import { useFetch, useSearchQuery } from '@hooks'
6
import { useFetch, useSearchQuery } from "@hooks";
7
 
7
 
8
import Input from '@components/UI/inputs/Input'
8
import Input from "@components/UI/inputs/Input";
9
import TitleSection from '@components/UI/TitleSection'
9
import TitleSection from "@components/UI/TitleSection";
10
import MyCompaniesList from '@components/company/MyCompaniesList'
10
import MyCompaniesList from "@components/company/MyCompaniesList";
11
import AddCompanyModal from '@components/modals/AddCompanyModal'
11
import AddCompanyModal from "@components/modals/AddCompanyModal";
Línea 12... Línea 12...
12
 
12
 
13
const MyCompanies = () => {
13
const MyCompanies = () => {
14
  const [showCompanyModal, setShowCompanyModal] = useState(false)
14
  const [showCompanyModal, setShowCompanyModal] = useState(false);
Línea 15... Línea 15...
15
  const labels = useSelector(({ intl }) => intl.labels)
15
  const labels = useSelector(({ intl }) => intl.labels);
16
 
16
 
17
  const { getStringParams, setParam } = useSearchQuery()
17
  const { getStringParams, setParam } = useSearchQuery();
18
  const {
18
  const {
19
    data: companies,
19
    data: companies,
20
    isLoading,
20
    loading,
Línea 21... Línea 21...
21
    refetch
21
    refetch,
Línea 22... Línea 22...
22
  } = useFetch('/company/my-companies' + getStringParams())
22
  } = useFetch("/company/my-companies" + getStringParams());
Línea 23... Línea 23...
23
 
23
 
24
  const handleSearch = debounce((e) => setParam('search', e.target.value))
24
  const handleSearch = debounce((e) => setParam("search", e.target.value));
25
 
25
 
26
  const toggleShowCompanyModal = () => setShowCompanyModal(!showCompanyModal)
26
  const toggleShowCompanyModal = () => setShowCompanyModal(!showCompanyModal);
27
 
27
 
28
  return (
28
  return (
29
    <>
29
    <>
30
      <TitleSection
30
      <TitleSection
31
        title={labels.my_companies}
31
        title={labels.my_companies}
32
        onAdd={toggleShowCompanyModal}
32
        onAdd={toggleShowCompanyModal}
33
        addLabel={`${labels.add} ${labels.company?.toLowerCase()}`}
33
        addLabel={`${labels.add} ${labels.company?.toLowerCase()}`}
34
      />
34
      />
35
      <Input icon={<Search />} onChange={handleSearch} variant='search' />
35
      <Input icon={<Search />} onChange={handleSearch} variant="search" />
36
      <MyCompaniesList
36
      <MyCompaniesList
37
        companies={companies}
37
        companies={companies}
38
        loading={isLoading}
38
        loading={loading}
39
        onComplete={refetch}
39
        onComplete={refetch}
40
      />
40
      />
41
      <AddCompanyModal
41
      <AddCompanyModal
42
        show={showCompanyModal}
42
        show={showCompanyModal}
43
        onHide={toggleShowCompanyModal}
43
        onHide={toggleShowCompanyModal}
Línea 44... Línea 44...
44
        fetchCompanies={refetch}
44
        fetchCompanies={refetch}