Получение, хранение и отображение проектов; новый компонент ProjectList, перенос к нему ProjectCard; реализация страниц проектов

This commit is contained in:
ifraimka committed 2024-05-17 16:44:45 +03:00
1 parent 81d2a009e0
commit 0ef02b2220
13 files changed
+132 -115

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import { useState, useEffect } from "react";
import ProjectCard from "./ProjectCard";
import { getProjects } from "../../api";
import "./ProjectList.styles.scss";
function ProjectList({ laboratory }) {
const [projectList, setProjectList] = useState({});
useEffect(() => {
const loadData = async () => {
const newProjectList = await getProjects(laboratory);
setProjectList(newProjectList);
};
loadData();
}, []);
return (
<div className="row project-list">
{Object.keys(projectList).map(id => <ProjectCard key={id} project={projectList[id]} />)}
</div>
);
}
export default ProjectList;