• 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

90.91
/src/components/twoFactor/TwoFactor.js
1
/* eslint-disable react/prop-types */
2
import React, { useState, useEffect, useCallback } from "react";
3
import { useNavigate } from "react-router-dom";
4
import { useDispatch, useSelector } from "react-redux";
5
import PageDesign from "../shared/TwoFactorPageDesign";
6
import FormContainerTwoFact from "./TwoFctFormCon";
7
import {
8
  getLoginUser,
9
  setGotEmail,
10
  setSuccessAuth,
11
  setError,
12
  setTwoFactorAuth,
13
} from "../../redux/features/slices/user";
14
import formatTime from "../../helpers/timeFormat";
15
import { ToastContainer, toast } from "react-toastify";
16

17
const TwoFactor = () => {
4✔
18
  const { error, successAuth, gotEmail } = useSelector(getLoginUser);
58✔
19
  const [seconds, setSeconds] = useState(300);
58✔
20
  const dispatch = useDispatch();
58✔
21
  const navigate = useNavigate();
58✔
22
  const onClick = () => dispatch(setGotEmail({ gotEmail: true }));
58✔
23
  const onLinkClick = () => dispatch(setTwoFactorAuth());
58✔
24
  const handleClick = useCallback(() => {
58✔
25
    dispatch(setSuccessAuth({ successAuth: false }));
8✔
26
    dispatch(setError({ error: null }));
8✔
27
  }, [dispatch, navigate, setSuccessAuth, setError]);
28
  useEffect(() => {
58✔
29
    if (seconds === 0) {
24✔
30
      localStorage.removeItem("userAuth");
2✔
31
      dispatch(setTwoFactorAuth());
2✔
32
      dispatch(setError({ error: null }));
2✔
33
      return navigate("/login");
2✔
34
    }
35
    const interval = setInterval(() => {
22✔
36
      setSeconds((seconds) => seconds - 1);
600✔
37
    }, 1000);
38
    return () => clearInterval(interval);
22✔
39
  }, [seconds, dispatch, setTwoFactorAuth, navigate]);
40

41
  useEffect(() => {
58✔
42
    if (successAuth) {
30!
43
      toast.success("Success", { onClose: handleClick });
×
44
      return;
×
45
    }
46
    if (error) {
30✔
47
      toast.error(error, { onClose: handleClick });
8✔
48
      return;
8✔
49
    }
50
  }, [successAuth, error]);
51

52
  return (
58✔
53
    <div>
54
      <ToastContainer />
55
      <PageDesign />
56
      <FormContainerTwoFact
57
        formatTime={formatTime(seconds)}
58
        gotEmail={gotEmail}
59
        onLinkClick={onLinkClick}
60
        onClick={onClick}
61
      />
62
    </div>
63
  );
64
};
65

66
export default TwoFactor;
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