-
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.
Merge pull request #176 from cornell-dti/add-admin
Add admin
- Loading branch information
Showing
11 changed files
with
174 additions
and
80 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export interface Admin { | ||
name: string | ||
email: string | ||
} | ||
} |
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
71 changes: 71 additions & 0 deletions
71
frontend/src/modules/Settings/Components/AddAdminModal.tsx
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,71 @@ | ||
import { Typography, TextField, Button, Box } from '@mui/material' | ||
import { AddAdminProp } from './types' | ||
import { ZingModal } from '@core/index' | ||
import { FormEvent, useState } from 'react' | ||
|
||
const AddAdminModal = ({ open, handleClose, addAdmin }: AddAdminProp) => { | ||
const [newName, setNewName] = useState('') | ||
const [newEmail, setNewEmail] = useState('') | ||
const [requiredField, setRequiredField] = useState(false) | ||
|
||
return ( | ||
<ZingModal open={open} onClose={handleClose}> | ||
<Box | ||
component={'form'} | ||
onSubmit={(e: FormEvent) => { | ||
e.preventDefault() | ||
if (newEmail.includes('@') && newEmail.includes('.')) { | ||
addAdmin({ name: newName, email: newEmail }) | ||
handleClose() | ||
} else { | ||
setRequiredField(true) | ||
} | ||
}} | ||
> | ||
<ZingModal.Title onClose={handleClose}> | ||
<Typography variant="h4" sx={{ fontWeight: '500' }}> | ||
Add New Adminstrator | ||
</Typography> | ||
</ZingModal.Title> | ||
<ZingModal.Body> | ||
<Typography variant="h6" sx={{ fontWeight: '300', padding: 1 }}> | ||
Name: | ||
</Typography> | ||
<TextField | ||
required | ||
onChange={(e) => setNewName(e.target.value)} | ||
sx={{ | ||
width: '100%', | ||
borderRadius: '15px', | ||
}} | ||
/> | ||
<Typography variant="h6" sx={{ fontWeight: '300', padding: 1 }}> | ||
Email: | ||
</Typography> | ||
<TextField | ||
required | ||
onChange={(e) => { | ||
setNewEmail(e.target.value) | ||
setRequiredField(false) | ||
}} | ||
error={requiredField} | ||
sx={{ | ||
width: '100%', | ||
borderRadius: '15px', | ||
}} | ||
/> | ||
</ZingModal.Body> | ||
<ZingModal.Controls> | ||
<Button variant="outlined" color="secondary" onClick={handleClose}> | ||
Cancel | ||
</Button> | ||
<Button type="submit" variant="outlined" color="primary"> | ||
Confirm | ||
</Button> | ||
</ZingModal.Controls> | ||
</Box> | ||
</ZingModal> | ||
) | ||
} | ||
|
||
export default AddAdminModal |
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
Oops, something went wrong.