"use client" import ResearchCard from "./research-card" import { SectionWrapper, SectionWrapperTitle, } from "@/app/components/wrappers/SectionWrapper" import { LABELS } from "@/app/labels" import { useProjects } from "@/app/providers/ProjectsProvider" import { ProjectInterface, ProjectStatus } from "@/lib/types" import NoResultIcon from "@/public/icons/no-result.svg" import Image from "next/image" import Link from "next/link" import React, { useEffect, useState, useMemo } from "react" const NoResults = () => { return (
No research projects found
{LABELS.COMMON.NO_RESULTS} {LABELS.COMMON.NO_RESULTS_DESCRIPTION}
) } const ProjectStatusOrderList = ["active", "maintained", "inactive"] export const ResearchList = () => { const [isMounted, setIsMounted] = useState(false) const { researchs } = useProjects() const noItems = researchs?.length === 0 useEffect(() => { setIsMounted(true) }, []) const { activeResearchs, pastResearchs } = useMemo(() => { const active = researchs.filter( (research: ProjectInterface) => research.projectStatus === ProjectStatus.ACTIVE ) const past = researchs.filter( (research: ProjectInterface) => research.projectStatus !== ProjectStatus.ACTIVE ) return { activeResearchs: active, pastResearchs: past } }, [researchs]) if (!isMounted) { return (
) } if (noItems) return return (
{activeResearchs.map((project: ProjectInterface) => ( ))}
{pastResearchs.map((project: ProjectInterface) => ( {project.name} ))}
) }