diff --git a/client/src/pages/landing/loginPage.jsx b/client/src/pages/landing/loginPage.jsx index ccd1d32..3a0ac08 100644 --- a/client/src/pages/landing/loginPage.jsx +++ b/client/src/pages/landing/loginPage.jsx @@ -4,17 +4,20 @@ import StyledButton from "../../components/CustomButton/StyledButton"; import axios from "../../utils/axiosInstance"; import { CustomTextField } from "../../globals/global.styles"; +import { useNavigate } from "react-router-dom"; const LoginPage = ({ setMode }) => { const [role, setRole] = useState(""); const [email,setEmail] = useState(); + const navigate = useNavigate() const handleLogin = async()=>{ const data = { email } const response = await axios.post('/auth/login',data); - console.log(response) + localStorage.setItem("Token", response?.data?.data._id); + navigate(`/verify/${response?.data?.data._id}`); } return ( diff --git a/client/src/pages/landing/signupPage.jsx b/client/src/pages/landing/signupPage.jsx index efc42bc..a230fd8 100644 --- a/client/src/pages/landing/signupPage.jsx +++ b/client/src/pages/landing/signupPage.jsx @@ -2,7 +2,7 @@ import { TextField, styled } from "@mui/material"; import React, { useState } from "react"; import StyledButton from "../../components/CustomButton/StyledButton"; import axios from "../../utils/axiosInstance"; - +import { useNavigate } from "react-router-dom"; const CustomTextField = styled(TextField)(() => ({ "& label.Mui-focused": { color: "rgba(255, 255, 255, 0.685)", @@ -29,6 +29,7 @@ const CustomTextField = styled(TextField)(() => ({ const SignupPage = ({ setMode }) => { const [role, setRole] = useState(null); const [data,setData] = useState() + const navigate = useNavigate() const handleChange = (e) => { setData({ @@ -42,6 +43,8 @@ const SignupPage = ({ setMode }) => { console.log(data); const response = await axios.post('/auth/signup',data); console.log(response); + localStorage.setItem("Token", response?.data?.data._id); + navigate(`/verify/${response?.data?.data._id}`); } return ( diff --git a/client/src/pages/landing/verify.component.jsx b/client/src/pages/landing/verify.component.jsx index 58b04fa..44596fe 100644 --- a/client/src/pages/landing/verify.component.jsx +++ b/client/src/pages/landing/verify.component.jsx @@ -10,9 +10,11 @@ import { CustomTextField } from "../../globals/global.styles"; import { Box, styled } from "@mui/material"; // import CustomButton from "../../components/CustomButton/CustomButton.component"; import StyledButton from "../../components/CustomButton/StyledButton"; +import axios from "../../utils/axiosInstance"; // import LandingPage from "./landingPage"; // import SignupPage from "./signupPage"; // import LoginPage from "./loginPage"; +import { useNavigate, useParams } from "react-router-dom"; const Glass = styled(Box)(() => ({ width: "100vw", @@ -25,6 +27,18 @@ const Glass = styled(Box)(() => ({ const Landing = () => { const [mode, setMode] = useState("landing"); + const [otp,setOTP] = useState(); + let { id } = useParams(); + const navigate = useNavigate(); + + const handleVerify = async()=>{ + const data = { + otp + } + const response = await axios.post(`/auth/validateOTP/${id}`,data) + console.log(response); + navigate('/reader/home') + } // let content; @@ -131,9 +145,9 @@ const Landing = () => {

Please enter the OTP sent to your email to verify yourself!

- + setOTP(e.target.value)} label="Enter OTP" name="otp" fullWidth /> - VERIFY + handleVerify()}>VERIFY {/*
New to debinder?{" "}