Small fix so that it uses component for getting users in a proj
This commit is contained in:
parent
5f42fa7818
commit
0c8a394f74
1 changed files with 7 additions and 23 deletions
|
@ -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 (
|
||||
<>
|
||||
|
|
Loading…
Reference in a new issue