forked from UBC-CIC/basics-for-health
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,177 additions
and
207 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
This file was deleted.
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useState } from 'react'; | ||
import { Drawer, List, ListItemText, Box, IconButton, ListItem } from '@mui/material' | ||
import { Menu } from '@material-ui/icons'; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
export default function Sidebar() { | ||
const [isOpen, setIsOpen] = useState(false); | ||
let navigate = useNavigate(); | ||
|
||
return ( | ||
<> | ||
<IconButton color="inherit" sx={{ mr: 2 }} onClick={() => setIsOpen(true)}> | ||
<Menu /> | ||
</IconButton> | ||
<Drawer open={isOpen} anchor="left" onClose={() => setIsOpen(false)}> | ||
<Box width='15rem' role='presentation' onClick={() => setIsOpen(false)}> | ||
<List disablePadding> | ||
<ListItem button onClick={() => navigate('/upload')}> | ||
<ListItemText primary="Upload a form" /> | ||
</ListItem> | ||
<ListItem button onClick={() => navigate('/')}> | ||
<ListItemText primary="Fill out a form" /> | ||
</ListItem> | ||
<ListItem button onClick={() => navigate('/admin')}> | ||
<ListItemText primary="Add an admin user" /> | ||
</ListItem> | ||
</List> | ||
</Box> | ||
</Drawer> | ||
</> | ||
) | ||
} |
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,27 @@ | ||
import { toast, Zoom} from 'react-toastify'; | ||
|
||
export function Notify(type, text) { | ||
if (type === 'success') { | ||
toast.success(text, { | ||
position: "top-center", | ||
autoClose: 3000, | ||
transition: Zoom, | ||
hideProgressBar: true, | ||
closeOnClick: true, | ||
pauseOnHover: true, | ||
draggable: false, | ||
progress: undefined, | ||
}); | ||
} else { | ||
toast.error(text, { | ||
position: "top-center", | ||
autoClose: 3000, | ||
transition: Zoom, | ||
hideProgressBar: true, | ||
closeOnClick: true, | ||
pauseOnHover: true, | ||
draggable: false, | ||
progress: undefined, | ||
}); | ||
} | ||
} |
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,63 @@ | ||
import { Box, TextField, Stack, FormControlLabel, Checkbox, Button } from '@mui/material' | ||
import { useState } from 'react' | ||
|
||
function Admin() { | ||
const [text, setText] = useState(''); | ||
const [errorText, setErrorText] = useState(''); | ||
const [checked, setChecked] = useState(false); | ||
|
||
function isValidEmail(email) { | ||
let re = /\S+@\S+\.\S+/; | ||
return !(re.test(email)); | ||
} | ||
|
||
function handleSubmit(e) { | ||
e.preventDefault(); | ||
if (text === '') { | ||
setErrorText("Please enter email"); | ||
} else if(isValidEmail(text)) { | ||
setErrorText('Please enter a valid email') | ||
} else { | ||
setErrorText(''); | ||
if (checked) { | ||
console.log('done') | ||
} | ||
} | ||
}; | ||
|
||
const checkChanged = () => { | ||
setChecked(!checked); | ||
}; | ||
|
||
return ( | ||
<Box | ||
component='form' | ||
onSubmit={handleSubmit} | ||
sx={{ | ||
display: 'flex', | ||
marginTop: '3em', | ||
justifyContent: 'center' | ||
}}> | ||
<Stack spacing={2}> | ||
<h2>Authorize administrative privilages for another user</h2> | ||
<TextField | ||
value={text} | ||
label="Email" | ||
onChange={(e) => {setText(e.target.value)}} | ||
error={isValidEmail(text)} | ||
helperText={errorText} | ||
variant="standard" | ||
/> | ||
<FormControlLabel | ||
control={<Checkbox checked={checked} onChange={checkChanged}/>} | ||
label="I want this user to be an administrator" | ||
/> | ||
<Box display="flex" justifyContent='flex-end'> | ||
<Button type='submit' style={{width: 'fit-content'}}>Submit</Button> | ||
</Box> | ||
</Stack> | ||
</Box> | ||
) | ||
} | ||
|
||
export default Admin; |
Oops, something went wrong.