diff --git a/frontend/src/Components/UserProjectListAdmin.tsx b/frontend/src/Components/UserProjectListAdmin.tsx index 9d6cc6e..eaebcba 100644 --- a/frontend/src/Components/UserProjectListAdmin.tsx +++ b/frontend/src/Components/UserProjectListAdmin.tsx @@ -7,6 +7,27 @@ const UserProjectListAdmin: React.FC = () => { // Define the functional component UserProjectListAdmin const [projects, setProjects] = useState([]); // State management for projects + 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 + if (response.success) { + setProjects(response.data ?? []); // Update projects state with fetched data + } else { + console.error("Failed to fetch projects:", response.message); + } + } catch (error) { + console.error("Error fetching projects:", error); + } + }; + + void fetchProjects(); // Call fetchProjects when the component mounts + }, []); // Empty dependency array to run effect only once + return (

User Projects