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' ;
2
4
import { Link } from 'react-router-dom' ;
3
5
4
6
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
+ }
5
26
6
27
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
+
7
65
return (
8
66
< 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">
11
86
Get Started
12
- </ Link >
87
+ </Link> */ }
13
88
</ div >
14
89
) ;
15
90
} ) ;
16
91
17
- // test
18
- export default Home ;
92
+ export default Home ;
0 commit comments