Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4890 Rev 4891
Línea 1... Línea -...
1
import React from "react";
-
 
2
import { useEffect, useState } from "react";
1
import React, { useEffect, useState } from "react"
3
import { connect } from "react-redux";
2
import { connect } from "react-redux"
4
import { axios } from "../../../utils";
3
import { axios } from "../../../utils"
5
import { addNotification } from "../../../redux/notification/notification.actions";
4
import { addNotification } from "../../../redux/notification/notification.actions"
6
import Spinner from "../../../shared/loading-spinner/Spinner";
5
import Spinner from "../../../shared/loading-spinner/Spinner"
7
import Profile from "../../../components/Profile";
6
import Profile from "../../../components/Profile"
8
import SearchList from "../../../components/SearchList";
7
import SearchList from "../../../components/SearchList"
9
import PaginationComponent from "../../../shared/pagination/PaginationComponent";
8
import PaginationComponent from "../../../shared/pagination/PaginationComponent"
Línea 10... Línea 9...
10
 
9
 
11
const MyConnections = () => {
10
const MyConnections = () => {
12
  const [myConnections, setMyConnections] = useState([])
11
  const [myConnections, setMyConnections] = useState([])
13
  const [currentPage, setCurrentPage] = useState(1)
12
  const [currentPage, setCurrentPage] = useState(1)
14
  const [search, setSearch] = useState('')
13
  const [search, setSearch] = useState('')
15
  const [pages, setPages] = useState(1)
14
  const [pages, setPages] = useState(1)
Línea 16... Línea -...
16
  const [loading, setLoading] = useState(true)
-
 
17
 
-
 
18
  useEffect(() => {
-
 
19
    fetchMyConnections({
-
 
20
      search: search,
-
 
21
      page: currentPage
-
 
22
    })
-
 
23
  }, [currentPage, search]);
15
  const [loading, setLoading] = useState(true)
24
 
16
 
25
  const fetchMyConnections = async ({ search = '', page = 1 }) => {
17
  const fetchMyConnections = async ({ search = '', page = 1 }) => {
26
    setLoading(true);
18
    setLoading(true)
27
    await axios
19
    await axios
28
      .get(`/connection/my-connections?search=${search}`, { params: { page } })
20
      .get(`/connection/my-connections?search=${search}`, { params: { page } })
29
      .then(({ data: response }) => {
21
      .then(({ data: response }) => {
30
        if (response.success) {
22
        if (response.success) {
31
          setMyConnections(response.data.current.items)
23
          setMyConnections(response.data.current.items)
32
          setCurrentPage(response.data.current.page)
24
          setCurrentPage(response.data.current.page)
33
          setPages(response.data.total.pages)
25
          setPages(response.data.total.pages)
34
        }
26
        }
35
      });
27
      })
Línea 36... Línea 28...
36
    setLoading(false);
28
    setLoading(false)
Línea -... Línea 29...
-
 
29
  }
-
 
30
 
-
 
31
  const handleChangePage = (newPage) => setCurrentPage(newPage)
-
 
32
 
-
 
33
  useEffect(() => {
-
 
34
    fetchMyConnections({
-
 
35
      search: search,
37
  };
36
      page: currentPage
38
 
37
    })
39
  const handleChangePage = (newPage) => setCurrentPage(newPage)
38
  }, [currentPage, search])
40
 
39
 
41
  return (
40
  return (
Línea 84... Línea 83...
84
 
83
 
85
const mapDispatchToProps = {
84
const mapDispatchToProps = {
86
  addNotification: (notification) => addNotification(notification),
85
  addNotification: (notification) => addNotification(notification),
Línea 87... Línea -...
87
}
-
 
88
 
86
}
-
 
87
 
89
export default connect(null, mapDispatchToProps)(MyConnections);
88
export default connect(null, mapDispatchToProps)(MyConnections)