Skip to content

Commit ffc93d9

Browse files
authored
add admin badge to avatar (#880)
1 parent c86a9b6 commit ffc93d9

File tree

1 file changed

+48
-12
lines changed

1 file changed

+48
-12
lines changed

frontend/src/components/Layout.tsx

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ import ListItem from "@mui/material/ListItem";
1616
import ListItemButton from "@mui/material/ListItemButton";
1717
import ListItemIcon from "@mui/material/ListItemIcon";
1818
import ListItemText from "@mui/material/ListItemText";
19-
import { Link, Menu, MenuItem, MenuList, Typography } from "@mui/material";
19+
import {
20+
Badge,
21+
Link,
22+
Menu,
23+
MenuItem,
24+
MenuList,
25+
Typography,
26+
} from "@mui/material";
2027
import { Link as RouterLink, useLocation } from "react-router-dom";
2128
import { useDispatch, useSelector } from "react-redux";
2229
import { RootState } from "../types/data";
@@ -37,6 +44,7 @@ import {
3744
} from "../actions/user";
3845
import { AdminPanelSettings } from "@mui/icons-material";
3946
import ManageAccountsIcon from "@mui/icons-material/ManageAccounts";
47+
import AdminPanelSettingsIcon from "@mui/icons-material/AdminPanelSettings";
4048

4149
const drawerWidth = 240;
4250

@@ -202,18 +210,46 @@ export default function PersistentDrawerLeft(props) {
202210
color="inherit"
203211
>
204212
{getCurrEmail() !== undefined ? (
205-
<Gravatar
206-
email={getCurrEmail()}
207-
rating="g"
208-
style={{
209-
width: "32px",
210-
height: "32px",
211-
borderRadius: "50%",
212-
verticalAlign: "middle",
213-
}}
214-
/>
213+
<Badge
214+
overlap="circular"
215+
anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
216+
badgeContent={
217+
adminMode ? (
218+
<AdminPanelSettingsIcon
219+
sx={{ color: theme.palette.primary.main }}
220+
/>
221+
) : (
222+
<></>
223+
)
224+
}
225+
>
226+
<Gravatar
227+
email={getCurrEmail()}
228+
rating="g"
229+
style={{
230+
width: "32px",
231+
height: "32px",
232+
borderRadius: "50%",
233+
verticalAlign: "middle",
234+
}}
235+
/>
236+
</Badge>
215237
) : (
216-
<PersonIcon sx={{ verticalAlign: "middle" }} />
238+
<Badge
239+
overlap="circular"
240+
anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
241+
badgeContent={
242+
adminMode ? (
243+
<AdminPanelSettingsIcon
244+
sx={{ color: theme.palette.primary.main }}
245+
/>
246+
) : (
247+
<></>
248+
)
249+
}
250+
>
251+
<PersonIcon sx={{ verticalAlign: "middle" }} />
252+
</Badge>
217253
)}
218254
</IconButton>
219255
)}

0 commit comments

Comments
 (0)