generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'FrontEnd-Integration' into 32-question-view-logic
- Loading branch information
Showing
16 changed files
with
1,174 additions
and
154 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"dependencies": { | ||
"asciidoctor-emoji": "^0.5.0" | ||
"@material-ui/core": "^4.12.4", | ||
"@material-ui/icons": "^4.11.3", | ||
"asciidoctor-emoji": "^0.5.0", | ||
"react-router-dom": "^6.22.1" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,93 @@ | ||
// src/components/AddUser.js | ||
import React, { useState } from 'react'; | ||
import axios from 'axios'; | ||
import { Container, Typography, TextField, Button, Snackbar } from '@mui/material'; | ||
|
||
const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; | ||
import React, { useState } from "react"; | ||
import { FaUser, FaLock } from "react-icons/fa"; | ||
import "./Login.css"; | ||
import { Link } from "react-router-dom"; | ||
|
||
const AddUser = () => { | ||
const [username, setUsername] = useState(''); | ||
const [password, setPassword] = useState(''); | ||
const [error, setError] = useState(''); | ||
const [openSnackbar, setOpenSnackbar] = useState(false); | ||
|
||
const addUser = async () => { | ||
try { | ||
await axios.post(`${apiEndpoint}/adduser`, { username, password }); | ||
setOpenSnackbar(true); | ||
} catch (error) { | ||
setError(error.response.data.error); | ||
} | ||
}; | ||
|
||
const handleCloseSnackbar = () => { | ||
setOpenSnackbar(false); | ||
}; | ||
|
||
return ( | ||
<Container component="main" maxWidth="xs" sx={{ marginTop: 4 }}> | ||
<Typography component="h1" variant="h5"> | ||
Add User | ||
</Typography> | ||
<TextField | ||
name="username" | ||
margin="normal" | ||
fullWidth | ||
label="Username" | ||
value={username} | ||
onChange={(e) => setUsername(e.target.value)} | ||
/> | ||
<TextField | ||
name="password" | ||
margin="normal" | ||
fullWidth | ||
label="Password" | ||
type="password" | ||
value={password} | ||
onChange={(e) => setPassword(e.target.value)} | ||
/> | ||
<Button variant="contained" color="primary" onClick={addUser}> | ||
Add User | ||
</Button> | ||
<Snackbar open={openSnackbar} autoHideDuration={6000} onClose={handleCloseSnackbar} message="User added successfully" /> | ||
{error && ( | ||
<Snackbar open={!!error} autoHideDuration={6000} onClose={() => setError('')} message={`Error: ${error}`} /> | ||
)} | ||
</Container> | ||
<div className="wrapper"> | ||
<form action=""> | ||
<div className="wrapper2"> | ||
<h1> Register </h1> | ||
<div className="input-box"> | ||
<input type="text" placeholder="Username" required /> | ||
<FaUser className="icon" /> | ||
</div> | ||
<div className="input-box"> | ||
<input type="password" placeholder="Password" required /> | ||
<FaLock className="icon" /> | ||
</div> | ||
<div className="input-box"> | ||
<input type="password" placeholder="Repeat password" required /> | ||
<FaLock className="icon" /> | ||
</div> | ||
|
||
<button type="submit">Register</button> | ||
|
||
<LinkLogin /> | ||
</div> | ||
</form> | ||
</div> | ||
); | ||
}; | ||
|
||
function LinkLogin() { | ||
return ( | ||
<Link to="/login" className="button-login" variant="body2" > | ||
Do you have an account? Login here. | ||
</Link> | ||
); | ||
} | ||
// const [username, setUsername] = useState(''); | ||
// const [password, setPassword] = useState(''); | ||
// const [error, setError] = useState(''); | ||
// const [openSnackbar, setOpenSnackbar] = useState(false); | ||
|
||
// const addUser = async () => { | ||
// try { | ||
// await axios.post(`${apiEndpoint}/adduser`, { username, password }); | ||
// setOpenSnackbar(true); | ||
// } catch (error) { | ||
// setError(error.response.data.error); | ||
// } | ||
// }; | ||
|
||
// const handleCloseSnackbar = () => { | ||
// setOpenSnackbar(false); | ||
// }; | ||
|
||
// return ( | ||
// <Container component="main" maxWidth="xs" sx={{ marginTop: 4 }}> | ||
// <Typography component="h1" variant="h5"> | ||
// Add User | ||
// </Typography> | ||
// <TextField | ||
// name="username" | ||
// margin="normal" | ||
// fullWidth | ||
// label="Username" | ||
// value={username} | ||
// onChange={(e) => setUsername(e.target.value)} | ||
// /> | ||
// <TextField | ||
// name="password" | ||
// margin="normal" | ||
// fullWidth | ||
// label="Password" | ||
// type="password" | ||
// value={password} | ||
// onChange={(e) => setPassword(e.target.value)} | ||
// /> | ||
// <Button variant="contained" color="primary" onClick={addUser}> | ||
// Add User | ||
// </Button> | ||
// <Snackbar open={openSnackbar} autoHideDuration={6000} onClose={handleCloseSnackbar} message="User added successfully" /> | ||
// {error && ( | ||
// <Snackbar open={!!error} autoHideDuration={6000} onClose={() => setError('')} message={`Error: ${error}`} /> | ||
// )} | ||
// </Container> | ||
// ); | ||
// }; | ||
|
||
export default AddUser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
} | ||
|
||
.wrapper button{ | ||
width: 100%; | ||
height: 45px; | ||
background: darkblue; | ||
border: none; | ||
outline: none; | ||
border-radius: 40px; | ||
box-shadow: 0 0 10px black; | ||
cursor:pointer; | ||
font-size: 16px; | ||
color: white; | ||
font-weight: 700; | ||
} | ||
|
||
.wrapper link{ | ||
font-size: 14.5px; | ||
text-align: center; | ||
margin: 20px 0 15px; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.