Skip to content

Commit b7f642c

Browse files
committed
done
1 parent a760365 commit b7f642c

File tree

13 files changed

+163
-65
lines changed

13 files changed

+163
-65
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

client/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

client/package-lock.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"react-dom": "^18.2.0",
1212
"react-router-dom": "^6.8.0",
1313
"react-scripts": "5.0.1",
14+
"react-toastify": "^9.1.3",
1415
"web-vitals": "^2.1.4"
1516
},
1617
"scripts": {

client/src/App.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.App{
22
display: flex;
3-
width: 100vw;
3+
width: 100%;
44
height: 90vh;
55
justify-content: center;
66
align-items: center;

client/src/App.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,27 @@ import React from "react";
22
import Login from "./component/login"
33
import { BrowserRouter, Routes, Route } from 'react-router-dom'
44
import "./App.css"
5+
import { ToastContainer, toast } from 'react-toastify';
6+
import 'react-toastify/dist/ReactToastify.css';
7+
58
function App() {
69

7-
10+
811
return (
12+
<>
913
<div className="App">
1014
<BrowserRouter>
1115
<Routes>
16+
1217
<Route path='/' element={<Login/>} />
18+
1319
</Routes>
1420
</BrowserRouter>
15-
21+
22+
1623
</div>
24+
<ToastContainer/>
25+
</>
1726
)
1827
}
1928

client/src/component/login.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
border-radius: 8px;
77
align-items: center;
88
text-align: center;
9+
910
}
1011
.login > input{
1112
border-radius: 8px;
@@ -16,15 +17,17 @@
1617
padding: 0.5rem 0.75rem;
1718
width: 92%;
1819
font-size: 1rem;
20+
1921
}
2022
.login > .button{
21-
background-color: aquamarine;
22-
border: 1px solid aquamarine;
23+
background-color: rgb(120, 120, 192);
24+
border: 1px solid rgb(224, 230, 228);
2325
color: rgb(255, 250, 250);
2426
font-size: 1.25rem;
2527
padding: 0.5rem;
2628
margin: 0.5rem 0;
2729
border-radius: 8px;
2830
outline: none;
2931
cursor: pointer;
32+
margin:0px 12px 0px 12px;
3033
}

client/src/component/login.js

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,57 @@
1-
import React, { useState } from 'react'
2-
import "./login.css"
1+
import React, { useState } from 'react';
2+
import "./login.css";
33
import axios from "axios";
4+
import { ToastContainer, toast } from 'react-toastify';
5+
import 'react-toastify/dist/ReactToastify.css';
6+
47
function Login() {
5-
const [email, setEmail] = useState("");
6-
const [message, setMessage] = useState("");
7-
const [otp,setOtp]=useState("");
8-
const handleSubmit = async (e) => {
9-
e.preventDefault();
10-
try {
11-
const res = await axios.post("http://localhost:8000/signup", { email });
12-
setMessage(res.data.message);
13-
14-
} catch (error) {
15-
setMessage("Error sending verification email");
16-
}
17-
}
18-
const verify=()=>{
19-
if(otp===message){
20-
alert("verified")
21-
}else{
22-
alert("wrong OTP")
23-
}
8+
const [email, setEmail] = useState("");
9+
const [message, setMessage] = useState("");
10+
const [otp, setOtp] = useState("");
11+
12+
const handleSubmit = async (e) => {
13+
e.preventDefault();
14+
try {
15+
const res = await axios.post("http://localhost:8000/signup", { email });
16+
toast.success('Otp send successfully!', { autoClose: 5000 });
17+
setMessage(res.data.message);
18+
} catch (error) {
19+
toast.error('Otp sending failed!', { autoClose: 5000 });
20+
setMessage("Error sending verification email");
21+
}
22+
}
23+
24+
const verify = () => {
25+
if (otp === message) {
26+
toast.success('Verification successful!', { autoClose: 5000 });
27+
} else {
28+
toast.error('Invalid OTP. Verification failed.', { autoClose: 5000 });
2429
}
30+
}
31+
2532
return (
26-
<div className='login'>
27-
<input
28-
type="email"
29-
placeholder="Enter Your Email Id"
30-
value={email}
31-
onChange={(e) => setEmail(e.target.value)}
32-
/>
33-
<input
34-
type="text"
35-
placeholder="Enter Your OTP"
36-
value={otp}
37-
onChange={(e) => setOtp(e.target.value)}
38-
/>
39-
<button onClick={handleSubmit} className='button'>send otp</button>
40-
<button onClick={verify} className='button'>verify</button>
41-
<div>{message}</div>
42-
43-
</div>
33+
<>
34+
<ToastContainer />
35+
<div className='login'>
36+
37+
<input
38+
type="email"
39+
placeholder="Enter Your Email Id"
40+
value={email}
41+
onChange={(e) => setEmail(e.target.value)}
42+
/>
43+
<input
44+
type="text"
45+
placeholder="Enter Your OTP"
46+
value={otp}
47+
onChange={(e) => setOtp(e.target.value)}
48+
/>
49+
50+
<button onClick={handleSubmit} className='button'>Send OTP</button>
51+
<button onClick={verify} className='button'>Verify</button>
52+
</div>
53+
</>
4454
)
4555
}
4656

47-
export default Login
57+
export default Login;

client/src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom/client';
33
import App from './App'
4+
5+
6+
47
const root = ReactDOM.createRoot(document.getElementById('root'));
58
root.render(
6-
9+
710
<App />
8-
11+
912
);
1013

1114

server/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.env

0 commit comments

Comments
 (0)