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 { Link, useParams } from "react-router-dom";
import { api } from "../API/API"; import GetUsersInProject, { ProjectMember } from "./GetUsersInProject";
import { UserProjectMember } from "../Types/goTypes";
function ProjectMembers(): JSX.Element { function ProjectMembers(): JSX.Element {
const { projectName } = useParams(); const { projectName } = useParams();
const [projectMembers, setProjectMembers] = useState<UserProjectMember[]>([]); const [projectMembers, setProjectMembers] = useState<ProjectMember[]>([]);
useEffect(() => { GetUsersInProject({
const getProjectMembers = async (): Promise<void> => { projectName: projectName ?? "",
const token = localStorage.getItem("accessToken") ?? ""; setUsersProp: setProjectMembers,
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;
}
return ( return (
<> <>