Files
advanced_db/db_app/src/components/CreateAccount.js

159 lines
3.9 KiB
JavaScript
Raw Normal View History

2023-04-27 14:30:17 -04:00
import React,{useState} from 'react';
import {Routes, Route, useNavigate} from 'react-router-dom';
import Axios from 'axios';
2023-04-29 16:24:23 -04:00
import './CreateAccount.css';
import Button from "@mui/material/Button";
import Card from "@mui/material/Card";
import TextField from "@mui/material/TextField";
import FormControlLabel from "@mui/material/FormControlLabel";
import Checkbox from "@mui/material/Checkbox";
import Link from "@mui/material/Link";
import Grid from "@mui/material/Grid";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import Container from "@mui/material/Container";
2023-04-29 16:24:23 -04:00
import {red, green, lightBlue, lightGreen} from '@mui/material/colors';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import image from "./images/main_background.jpg"
const theme = createTheme({
palette: {
primary: {
main: lightGreen[700],
},
},
});
2023-04-27 14:30:17 -04:00
function CreateAccount() {
2023-04-27 14:40:49 -04:00
const navigate = useNavigate();
const navigateLogin = () => {
navigate('/');
}
const [data,setData] = useState({
net_id:"",
2023-04-27 14:40:49 -04:00
password:"",
first_name:"",
last_name:"",
2023-04-27 14:40:49 -04:00
})
const {net_id, password, first_name, last_name} = data;
2023-04-27 14:40:49 -04:00
const changeHandler = e => {
setData({...data,[e.target.name]:[e.target.value]});
}
const submitHandler = e => {
e.preventDefault();
console.log(data);
console.log(net_id[0])
console.log(password[0])
console.log(first_name[0])
console.log(last_name[0])
createAccount();
2023-04-27 14:40:49 -04:00
}
2023-04-27 14:30:17 -04:00
const createAccount = () => {
Axios.post("http://3.219.93.142:8000/api/signup", {net_id: net_id[0], password: password[0], first_name: first_name[0], last_name: last_name[0]}).then((response) => {
console.log(response);
});
};
2023-04-27 14:30:17 -04:00
return (
2023-04-29 16:24:23 -04:00
<ThemeProvider theme={theme}>
<div className='bg' style={{backgroundImage: 'url(' + require('./images/main_background.jpg') + ')'}}>
<div className='logbox'>
<Box
sx={{
marginTop: 8,
display: "flex",
flexDirection: "column",
alignItems: "center",
}}
>
<Typography component="h1" variant="h5">Create Account</Typography>
2023-04-29 16:24:23 -04:00
<form className='formbox' onSubmit={submitHandler}>
<TextField
margin="normal"
required
fullWidth
id="net_id"
label="net_id"
name="net_id"
autoComplete="net_id"
autoFocus
value={net_id}
onChange={changeHandler}
/>
<TextField
margin="normal"
required
fullWidth
id="password"
label="Password"
name="password"
autoComplete="password"
autoFocus
value={password}
onChange={changeHandler}
/>
<TextField
margin="normal"
required
fullWidth
id="first_name"
label="First name"
name="first_name"
autoComplete="first_name"
autoFocus
value={first_name}
onChange={changeHandler}
/>
<TextField
margin="normal"
required
fullWidth
id="last_name"
label="Last name"
name="last_name"
autoComplete="last_name"
autoFocus
value={last_name}
onChange={changeHandler}
/>
<Button
type="submit"
fullWidth
variant="contained"
sx={{ mt: 3, mb: 2 }}
>
Submit</Button>
2023-04-27 14:40:49 -04:00
</form>
<Button
onClick={navigateLogin}
fullWidth
variant="contained"
sx={{ mt: 3, mb: 2, width:1/4 }}
>Back to Login</Button>
2023-04-27 14:30:17 -04:00
</Box>
2023-04-27 14:30:17 -04:00
</div>
2023-04-29 16:24:23 -04:00
</div>
</ThemeProvider>
2023-04-27 14:30:17 -04:00
);
}
export default CreateAccount;