Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 7599 Rev 7806
Línea 5... Línea 5...
5
import Follower from "./follower/Follower";
5
import Follower from "./follower/Follower";
6
import PaginationComponent from "../../shared/PaginationComponent";
6
import PaginationComponent from "../../shared/PaginationComponent";
7
import ContentTitle from "../../shared/ContentTitle";
7
import ContentTitle from "../../shared/ContentTitle";
Línea 8... Línea 8...
8
 
8
 
-
 
9
const Followers = ({ backendVars }) => {
9
const Followers = ({ backendVars }) => {
10
 
-
 
11
  let axiosThrottle = null;
10
  // backendVars destructuring
12
 
11
  const { table_link, allowDelete } = backendVars;
13
  const { table_link, allowDelete } = backendVars;
12
  // states
14
 
13
  const [followers, setFollowers] = useState([]);
15
  const [followers, setFollowers] = useState([]);
14
  const [loading, setLoading] = useState(true);
16
  const [loading, setLoading] = useState(true);
15
  const [pages, setPages] = useState(1);
17
  const [pages, setPages] = useState(1);
Línea 16... Línea -...
16
  const [currentPage, setCurrentPage] = useState(1);
-
 
17
 
18
  const [currentPage, setCurrentPage] = useState(1);
Línea 18... Línea -...
18
  // React hook form
-
 
19
  const { register, getValues } = useForm();
-
 
20
 
19
 
21
  let axiosThrottle = null;
20
  const { register, getValues } = useForm();
22
 
21
 
23
  useEffect(() => {
22
  useEffect(() => {
24
    fetchFollowers();
23
    fetchFollowers();
Línea 35... Línea 34...
35
      },
34
      },
36
    };
35
    };
37
    if (getValues("search")) {
36
    if (getValues("search")) {
38
      params = { params: { ...params.params, search: getValues("search") } };
37
      params = { params: { ...params.params, search: getValues("search") } };
39
    }
38
    }
40
    await axios
-
 
41
      .get(table_link, params)
39
    await axios.get(table_link, params)
42
      .then(({ data }) => {
40
      .then(({ data }) => {
43
        if (data.success) {
41
        if (data.success) {
44
          setFollowers(data.data.items);
42
          setFollowers(data.data.items);
45
        }
43
        }
46
      });
44
      });
47
    setLoading(false);
45
    setLoading(false);
48
  };
46
  };
Línea 49... Línea 47...
49
 
47
 
50
  const handleSearch = () => {
-
 
51
    //  (getValues());
48
  const handleSearch = () => {
52
    clearTimeout(axiosThrottle);
-
 
53
    // setLoading(true);
49
    clearTimeout(axiosThrottle);
54
    axiosThrottle = setTimeout(() => {
50
    axiosThrottle = setTimeout(() => {
55
      fetchFollowers();
51
      fetchFollowers();
56
    }, 500);
52
    }, 500);
Línea -... Línea 53...
-
 
53
  };
-
 
54
 
-
 
55
  const deleteFollower = (email) => {
-
 
56
    setFollowers(followers.filter((follower) => follower.email !== email))
57
  };
57
  }
58
 
58
 
59
  const handleChangePage = (newPage) => {
59
  const handleChangePage = (newPage) => {
Línea 60... Línea 60...
60
    setCurrentPage(newPage);
60
    setCurrentPage(newPage);
Línea 98... Línea 98...
98
              first_name={first_name}
98
              first_name={first_name}
99
              last_name={last_name}
99
              last_name={last_name}
100
              email={email}
100
              email={email}
101
              actions={actions}
101
              actions={actions}
102
              allowDelete={allowDelete}
102
              allowDelete={allowDelete}
-
 
103
              deleteFollower={deleteFollower}
103
            />
104
            />
104
          ))}
105
          ))}
105
          <PaginationComponent
106
          <PaginationComponent
106
            pages={pages}
107
            pages={pages}
107
            currentPage={currentPage}
108
            currentPage={currentPage}