• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Build has been canceled!

atlp-rwanda / trojans-ec-fe / 0cb862e4-0fa2-47c7-95e9-d93125127b5b

pending completion
0cb862e4-0fa2-47c7-95e9-d93125127b5b

push

circleci

GitHub
feature(navbar/sidebar):Dashboard sidebar/navbar and main navbar [Finishes #185032608] (#33)

452 of 602 branches covered (75.08%)

Branch coverage included in aggregate %.

309 of 309 new or added lines in 56 files covered. (100.0%)

1056 of 1253 relevant lines covered (84.28%)

23.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.19
/src/components/UserTable.js
1
import React, { useEffect, useState } from "react";
2
import Pagination from "./Pagination";
3
import BackButton from "./BackButton";
4
import TbBody from "./TbBody";
5
import { useDispatch, useSelector } from "react-redux";
6
import { getUsersThunk } from "../redux/features/actions/user";
7
import { getUsers } from "../redux/features/slices/getUsers";
8
import { LoadingTable } from "./skeleton/LoadingTable";
9
import TbHeader from "./TbHeader";
10
import { ToastContainer } from "react-toastify";
11

12
const UserTable = () => {
8✔
13
  const dispatch = useDispatch();
22✔
14
  const { users, getLoading, error } = useSelector(getUsers);
18✔
15
  const [currentPage, setCurrentPage] = useState(1);
18✔
16
  const usersPerPage = 5;
18✔
17
  const lastUsersIndex = currentPage * usersPerPage;
18✔
18
  const firstUsersIndex = lastUsersIndex - usersPerPage;
18✔
19
  const currentUsers = users.slice(firstUsersIndex, lastUsersIndex);
18✔
20
  useEffect(() => {
18✔
21
    dispatch(getUsersThunk());
4✔
22
  }, [dispatch]);
23
  const prevPage = () => {
18✔
24
    if (currentPage !== 1) {
2!
25
      setCurrentPage(currentPage - 1);
×
26
    }
27
  };
28
  const totalUsers = Math.ceil(users.length / usersPerPage);
18✔
29

30
  const nextPage = () => {
18✔
31
    if (currentPage !== totalUsers) {
2!
32
      setCurrentPage(currentPage + 1);
×
33
    }
34
  };
35

36
  return (
18✔
37
    <div>
38
      {getLoading && <LoadingTable />}
22✔
39
      {!getLoading && !error && (
40✔
40
        <div className="allUsers box-border w-[100%] min-h-[80vh] bg-white px-8 py-4 rounded-2xl relative lg:w-full">
41
          <ToastContainer />
42
          <div className="w-full">
43
            {/* <BackButton /> */}
44
            <h1 className="text-center font-bold text-purple-900 py-4">
45
              All Users
46
            </h1>
47
            <div className="container mx-auto userTable overflow-x-auto  ">
48
              <table className="w-full table" data-testid="table">
49
                <thead>
50
                  <TbHeader />
51
                </thead>
52
                <tbody>
53
                  <TbBody currentUsers={currentUsers} />
54
                </tbody>
55
              </table>
56
            </div>
57

58
            <div className="container mx-auto pagination my-4 flex outside">
59
              <button
60
                className="bg-gray-300 rounded px-2 py-[1px] hover:bg-gray-400 font-semibold"
61
                onClick={prevPage}
62
              >
63
                Prev
64
              </button>
65
              <Pagination
66
                totalUsers={users.length}
67
                usersPerPage={usersPerPage}
68
                setCurrentPage={setCurrentPage}
69
                currentPage={currentPage}
70
              />
71
              <button
72
                className="bg-gray-300 rounded px-2 py-[1px] hover:bg-gray-400 font-semibold"
73
                onClick={nextPage}
74
              >
75
                Next
76
              </button>
77
            </div>
78
          </div>
79
        </div>
80
      )}
81
    </div>
82
  );
83
};
84

85
export default UserTable;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc