Skip to content

Commit 2cea7fb

Browse files
UserUser
authored andcommitted
to commit login frontend changes
1 parent 4bc13ec commit 2cea7fb

File tree

1 file changed

+80
-6
lines changed

1 file changed

+80
-6
lines changed

app/components/Home.tsx

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,92 @@
1-
import React from 'react';
1+
import { faGlassMartiniAlt } from '@fortawesome/free-solid-svg-icons';
2+
// import axios from 'axios';
3+
import React, { useState } from 'react';
24
import { Link } from 'react-router-dom';
35

46
import '../stylesheets/Home.scss';
7+
//
8+
const { ipcRenderer } = window.require('electron');
9+
10+
interface PersonProps {
11+
email: string;
12+
password: string;
13+
}
14+
15+
type ClickEvent = React.MouseEvent<HTMLElement>;
16+
17+
// const [email] = React.useState<string>('');
18+
// const [password] = React.useState<string>('');
19+
// function handleChange(e) {
20+
21+
// }
22+
const adminUser = {
23+
24+
password: "admin123"
25+
}
526

627
const Home = React.memo(function Home(props) {
28+
const [open, setOpen] = useState<boolean>(false);
29+
const [loginInfo, setLoginInfo] = React.useState<PersonProps>({
30+
email: '',
31+
password: ''
32+
});
33+
34+
function myFunction() {
35+
location.replace("/applications")
36+
}
37+
function pageRedirect(){
38+
setTimeout(function(){
39+
window.location.href = '/applications';
40+
}, 5000);
41+
}
42+
43+
function submitLogin(e: any) {
44+
e.preventDefault();
45+
// console.log(e);
46+
console.log(loginInfo);
47+
//check local state if the username is there
48+
if(loginInfo.email === adminUser.email && loginInfo.password === adminUser.password){
49+
console.log("Logged In");
50+
myFunction();
51+
// alert('Welcome Back!\n\n (\\__/) \n (=\'.\'=) \n(\'\')__(\'\')')
52+
// // pageRedirect();
53+
// // "window.location='/applications'"
54+
} else {
55+
alert('Log In credentials are wrong!\n\n (\\__/) \n (=\'.\'=) \n(\'\')__(\'\')')
56+
}
57+
}
58+
//database connection/fetch
59+
function checkLoginStatus() {
60+
// axios('http://localhost:3000/loggedIn', {withCredentials: true})
61+
}
62+
63+
64+
765
return (
866
<div className="home">
9-
<p className="welcomeMessage">Your all-in-one application monitoring tool</p>
10-
<Link className="link" to="/applications">
67+
<p className="welcomeMessage">Welcome Back To Chronos! Your all-in-one application monitoring tool</p>
68+
69+
<form className="form" onSubmit={submitLogin}>
70+
<label className="login">
71+
<input type="email" name="email" id="email" placeholder="[email protected]" onChange={e => setLoginInfo({...loginInfo, email: e.target.value})} ></input>
72+
<br></br>
73+
<input type="password" name= "password" id="password" placeholder="enter password" onChange={e => setLoginInfo({...loginInfo, password:e.target.value})} ></input>
74+
<hr />
75+
</label>
76+
<br></br>
77+
<br></br>
78+
<br></br>
79+
<button className="link" id="submitBtn" type="submit" onClick={() => (true)}>
80+
Log In
81+
</button>
82+
</form>
83+
84+
<br></br>
85+
{/* <Link className="link" to="/applications">
1186
Get Started
12-
</Link>
87+
</Link> */}
1388
</div>
1489
);
1590
});
1691

17-
// test
18-
export default Home;
92+
export default Home;

0 commit comments

Comments
 (0)