Small fix so that it uses component for getting users in a proj

This commit is contained in:
Peter KW 2024-03-31 20:56:08 +02:00
parent 5f42fa7818
commit 0c8a394f74

View file

@ -1,31 +1,15 @@
import { useEffect, useState } from "react";
import { useState } from "react";
import { Link, useParams } from "react-router-dom";
import { api } from "../API/API";
import { UserProjectMember } from "../Types/goTypes";
import GetUsersInProject, { ProjectMember } from "./GetUsersInProject";
function ProjectMembers(): JSX.Element {
const { projectName } = useParams();
const [projectMembers, setProjectMembers] = useState<UserProjectMember[]>([]);
const [projectMembers, setProjectMembers] = useState<ProjectMember[]>([]);
useEffect(() => {
const getProjectMembers = async (): Promise<void> => {
const token = localStorage.getItem("accessToken") ?? "";
const response = await api.getAllUsersProject(projectName ?? "", token);
console.log(response);
if (response.success) {
setProjectMembers(response.data ?? []);
} else {
console.error(response.message);
}
};
void getProjectMembers();
}, [projectName]);
interface ProjectMember {
Username: string;
UserRole: string;
}
GetUsersInProject({
projectName: projectName ?? "",
setUsersProp: setProjectMembers,
});
return (
<>