diff --git a/frontend/src/Components/UserProjectListAdmin.tsx b/frontend/src/Components/UserProjectListAdmin.tsx index eaebcba..423e793 100644 --- a/frontend/src/Components/UserProjectListAdmin.tsx +++ b/frontend/src/Components/UserProjectListAdmin.tsx @@ -1,22 +1,19 @@ -import React from "react"; -import { useEffect, useState } from "react"; // Importing useEffect and useState from React -import { api } from "../API/API"; // Importing the api object -import { Project } from "../Types/goTypes"; // Importing the Project type +import React, { useEffect, useState } from "react"; +import { api } from "../API/API"; +import { Project } from "../Types/goTypes"; const UserProjectListAdmin: React.FC = () => { - // Define the functional component UserProjectListAdmin - const [projects, setProjects] = useState([]); // State management for projects + const [projects, setProjects] = useState([]); useEffect(() => { const fetchProjects = async (): Promise => { - // Define the fetchProjects async function try { const token = localStorage.getItem("accessToken") ?? ""; const username = getUsernameFromContext(); // Assuming you have a function to get the username from your context - const response = await api.getUserProjects(username, token); // Fetch projects from API + const response = await api.getUserProjects(username, token); if (response.success) { - setProjects(response.data ?? []); // Update projects state with fetched data + setProjects(response.data ?? []); } else { console.error("Failed to fetch projects:", response.message); } @@ -25,13 +22,20 @@ const UserProjectListAdmin: React.FC = () => { } }; - void fetchProjects(); // Call fetchProjects when the component mounts - }, []); // Empty dependency array to run effect only once + void fetchProjects(); + }, []); return (

User Projects

- {/* Placeholder for project list */} +
    + {projects.map((project) => ( +
  • + {project.name} + {/* Add any additional project details you want to display */} +
  • + ))} +
); };