From 36524e5cbb3ab99dbd0df10d97f8f0c3ef03b808 Mon Sep 17 00:00:00 2001 From: Peter KW Date: Tue, 19 Mar 2024 00:25:37 +0100 Subject: [PATCH] Changed so that it makes a modal for each user instead of a link --- frontend/src/Components/UserListAdmin.tsx | 54 +++++++++++++++++------ 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/frontend/src/Components/UserListAdmin.tsx b/frontend/src/Components/UserListAdmin.tsx index b86076a..3d2bcae 100644 --- a/frontend/src/Components/UserListAdmin.tsx +++ b/frontend/src/Components/UserListAdmin.tsx @@ -1,5 +1,6 @@ -import { Link } from "react-router-dom"; +import { useState } from "react"; import { PublicUser } from "../Types/goTypes"; +import UserInfoModal from "./UserInfoModal"; /** * The props for the UserProps component @@ -9,27 +10,52 @@ interface UserProps { } /** - * A list of users for admin manage users page, that links admin to the right user page - * thanks to the state property - * @param props - The users to display + * A list of users for admin manage users page, that sets an onClick + * function for eact user
  • element, which displays a modul with + * user info. + * @param props - An array of users users to display * @returns {JSX.Element} The user list * @example - * const users = [{ id: 1, userName: "Random name" }]; + * const users = [{ id: 1, userName: "ExampleName" }]; * return ; */ export function UserListAdmin(props: UserProps): JSX.Element { + const [modalVisible, setModalVisible] = useState(false); + const [username, setUsername] = useState(""); + + const handleClick = (username: string): void => { + setUsername(username); + setModalVisible(true); + }; + + const handleClose = (): void => { + setUsername(""); + setModalVisible(false); + }; + return ( -
    -
      - {props.users.map((user) => ( - -
    • + <> + +
      +
        + {props.users.map((user) => ( +
      • { + handleClick(user.username); + }} + > {user.username}
      • - - ))} -
      -
      + ))} +
    +
    + ); }