• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

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

6.67
/src/components/auth/ProtectedRoutes.js
1
import React, { useState, useEffect } from "react";
2
import jwtDecode from "jwt-decode";
3
import Error from "../shared/Error";
4
import { Outlet, useNavigate } from "react-router-dom";
5

6
const ProtectedRoutes = ({ role }) => {
4✔
7
  const [isAuth, setIsAuth] = useState(false);
×
8
  const navigate = useNavigate();
×
9
  const auth = () => {
×
10
    const token = localStorage.getItem("token");
×
11
    const { data } = jwtDecode(token);
×
12
    if (data.role === role) {
×
13
      setIsAuth(true);
×
14
    }
15
  };
16
  useEffect(() => {
×
17
    auth();
×
18
  }, [isAuth]);
19
  return isAuth ? (
×
20
    <Outlet />
21
  ) : (
22
    // <Error
23
    //   code="401"
24
    //   title="Unauthorized"
25
    //   description="Denied access to this page"
26
    //   to="login"
27
    // />
28
    navigate("/")
29
  );
30
};
31

32
export default ProtectedRoutes;
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