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

atlp-rwanda / trojans-ec-fe / 69e36c33-b34f-4620-a04a-b4b713e8b75e

pending completion
69e36c33-b34f-4620-a04a-b4b713e8b75e

push

circleci

GitHub
feature(delete, update):delete and update product (#19)

410 of 531 branches covered (77.21%)

Branch coverage included in aggregate %.

244 of 244 new or added lines in 38 files covered. (100.0%)

980 of 1144 relevant lines covered (85.66%)

21.98 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 = () => {
2✔
18
    const { error, successAuth, gotEmail } = useSelector(getLoginUser);
62✔
19
    const [seconds, setSeconds] = useState(300);
62✔
20
    const dispatch = useDispatch();
62✔
21
    const navigate = useNavigate();
62✔
22
    const onClick = () => dispatch(setGotEmail({ gotEmail: true }));
62✔
23
    const onLinkClick = () => dispatch(setTwoFactorAuth());
62✔
24
    const handleClick = useCallback(() => {
62✔
25
        dispatch(setSuccessAuth({ successAuth: false }));
8✔
26
        dispatch(setError({ error: null }));
8✔
27
    }, [dispatch, navigate, setSuccessAuth, setError]);
28
    useEffect(() => {
62✔
29
        if (seconds === 0) {
26✔
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(() => {
24✔
36
          setSeconds(seconds => seconds - 1);
600✔
37
        }, 1000);
38
        return () => clearInterval(interval);
24✔
39
      }, [seconds,dispatch, setTwoFactorAuth, navigate]);
40

41
      useEffect(() => {
62✔
42
        if(successAuth){
32!
43
           toast.success("Success", {onClose: handleClick});
×
44
           return;
×
45
         }
46
         if(error){
32✔
47
           toast.error(error, {onClose: handleClick});
8✔
48
           return;
8✔
49
         }
50
       }, [successAuth, error]);
51
      
52
    return (
62✔
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