added functions to close menu and reload element after user role change
This commit is contained in:
parent
2dc8a97af0
commit
0d6d496291
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "candymat",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{}
|
|
@ -28,9 +28,9 @@ const useStyles = makeStyles((theme) => ({
|
|||
}));
|
||||
|
||||
export default function CategoryList(): React.ReactElement {
|
||||
const categories =
|
||||
useQuery<GetAllCategoriesResponse, null>(GET_ALL_CATEGORIES).data
|
||||
?.allCategories.nodes;
|
||||
const categories = useQuery<GetAllCategoriesResponse, null>(
|
||||
GET_ALL_CATEGORIES
|
||||
).data?.allCategories.nodes;
|
||||
const classes = useStyles();
|
||||
|
||||
const handleAddClick = () => {
|
||||
|
|
|
@ -4,6 +4,7 @@ import Menu from "@material-ui/core/Menu";
|
|||
import EditIcon from "@material-ui/icons/Edit";
|
||||
import { UppercaseUserRole, UPPERCASE_USER_ROLES } from "../jwt/jwt";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import {
|
||||
ChangeRoleResponse,
|
||||
ChangeRoleVariables,
|
||||
|
@ -18,7 +19,7 @@ interface ChangeRoleProps {
|
|||
export default function ChangeRole(props: ChangeRoleProps): React.ReactElement {
|
||||
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
||||
const open = Boolean(anchorEl);
|
||||
|
||||
const history = useHistory();
|
||||
const otherRoles = UPPERCASE_USER_ROLES.filter(
|
||||
(role) => role != props.currentRole
|
||||
);
|
||||
|
@ -34,6 +35,8 @@ export default function ChangeRole(props: ChangeRoleProps): React.ReactElement {
|
|||
{
|
||||
onCompleted() {
|
||||
console.log("Role changed");
|
||||
history.go(0);
|
||||
handleClose();
|
||||
},
|
||||
onError(e) {
|
||||
console.error(e);
|
||||
|
|
|
@ -52,9 +52,9 @@ export default function DialogChangeQuestion(): React.ReactElement {
|
|||
},
|
||||
}
|
||||
);
|
||||
const categories =
|
||||
useQuery<GetAllCategoriesResponse, null>(GET_ALL_CATEGORIES).data
|
||||
?.allCategories.nodes;
|
||||
const categories = useQuery<GetAllCategoriesResponse, null>(
|
||||
GET_ALL_CATEGORIES
|
||||
).data?.allCategories.nodes;
|
||||
|
||||
const [editQuestion, { loading: editLoading }] = useMutation<
|
||||
EditQuestionResponse,
|
||||
|
|
|
@ -28,9 +28,8 @@ const useStyles = makeStyles((theme) => ({
|
|||
}));
|
||||
|
||||
export default function QuestionList(): React.ReactElement {
|
||||
const questions =
|
||||
useQuery<GetAllQuestionsResponse, null>(GET_ALL_QUESTIONS).data
|
||||
?.allQuestions.nodes;
|
||||
const questions = useQuery<GetAllQuestionsResponse, null>(GET_ALL_QUESTIONS)
|
||||
.data?.allQuestions.nodes;
|
||||
const classes = useStyles();
|
||||
|
||||
const handleAddButtonClick = () => {
|
||||
|
|
Loading…
Reference in New Issue