Skip to content

Commit

Permalink
Merge pull request #252 from cmu15122/jtromero/preferredNameFixes
Browse files Browse the repository at this point in the history
Preferred Name Fixes
  • Loading branch information
jacksontromero authored Jan 10, 2024
2 parents 35cb11a + c1bd90f commit b39f1d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
16 changes: 11 additions & 5 deletions client/src/components/navbar/ChangeNameBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, {useState} from 'react';
import {
Button, Dialog, DialogActions, DialogTitle, DialogContent, DialogContentText, TextField,
Button, Dialog, DialogActions, DialogTitle, DialogContent, DialogContentText, TextField, Typography, MenuItem,
} from '@mui/material';
import EditIcon from '@mui/icons-material/Edit';

import SettingsService from '../../services/SettingsService';

export default function ChangeNameBtn(props) {
const {setpname, pname} = props;
const {setpname, pname, mobile} = props;

const [tmpPrefName, setTmpPrefName] = useState(pname);
const [open, setOpen] = useState(false);
Expand All @@ -28,9 +28,15 @@ export default function ChangeNameBtn(props) {

return (
<div>
<Button variant="text" onClick={handleClickOpen} sx={{color: '#FFFFFF'}}>
<EditIcon/>
</Button>
{
mobile ?
<MenuItem onClick={handleClickOpen}>
<Typography variant='subtitle2' sx={{mx: 2}}> Change Name </Typography>
</MenuItem> :
<Button variant="text" onClick={handleClickOpen} sx={{color: '#FFFFFF'}}>
<EditIcon/>
</Button>
}
<Dialog open={open} onClose={handleClose}>
<form onSubmit={handleSubmit}>
<DialogTitle>Change Name</DialogTitle>
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ export default function Navbar(props) {
</MenuItem>
))
}
{
userData.isAuthenticated && <ChangeNameBtn mobile={true} pname={pname} setpname={setpname}/>
}
{
userData.isAuthenticated &&
<MenuItem onClick={handleLogoutClicked}>
Expand Down Expand Up @@ -199,7 +202,7 @@ export default function Navbar(props) {
</Box>
<Box sx={{flexGrow: 0, display: 'flex'}}>
{
userData.isAuthenticated && <ChangeNameBtn pname={pname} setpname={setpname}/>
userData.isAuthenticated && <ChangeNameBtn mobile={false} pname={pname} setpname={setpname}/>
}
</Box>

Expand Down
2 changes: 1 addition & 1 deletion server/controllers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function respond(req, res, message, data, status) {
}

function respond_success(req, res, message = null) {
if (!req.user || !req.user.isTA) {
if (!req.user) {
respond_error(req, res, "You don't have permissions to view this page", 404);
return;
}
Expand Down

0 comments on commit b39f1d0

Please sign in to comment.