|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import { useTranslation } from "react-i18next"; |
| 4 | +// import TabsResearchLineFilter from "@/components/filters/TabsResearchLineFilter"; |
| 5 | +import { projects } from "@/constants/projects"; |
| 6 | +import { Card } from "@/components/core/Cards"; |
| 7 | +// import { researchlines } from "@/constants/researchlines"; |
| 8 | +import Heading from "@/components/ui/Heading"; |
| 9 | +import Text from "@/components/ui/Text" |
| 10 | +// import ProjectsFilter from "@/components/filters/ProjectsFilter" |
| 11 | +import { useRouter, useSearchParams } from "next/navigation"; |
| 12 | +import { useState, useEffect } from "react"; |
| 13 | +import { Suspense } from 'react'; |
| 14 | + |
| 15 | + |
| 16 | +export default function Projects() { |
| 17 | + return ( |
| 18 | + <Suspense> |
| 19 | + <ProjectsPage /> |
| 20 | + </Suspense> |
| 21 | + ); |
| 22 | + |
| 23 | +} |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +function ProjectsPage() { |
| 28 | + const { t, i18n } = useTranslation(); |
| 29 | + const currentLang = i18n.language; |
| 30 | + |
| 31 | + const router = useRouter(); // Hook para manipular la URL |
| 32 | + let searchParams = useSearchParams(); |
| 33 | + |
| 34 | + const [researchLine, setResearchLine] = useState("all"); |
| 35 | + const [projectType, setProjectType] = useState(undefined); |
| 36 | + const [search, setSearch] = useState(""); |
| 37 | + |
| 38 | + const pathname = "/projects"; |
| 39 | + |
| 40 | +// // creado array de categorías de publications |
| 41 | +// const projectTypes = ["all",...new Set(projects.map(project => project.projectType))]; |
| 42 | + |
| 43 | +// // 2. Agregar objeto "all", que sería "todas las líneas de inv." |
| 44 | +// let researchLines = ["all", ...researchlines]; |
| 45 | + |
| 46 | +// //actualizar la URL cuando cambia algo en el estado, usamos router.push |
| 47 | +// useEffect(() => { |
| 48 | +// let query = {}; |
| 49 | +// if (search) query.search = search; |
| 50 | +// if (projectType) query.category = projectType; |
| 51 | +// if (researchLine) query.researchline = researchLine; |
| 52 | + |
| 53 | +// router.push(`${pathname}/?${new URLSearchParams(query).toString()}`, undefined); |
| 54 | +// }, [search, projectType, researchLine]); |
| 55 | + |
| 56 | + |
| 57 | +// // función para obtener todos los parámetros de la URL |
| 58 | +// useEffect(() => { |
| 59 | +// let researchLineURL = searchParams.get('researchline'); |
| 60 | +// console.log("researchLineURL: " + researchLineURL); |
| 61 | +// setResearchLine(researchLineURL); |
| 62 | + |
| 63 | +// let searchURL = searchParams.get('search'); |
| 64 | +// console.log("searchURL: " + searchURL); |
| 65 | +// setSearch(searchURL); |
| 66 | + |
| 67 | +// let projectTypeURL = searchParams.get('category'); |
| 68 | +// console.log("projectType: " + projectTypeURL); |
| 69 | +// setProjectType(projectTypeURL); |
| 70 | + |
| 71 | +// }, []); |
| 72 | + |
| 73 | +// // Filtrar los proyectos por línea de investigación |
| 74 | +// const filteredItems = projects.filter( |
| 75 | + |
| 76 | +// (item) => |
| 77 | + |
| 78 | +// (!search || |
| 79 | +// search |
| 80 | +// .toLowerCase() |
| 81 | +// .replace(new RegExp(/\s/g), "") |
| 82 | +// .replace(new RegExp(/[àáâãäå]/g), "a") |
| 83 | +// .replace(new RegExp(/æ/g), "ae") |
| 84 | +// .replace(new RegExp(/ç/g), "c") |
| 85 | +// .replace(new RegExp(/[èéêë]/g), "e") |
| 86 | +// .replace(new RegExp(/[ìíîï]/g), "i") |
| 87 | +// .replace(new RegExp(/ñ/g), "n") |
| 88 | +// .replace(new RegExp(/[òóôõö]/g), "o") |
| 89 | +// .replace(new RegExp(/œ/g), "oe") |
| 90 | +// .replace(new RegExp(/[ùúûü]/g), "u") |
| 91 | +// .replace(new RegExp(/[ýÿ]/g), "y") |
| 92 | +// .replace(new RegExp(/\W/g), "") |
| 93 | +// .split(" ") |
| 94 | +// .every((i) => |
| 95 | +// item.title |
| 96 | +// .toLowerCase() |
| 97 | +// .replace(new RegExp(/\s/g), "") |
| 98 | +// .replace(new RegExp(/[àáâãäå]/g), "a") |
| 99 | +// .replace(new RegExp(/æ/g), "ae") |
| 100 | +// .replace(new RegExp(/ç/g), "c") |
| 101 | +// .replace(new RegExp(/[èéêë]/g), "e") |
| 102 | +// .replace(new RegExp(/[ìíîï]/g), "i") |
| 103 | +// .replace(new RegExp(/ñ/g), "n") |
| 104 | +// .replace(new RegExp(/[òóôõö]/g), "o") |
| 105 | +// .replace(new RegExp(/œ/g), "oe") |
| 106 | +// .replace(new RegExp(/[ùúûü]/g), "u") |
| 107 | +// .replace(new RegExp(/[ýÿ]/g), "y") |
| 108 | +// .replace(new RegExp(/\W/g), "") |
| 109 | +// .includes(i) |
| 110 | +// )) && |
| 111 | +// (!researchLine || (researchLine === "all" || item.researchLine.includes(researchLine))) && |
| 112 | +// (!projectType || (item.projectType && item.projectType === projectType)) |
| 113 | +// ); |
| 114 | +// console.log(filteredItems.map(filteredItem => filteredItem )); |
| 115 | + return ( |
| 116 | + <div> |
| 117 | + <div className="standard_margin" id="banner-publications"> |
| 118 | + <Heading level="h2">{t("projects.title")}</Heading> |
| 119 | + <Text type="p"> |
| 120 | + {t("projects.description")} |
| 121 | + </Text> |
| 122 | + </div> |
| 123 | + <div> |
| 124 | + |
| 125 | + <div className="flex flex-col justify-center"> |
| 126 | + {/* <ProjectsFilter |
| 127 | + researchLines={researchLines} |
| 128 | + researchLine={researchLine} |
| 129 | + projectType={projectType} |
| 130 | + projectTypes={projectTypes} |
| 131 | + search={search} |
| 132 | + changeProjectType={(projectType) => setProjectType(projectType)} |
| 133 | + changeResearchLine={(researchLine) => setResearchLine(researchLine)} |
| 134 | + changeSearch={(search) => setSearch(search)} |
| 135 | + pathname={pathname} |
| 136 | + /> */} |
| 137 | + |
| 138 | + </div> |
| 139 | + <div className="project_cards standard_margin my-4 sm:my-6 lg:my-10 sm:gap-4"> |
| 140 | + {projects.map( |
| 141 | + ( |
| 142 | + { |
| 143 | + year, |
| 144 | + title, |
| 145 | + description, |
| 146 | + description_es, |
| 147 | + researchLine, |
| 148 | + logo, |
| 149 | + route, |
| 150 | + projectType |
| 151 | + }, |
| 152 | + index |
| 153 | + ) => ( |
| 154 | + <Card |
| 155 | + key={index} |
| 156 | + cardType={"project"} |
| 157 | + year={year} |
| 158 | + researchLine={researchLine} |
| 159 | + title={title} |
| 160 | + logo={logo} |
| 161 | + route={route} |
| 162 | + description_en={description} |
| 163 | + description_es={description_es} |
| 164 | + projectType={projectType} |
| 165 | + ></Card> |
| 166 | + ) |
| 167 | + )} |
| 168 | + </div> |
| 169 | + </div> |
| 170 | + </div> |
| 171 | + ); |
| 172 | +} |
0 commit comments