Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6736 Rev 6885
Línea 8... Línea 8...
8
import SearchBar from '../../components/UI/SearchBar'
8
import SearchBar from '../../components/UI/SearchBar'
9
import TitleSection from '../../components/UI/TitleSection'
9
import TitleSection from '../../components/UI/TitleSection'
10
import EmptySection from '../../components/UI/EmptySection'
10
import EmptySection from '../../components/UI/EmptySection'
11
import ProfileItem from '../../components/profile/ProfileItem'
11
import ProfileItem from '../../components/profile/ProfileItem'
12
import LoaderContainer from '../../components/UI/LoaderContainer'
12
import LoaderContainer from '../../components/UI/LoaderContainer'
-
 
13
import PaginationComponent from '../../components/UI/PaginationComponent'
Línea 13... Línea 14...
13
 
14
 
14
const PeopleYouMayKnowPage = () => {
15
const PeopleYouMayKnowPage = () => {
-
 
16
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([])
-
 
17
  const [currentPage, setCurrentPage] = useState(1)
15
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([])
18
  const [totalPages, setTotalPages] = useState(1)
16
  const [loading, setLoading] = useState(false)
19
  const [loading, setLoading] = useState(false)
Línea 17... Línea 20...
17
  const [search, setSearch] = useState('')
20
  const [search, setSearch] = useState('')
18
 
21
 
Línea 19... Línea 22...
19
  const labels = useSelector(({ intl }) => intl.labels)
22
  const labels = useSelector(({ intl }) => intl.labels)
20
  const dispatch = useDispatch()
23
  const dispatch = useDispatch()
21
 
24
 
22
  const getPeopleYouMayKnow = async (search = '') => {
25
  const getPeopleYouMayKnow = async (search = '', page = 1) => {
23
    setLoading(true)
26
    setLoading(true)
24
    try {
27
    try {
-
 
28
      const { success, data } = await searchEntities(
25
      const { success, data } = await searchEntities(
29
        'connection/people-you-may-know',
Línea 26... Línea 30...
26
        'connection/people-you-may-know',
30
        search,
27
        search
31
        page
28
      )
32
      )
29
 
33
 
30
      if (!success) {
34
      if (!success) {
Línea 31... Línea 35...
31
        dispatch(addNotification({ style: 'danger', msg: data }))
35
        dispatch(addNotification({ style: 'danger', msg: data }))
-
 
36
        setLoading(false)
-
 
37
        return
32
        setLoading(false)
38
      }
33
        return
39
 
34
      }
40
      setPeopleYouMayKnow(data.current.items)
35
 
41
      setCurrentPage(data.current.page)
36
      setPeopleYouMayKnow(data)
42
      setTotalPages(data.total.pages)
37
    } catch (error) {
43
    } catch (error) {
38
      console.log(error)
44
      console.log(error)
Línea 39... Línea 45...
39
      throw new Error(error)
45
      throw new Error(error)
Línea -... Línea 46...
-
 
46
    } finally {
-
 
47
      setLoading(false)
-
 
48
    }
-
 
49
  }
40
    } finally {
50
 
41
      setLoading(false)
51
  const handleSearch = debounce((value) => setSearch(value), 500)
42
    }
52
 
Línea 43... Línea 53...
43
  }
53
  const onChangePageHandler = (currentPage) => {
44
 
54
    setCurrentPage(currentPage)
45
  const handleSearch = debounce((value) => setSearch(value), 500)
55
  }
46
 
56
 
Línea 73... Línea 83...
73
              message={labels.datatable_szerorecords}
83
              message={labels.datatable_szerorecords}
74
            />
84
            />
75
          )}
85
          )}
76
        </ul>
86
        </ul>
77
      )}
87
      )}
-
 
88
      <PaginationComponent
-
 
89
        isRow
-
 
90
        pages={totalPages}
-
 
91
        currentActivePage={currentPage}
-
 
92
        onChangePage={onChangePageHandler}
-
 
93
      />
78
    </main>
94
    </main>
79
  )
95
  )
80
}
96
}
Línea 81... Línea 97...
81
 
97