-
Notifications
You must be signed in to change notification settings - Fork 7
/
OTP.jsx
49 lines (44 loc) · 1.28 KB
/
OTP.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React, { useState, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import Axios from "axios";
import { Api } from "../backend";
import otpImg from "../Assets/otp.svg";
import Otpforum from "./Components/Otpforum";
import "./styles/SigninSignup.css";
const Mainform = () => {
return (
<>
<div className="user-login otpVerify-page">
<div className="user-img">
<img alt="" src={otpImg}></img>
</div>
<Otpforum />
</div>
</>
);
};
const Otpverify = () => {
const [auth, setAuth] = useState(true);
let navigate = useNavigate();
async function fetchdata() {
const authToken = localStorage.getItem("token");
if (!authToken) window.location = "/";
const parseddata = await Axios.get(`${Api}verify`, {
withCredentials: true,
headers: { Authorization: `Bearer ${authToken}` },
});
if (!parseddata.data.token) {
window.location = "/";
}
// console.log('Api is :- ', Api)
// console.log(parseddata)
// setAuth(!parseddata.data.success);
// console.log('Useeffet :- ', parseddata)
}
useEffect(() => {
// document.querySelector("nav").remove();
fetchdata();
}, []);
return <>{auth ? <Mainform /> : `OTP not found`}</>;
};
export default Otpverify;