2023-04-29 12:01:45 -04:00
|
|
|
import React,{useState, useEffect} from 'react';
|
2023-04-27 14:30:17 -04:00
|
|
|
import {Routes, Route, useNavigate} from 'react-router-dom';
|
2023-04-29 12:01:45 -04:00
|
|
|
import Axios from 'axios';
|
2023-04-27 14:30:17 -04:00
|
|
|
import './Login.css';
|
|
|
|
|
|
2023-04-29 12:01:45 -04:00
|
|
|
|
2023-04-27 14:30:17 -04:00
|
|
|
function Login() {
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
|
|
|
|
const navigateCreateAccount = () => {
|
|
|
|
|
navigate('/CreateAccount');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const [data,setData] = useState({
|
|
|
|
|
username:"",
|
|
|
|
|
password:""
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const {username,password} = data;
|
|
|
|
|
|
|
|
|
|
const changeHandler = e => {
|
|
|
|
|
setData({...data,[e.target.name]:[e.target.value]});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const submitHandler = e => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
console.log(data);
|
2023-04-29 12:01:45 -04:00
|
|
|
login();
|
2023-04-27 14:30:17 -04:00
|
|
|
}
|
2023-04-29 12:01:45 -04:00
|
|
|
|
2023-04-27 14:30:17 -04:00
|
|
|
|
2023-04-29 12:01:45 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
const getHello = () => {
|
|
|
|
|
Axios.get("http://3.219.93.142:8000/").then((response) => {
|
|
|
|
|
console.log(response.data);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const login = () => {
|
|
|
|
|
Axios.post("http://3.219.93.142:8000/api/", {net_id: username, password: password,}).then((response) => {
|
|
|
|
|
console.log(response.data);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
2023-04-27 14:30:17 -04:00
|
|
|
<div>
|
|
|
|
|
<center>
|
|
|
|
|
<h1>Log In</h1>
|
2023-04-29 12:01:45 -04:00
|
|
|
<button onClick={getHello}>Test</button>
|
2023-04-27 14:30:17 -04:00
|
|
|
<p>Log in to your account</p>
|
|
|
|
|
<form onSubmit={submitHandler}>
|
2023-04-27 14:40:49 -04:00
|
|
|
<p>Username:</p>
|
|
|
|
|
<input type="text" name="username" value={username} onChange={changeHandler}/>
|
|
|
|
|
<p>Password:</p>
|
2023-04-27 14:30:17 -04:00
|
|
|
<input type="password" name="password" value={password} onChange={changeHandler}/><br/>
|
|
|
|
|
<input type="submit" name="submit"/>
|
|
|
|
|
</form>
|
|
|
|
|
<button onClick={navigateCreateAccount}>Create New Account</button>
|
|
|
|
|
</center>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Login;
|