-
Notifications
You must be signed in to change notification settings - Fork 3
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 #17 from utmgdsc/darkmode
- Loading branch information
Showing
7 changed files
with
224 additions
and
213 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,24 @@ | ||
import React, {useEffect} from "react"; | ||
import { | ||
Typography, | ||
Box, | ||
Button, | ||
Card, | ||
CardContent, | ||
CardActions, | ||
Box, | ||
Tooltip, | ||
CardContent, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogContentText, | ||
DialogTitle, | ||
useMediaQuery, | ||
useTheme, | ||
TextField, | ||
Typography, | ||
useMediaQuery, | ||
useTheme | ||
} from "@mui/material"; | ||
import { SubPage } from "../../layouts/SubPage"; | ||
import React, { useContext, useEffect } from "react"; | ||
import { useNavigate, useParams } from 'react-router-dom'; | ||
import { InitialsAvatar } from "../../components"; | ||
import { Routes, Route, useParams, useNavigate } from 'react-router-dom'; | ||
|
||
// let people = [ | ||
// { | ||
// name: "Hatsune Miku", | ||
// email: "[email protected]", | ||
// utorid: "hatsunem", | ||
// admin: true, | ||
// }, | ||
// { | ||
// name: "Kagamine Rin", | ||
// email: "[email protected]", | ||
// utorid: "kagaminr", | ||
// admin: false, | ||
// }, | ||
// { | ||
// name: "Kagamine Len", | ||
// email: "[email protected]", | ||
// utorid: "kagaminl", | ||
// admin: false, | ||
// } | ||
// ] | ||
// const group = { | ||
// people: people, | ||
// name: "Google Developers Student Club", | ||
// faculty_representative: { | ||
// name: "Yowane Haku", | ||
// email: "[email protected]", | ||
// utorid: "yowanh" | ||
// } | ||
// } | ||
import { UserContext } from "../../contexts/UserContext"; | ||
import { SubPage } from "../../layouts/SubPage"; | ||
|
||
export const Group = () => { | ||
const [open, setOpen] = React.useState(false); | ||
|
@@ -60,6 +30,7 @@ export const Group = () => { | |
const [group, setGroup] = React.useState({}); | ||
const [inviteUtorid, setInviteUtorid] = React.useState(''); | ||
const navigate = useNavigate(); | ||
const userInfo = useContext(UserContext); | ||
|
||
const getGroups = () => { | ||
fetch(process.env.REACT_APP_API_URL + '/groups/search/byID/' + groupID, { | ||
|
@@ -201,7 +172,7 @@ export const Group = () => { | |
}} | ||
> | ||
<Button onClick={handleClose}>Cancel</Button> | ||
<Button onClick={() => {handleClose(); addPerson(inviteUtorid); setInviteUtorid('')}} variant="contained">Add</Button> | ||
<Button onClick={() => { handleClose(); addPerson(inviteUtorid); setInviteUtorid('') }} variant="contained">Add</Button> | ||
</DialogActions> | ||
</Dialog> | ||
</Box> | ||
|
@@ -221,34 +192,39 @@ export const Group = () => { | |
<InitialsAvatar name={person.name} /> | ||
</Box> | ||
<Box> | ||
<Typography variant="h5">{person.name} <Typography sx={{color: "grey", display: "inline"}}>({person.utorid})</Typography></Typography> | ||
<Typography variant="h5">{person.name} <Typography sx={{ color: "grey", display: "inline" }}>({person.utorid})</Typography></Typography> | ||
{person.admin ? <Typography color="success">Group manager</Typography> : null} | ||
<Typography variant="body1">{person.email}</Typography> | ||
</Box> | ||
</CardContent> | ||
<CardActions> | ||
{ | ||
person.admin ? null : ( | ||
<Button | ||
onClick={() => { | ||
makeAdmin(person.utorid); | ||
}} | ||
> | ||
Make Admin | ||
</Button> | ||
) | ||
} | ||
|
||
<Button | ||
color="error" | ||
onClick={() => { | ||
removePerson(person.utorid); | ||
}} | ||
> | ||
Remove Student | ||
</Button> | ||
|
||
</CardActions> | ||
{person.admin && userInfo.utorid === person.utorid ? null : ( | ||
|
||
<CardActions> | ||
{ | ||
person.admin ? null : ( | ||
<Button | ||
onClick={() => { | ||
makeAdmin(person.utorid); | ||
}} | ||
> | ||
Make Admin | ||
</Button> | ||
) | ||
} | ||
|
||
<Button | ||
color="error" | ||
onClick={() => { | ||
removePerson(person.utorid); | ||
if (userInfo.utorid === person.utorid) { | ||
navigate('/group', { replace: true }); | ||
} | ||
}} | ||
> | ||
Remove Student | ||
</Button> | ||
</CardActions> | ||
)} | ||
</Card> | ||
)) | ||
} | ||
|
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.