Fixing MaterialUI stuff
This commit is contained in:
parent
578d38f187
commit
4998f3a2d5
|
@ -17,13 +17,15 @@ import {
|
||||||
Alert,
|
Alert,
|
||||||
Container,
|
Container,
|
||||||
Box,
|
Box,
|
||||||
TextField
|
TextField,
|
||||||
|
Tab
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
|
|
||||||
|
|
||||||
export default function Admin() {
|
export default function Admin() {
|
||||||
const [users, setUsers] = useState([]);
|
const [users, setUsers] = useState([]);
|
||||||
const [username, setUsername] = useState('');
|
const [username, setUsername] = useState('');
|
||||||
|
const [email, setEmail] = useState('');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const fileInputRef = useRef(null);
|
const fileInputRef = useRef(null);
|
||||||
|
@ -59,13 +61,15 @@ export default function Admin() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(`${process.env.REACT_APP_API_URL}/admin/user`, {
|
const response = await axios.post(`${process.env.REACT_APP_API_URL}/admin/user`, {
|
||||||
username,
|
username,
|
||||||
password
|
password,
|
||||||
|
email
|
||||||
}, {
|
}, {
|
||||||
headers: { Authorization: `Bearer ${localStorage.getItem('token')}` }
|
headers: { Authorization: `Bearer ${localStorage.getItem('token')}` }
|
||||||
});
|
});
|
||||||
setUsers([...users, response.data]);
|
setUsers([...users, response.data]);
|
||||||
setUsername('');
|
setUsername('');
|
||||||
setPassword('');
|
setPassword('');
|
||||||
|
setEmail('');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
@ -158,6 +162,13 @@ export default function Admin() {
|
||||||
onChange={(e) => setPassword(e.target.value)}
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
sx={{ mr: 2 }}
|
sx={{ mr: 2 }}
|
||||||
/>
|
/>
|
||||||
|
<TextField
|
||||||
|
label="Email"
|
||||||
|
variant="outlined"
|
||||||
|
value={email}
|
||||||
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
|
sx={{ mr: 2 }}
|
||||||
|
/>
|
||||||
<Button type="submit" sx={{ backgroundColor: PRIMARY_COLOR, borderBottom: '1px solid', borderColor: '#444', color: SECONDARY_COLOR }} variant="contained" color="primary">
|
<Button type="submit" sx={{ backgroundColor: PRIMARY_COLOR, borderBottom: '1px solid', borderColor: '#444', color: SECONDARY_COLOR }} variant="contained" color="primary">
|
||||||
Add User
|
Add User
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -167,14 +178,18 @@ export default function Admin() {
|
||||||
<Table>
|
<Table>
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
<TableCell>ID</TableCell>
|
||||||
<TableCell>Username</TableCell>
|
<TableCell>Username</TableCell>
|
||||||
|
<TableCell>Email</TableCell>
|
||||||
<TableCell>Actions</TableCell>
|
<TableCell>Actions</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{users.map(user => (
|
{users.map(user => (
|
||||||
<TableRow key={user.ID}>
|
<TableRow key={user.ID}>
|
||||||
<TableCell>{user.username}</TableCell>
|
<TableCell style={{ width: '30px' }}>{user.ID}</TableCell>
|
||||||
|
<TableCell style={{ width: '100px'}}>{user.username}</TableCell>
|
||||||
|
<TableCell style={{ width: '300px'}}>{user.email}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
|
Loading…
Reference in New Issue