diff --git a/src/app/page.tsx b/src/app/page.tsx index 87d4225..71332a5 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -32,8 +32,9 @@ import { ProjectYear } from "../types/ProjectYear"; import Histories from "@components/Histories"; import Winners from "@components/Winners"; import { getTime, getDate, getYear } from "date-fns"; -import YearCard from "@components/CardYear"; -import ProjectYearSection from "@components/ProjectYearSection"; +import LabelCard from "@components/CardYear"; +import ProjectsSection from "@components/ProjectsSection"; +import { motion } from "framer-motion"; function getSortedProjects(projects: IProject[]) { const sorted = [...projects].sort( @@ -46,11 +47,6 @@ function getSortedProjects(projects: IProject[]) { const project = sorted[i]; const projectYear = getYear(project.releaseDate); const key = project.stage !== 6 ? "В работе" : projectYear; - // if(project.stage === 6){ - // if(sortedProject.has(key)){ - - // } - // } if (sortedProject.has(key)) { const prevProjects = sortedProject.get(key) as IProject[]; @@ -62,11 +58,10 @@ function getSortedProjects(projects: IProject[]) { } } - console.log("sortedProject", sortedProject); return sortedProject; } -function getProjectYears(projects: IProject[]) { +function getProjectLabels(projects: IProject[]) { const projectYears: number[] = []; for (let i = 0; i < projects.length; i++) { @@ -87,7 +82,7 @@ export default function App() { "/videos/features/virtual_tour.mp4" ); const [projects, setProjects] = useState([]); - const [projectYears, setProjectYears] = useState([]); + const [projectLabels, setProjectLabels] = useState<(string | number)[]>([]); const [sortedProjects, setSortedProjects] = useState(); const [setModal] = useModalStore((state) => [state.setModal]); const [isShownAllProjects, setIsShownAllProjects] = useState(false); @@ -96,10 +91,10 @@ export default function App() { async function getProjects() { try { const _projects: IProject[] = await api.get("projects").json(); - const _projectYears = getProjectYears(_projects); + const _projectLabels = getProjectLabels(_projects); const _sortedProjects = getSortedProjects(_projects); - setProjectYears(_projectYears); + setProjectLabels(_projectLabels); setSortedProjects(_sortedProjects); setProjects(_projects); } catch (error) { @@ -338,7 +333,11 @@ export default function App() { -
+ console.log("first")} + >
@@ -419,7 +418,7 @@ export default function App() {
-
+
{/* */} @@ -647,23 +646,22 @@ export default function App() {
Проекты -
- {/* {projectYears.map((year) => { - const projects = - (sortedProjects && sortedProjects.get(year)) ?? []; + {projectLabels.map((year) => { + const projects = + (sortedProjects && sortedProjects.get(year)) ?? []; - return ( - - ); - })} */} - {projects.map((project, index) => ( - - ))} -
+ return ( + <> + {projects.length !== 0 && ( + + )} + + ); + })}
{[...Array(5)].map((_, index) => ( diff --git a/src/components/CardYear.tsx b/src/components/CardYear.tsx index fe2bbf2..e974e76 100644 --- a/src/components/CardYear.tsx +++ b/src/components/CardYear.tsx @@ -1,9 +1,9 @@ -interface YearCardProps { - year: number; +interface LabelCardProps { + label: number | string; } -const YearCard = ({ year }: YearCardProps): JSX.Element => { - return
{year}
; +const LabelCard = ({ label }: LabelCardProps): JSX.Element => { + return
{label}
; }; -export default YearCard; +export default LabelCard; diff --git a/src/components/ProjectYearSection.tsx b/src/components/ProjectYearSection.tsx deleted file mode 100644 index d559f34..0000000 --- a/src/components/ProjectYearSection.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { IProject } from "../types/IProject"; -import YearCard from "./CardYear"; -import ProjectCard from "./ProjectCard"; - -type ProjectYearSectionProps = { - year: number; - projects: IProject[]; -}; - -const ProjectYearSection = ({ year, projects }: ProjectYearSectionProps) => { - return ( - <> - - {projects.map((project, index) => ( - - ))} - - ); -}; - -export default ProjectYearSection; diff --git a/src/components/ProjectsSection.tsx b/src/components/ProjectsSection.tsx new file mode 100644 index 0000000..c808772 --- /dev/null +++ b/src/components/ProjectsSection.tsx @@ -0,0 +1,21 @@ +import { IProject } from "../types/IProject"; +import LabelCard from "./CardYear"; +import ProjectCard from "./ProjectCard"; + +type ProjectYearSectionProps = { + year: number | string; + projects: IProject[]; +}; + +const ProjectsSection = ({ year, projects }: ProjectYearSectionProps) => { + return ( +
+ + {projects.map((project, index) => ( + + ))} +
+ ); +}; + +export default ProjectsSection;