diff --git a/redaktions-app/src/App.tsx b/redaktions-app/src/App.tsx
index 0212bd9..c460785 100644
--- a/redaktions-app/src/App.tsx
+++ b/redaktions-app/src/App.tsx
@@ -57,7 +57,9 @@ function App(): React.ReactElement {
- {jwt && }
+ {jwt && (
+
+ )}
);
diff --git a/redaktions-app/src/components/AccordionQuestionAnswer.tsx b/redaktions-app/src/components/AccordionQuestionAnswer.tsx
index 9b361b3..afa50db 100644
--- a/redaktions-app/src/components/AccordionQuestionAnswer.tsx
+++ b/redaktions-app/src/components/AccordionQuestionAnswer.tsx
@@ -40,7 +40,7 @@ const useStyles = makeStyles((theme: Theme) =>
);
interface AccordionQuestionAnswerProps {
- personRowId: number;
+ loggedInPersonRowId: number;
question: QuestionAnswerResponse;
}
@@ -86,7 +86,7 @@ export default function AccordionQuestionAnswer(
diff --git a/redaktions-app/src/components/ChangeRole.tsx b/redaktions-app/src/components/ChangeRoleMenu.tsx
similarity index 93%
rename from redaktions-app/src/components/ChangeRole.tsx
rename to redaktions-app/src/components/ChangeRoleMenu.tsx
index 1469148..3e9d78d 100644
--- a/redaktions-app/src/components/ChangeRole.tsx
+++ b/redaktions-app/src/components/ChangeRoleMenu.tsx
@@ -12,14 +12,18 @@ import {
import { useSnackbar } from "notistack";
import { GET_PERSONS_SORTED_BY_ROLE } from "../backend/queries/person";
-interface ChangeRoleProps {
+interface ChangeRoleMenuProps {
currentRole: UppercaseUserRole;
currentUserRowId: number;
+ disabled?: boolean;
}
-export default function ChangeRole(props: ChangeRoleProps): React.ReactElement {
+
+export default function ChangeRoleMenu(
+ props: ChangeRoleMenuProps
+): React.ReactElement {
+ const { enqueueSnackbar } = useSnackbar();
const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl);
- const { enqueueSnackbar } = useSnackbar();
const otherRoles = UPPERCASE_USER_ROLES.filter(
(role) => role != props.currentRole
);
@@ -63,6 +67,7 @@ export default function ChangeRole(props: ChangeRoleProps): React.ReactElement {
aria-haspopup="true"
onClick={handleMenu}
color="inherit"
+ disabled={props.disabled}
>
diff --git a/redaktions-app/src/components/EditAnswerSection.tsx b/redaktions-app/src/components/EditAnswerSection.tsx
index 7946bff..014bf74 100644
--- a/redaktions-app/src/components/EditAnswerSection.tsx
+++ b/redaktions-app/src/components/EditAnswerSection.tsx
@@ -22,7 +22,7 @@ import ToggleButtonGroupAnswerPosition from "./ToggleButtonGroupAnswerPosition";
import EditAnswerText from "./EditAnswerText";
interface EditAnswerSectionProps {
- personRowId: number;
+ loggedInPersonRowId: number;
question: QuestionAnswerResponse;
}
@@ -35,7 +35,7 @@ export default function EditAnswerSection(
GetAnswerByQuestionAndPersonVariables
>(GET_ANSWER_BY_QUESTION_AND_PERSON, {
variables: {
- personRowId: props.personRowId,
+ personRowId: props.loggedInPersonRowId,
questionRowId: props.question.rowId,
},
});
@@ -92,7 +92,7 @@ export default function EditAnswerSection(
const savePosition = parsePosition(position);
const response = await addAnswer({
variables: {
- personRowId: props.personRowId,
+ personRowId: props.loggedInPersonRowId,
questionRowId: props.question.rowId,
position: savePosition,
text: text,
@@ -104,7 +104,7 @@ export default function EditAnswerSection(
id: "somethingIntermediate",
position: savePosition,
text: text || null,
- personRowId: props.personRowId,
+ personRowId: props.loggedInPersonRowId,
questionRowId: props.question.rowId,
__typename: "Answer",
},
diff --git a/redaktions-app/src/components/HomePageCandidate.tsx b/redaktions-app/src/components/HomePageCandidate.tsx
index 4c4c3d2..96e25ce 100644
--- a/redaktions-app/src/components/HomePageCandidate.tsx
+++ b/redaktions-app/src/components/HomePageCandidate.tsx
@@ -28,7 +28,7 @@ export const candidateRoutes: CandidateRoutes = {
};
interface HomePageCandidateProps {
- personRowId: number;
+ loggedInPersonRowId: number;
}
export function HomePageCandidate(
@@ -40,7 +40,9 @@ export function HomePageCandidate(
-
+
diff --git a/redaktions-app/src/components/HomePageEditor.tsx b/redaktions-app/src/components/HomePageEditor.tsx
index c88525c..d53e801 100644
--- a/redaktions-app/src/components/HomePageEditor.tsx
+++ b/redaktions-app/src/components/HomePageEditor.tsx
@@ -37,7 +37,11 @@ export const editorRoutes: EditorRoutes = {
},
};
-export function HomePageEditor(): React.ReactElement {
+interface HomePageEditorProps {
+ loggedInUserRowId: number;
+}
+
+export function HomePageEditor(props: HomePageEditorProps): React.ReactElement {
const classes = useStyles();
return (
@@ -48,7 +52,7 @@ export function HomePageEditor(): React.ReactElement {
-
+
diff --git a/redaktions-app/src/components/Main.test.tsx b/redaktions-app/src/components/Main.test.tsx
index 3f08b1c..5d3d99a 100644
--- a/redaktions-app/src/components/Main.test.tsx
+++ b/redaktions-app/src/components/Main.test.tsx
@@ -12,7 +12,7 @@ function renderMainPage(jwt: JwtPayload) {
-
+
diff --git a/redaktions-app/src/components/Main.tsx b/redaktions-app/src/components/Main.tsx
index 95cd0fd..07d54f5 100644
--- a/redaktions-app/src/components/Main.tsx
+++ b/redaktions-app/src/components/Main.tsx
@@ -42,7 +42,7 @@ export interface PersonRoutes {
interface MainProps {
userRole: UserRole;
- userRowId: number;
+ loggedInUserRowId: number;
}
function Main(props: MainProps): ReactElement {
@@ -52,9 +52,11 @@ function Main(props: MainProps): ReactElement {
const getHomePage = (): ReactElement => {
switch (props.userRole) {
case "candymat_editor":
- return ;
+ return ;
case "candymat_candidate":
- return ;
+ return (
+
+ );
case "candymat_person":
return ;
}
diff --git a/redaktions-app/src/components/PersonCard.tsx b/redaktions-app/src/components/PersonCard.tsx
index 1e54f1b..89509d0 100644
--- a/redaktions-app/src/components/PersonCard.tsx
+++ b/redaktions-app/src/components/PersonCard.tsx
@@ -1,7 +1,7 @@
import { Avatar, Paper, Typography } from "@material-ui/core";
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
-import ChangeRole from "./ChangeRole";
+import ChangeRoleMenu from "./ChangeRoleMenu";
import { UppercaseUserRole } from "../jwt/jwt";
const useStyles = makeStyles((theme) => ({
@@ -29,6 +29,7 @@ interface PersonCardProps {
lastName: string;
userRole: UppercaseUserRole;
userRowId: number;
+ loggedInUserRowId: number;
}
export default function PersonCard(props: PersonCardProps): React.ReactElement {
@@ -48,7 +49,11 @@ export default function PersonCard(props: PersonCardProps): React.ReactElement {
{getInitials()}
{fullName}
-
+
);
}
diff --git a/redaktions-app/src/components/ProfileManagement.tsx b/redaktions-app/src/components/ProfileManagement.tsx
deleted file mode 100644
index be09f0a..0000000
--- a/redaktions-app/src/components/ProfileManagement.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import React from "react";
-import { Paper, Typography } from "@material-ui/core";
-import { makeStyles } from "@material-ui/core/styles";
-import PersonCard from "./PersonCard";
-import { useQuery } from "@apollo/client";
-import {
- BasicPersonResponse,
- GET_PERSONS_SORTED_BY_ROLE,
- GetPersonsSortedByRoleResponse,
-} from "../backend/queries/person";
-
-const useStyles = makeStyles((theme) => ({
- root: {
- width: "100%",
- padding: theme.spacing(1),
- marginBottom: theme.spacing(3),
- },
-}));
-
-export function ProfileManagement(): React.ReactElement {
- const classes = useStyles();
- const persons = useQuery(
- GET_PERSONS_SORTED_BY_ROLE
- ).data;
-
- const convertPersonNodeToPersonCard = (
- person: BasicPersonResponse
- ): JSX.Element => {
- return (
-
- );
- };
-
- return (
-
-
-
- Ertellen Sie hier ihr Profil
-
- {persons?.editors.nodes.map(convertPersonNodeToPersonCard)}
-
-
-
- KandidatInnen
-
- {persons?.candidates.nodes.map(convertPersonNodeToPersonCard)}
-
-
-
- Andere registrierte Personen
-
- {persons?.users.nodes.map(convertPersonNodeToPersonCard)}
-
-
- );
-}
diff --git a/redaktions-app/src/components/QuestionAnswerList.tsx b/redaktions-app/src/components/QuestionAnswerList.tsx
index f20e737..79030c4 100644
--- a/redaktions-app/src/components/QuestionAnswerList.tsx
+++ b/redaktions-app/src/components/QuestionAnswerList.tsx
@@ -20,7 +20,7 @@ const useStyles = makeStyles((theme) => ({
}));
interface QuestionAnswerListProps {
- personRowId: number;
+ loggedInPersonRowId: number;
}
export default function QuestionAnswersList(
@@ -32,7 +32,7 @@ export default function QuestionAnswersList(
GetAllQuestionAnswersVariables
>(GET_ALL_QUESTION_ANSWERS, {
variables: {
- personRowId: props.personRowId,
+ personRowId: props.loggedInPersonRowId,
},
}).data?.allQuestions.nodes;
@@ -45,7 +45,7 @@ export default function QuestionAnswersList(
{questionAnswers?.map((question) => (
))}
diff --git a/redaktions-app/src/components/UserManagement.tsx b/redaktions-app/src/components/UserManagement.tsx
index f7cab50..af0270c 100644
--- a/redaktions-app/src/components/UserManagement.tsx
+++ b/redaktions-app/src/components/UserManagement.tsx
@@ -17,7 +17,11 @@ const useStyles = makeStyles((theme) => ({
},
}));
-export function UserManagement(): React.ReactElement {
+interface UserManagementProps {
+ loggedInPersonRowId: number;
+}
+
+export function UserManagement(props: UserManagementProps): React.ReactElement {
const classes = useStyles();
const persons = useQuery(
GET_PERSONS_SORTED_BY_ROLE
@@ -33,6 +37,7 @@ export function UserManagement(): React.ReactElement {
lastName={person.lastName || ""}
userRole={person.role}
userRowId={person.rowId}
+ loggedInUserRowId={props.loggedInPersonRowId}
/>
);
};
diff --git a/redaktions-app/src/integration-tests/answer-list.integration.test.tsx b/redaktions-app/src/integration-tests/answer-list.integration.test.tsx
index cb51f77..9a588c1 100644
--- a/redaktions-app/src/integration-tests/answer-list.integration.test.tsx
+++ b/redaktions-app/src/integration-tests/answer-list.integration.test.tsx
@@ -40,7 +40,7 @@ function renderQuestionAnswerList(additionalMocks?: Array) {
-
+