Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | 1x 29x 29x 29x 29x 29x 29x 29x 13x 13x 13x 12x 29x 12x 39x 29x 39x 39x 39x 29x 16x 14x 14x 14x 14x 14x 15x 15x 3x 3x 3x 22x | import {useTranslation} from 'react-i18next';
import {Card} from "@/components/ui/card/Card";
import {CardContent} from "@/components/ui/cardContent/CardContent";
import React, {useEffect, useState} from "react";
import {PageSection} from "@/components/ui/pageSection/PageSection";
import {ExpandableText} from "@/components/ui/expandableText/ExpandableText";
import {SeoHead} from "@/components/seoHead/SeoHead";
import {Pagination} from "@/components/ui/pagination/Pagination";
import {PageGrid} from "@/components/ui/pageGrid/PageGrid";
import TechDisclosure from "@/components/ui/techDisclosure/TechDisclosure";
import {getProjects} from "@/services/portfolioService";
import {Loading} from "@/components/loading/Loading";
import {ErrorState} from "@/components/errorState/ErrorState";
const ITEMS_PER_PAGE = 2;
/**
* Projects component displays a list of projects grouped by company.
*
* Features:
* - Sidebar with buttons to filter projects by company.
* - Shows project details including name, company, period, type, and technologies used.
* - Each project has a collapsible panel to toggle visibility of technology stack.
* - Uses i18n translation for UI texts and project types.
*
* @component
* @module pages/projects/Projects
* @returns {JSX.Element} Rendered Projects section with filtering and collapsible tech details.
*/
export default function Projects() {
const {t} = useTranslation();
const [selectedCompany, setSelectedCompany] = useState("Intesa Sanpaolo");
const [page, setPage] = useState(1);
const [projects, setProjects] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
const loadProjects = () => {
setLoading(true);
setError(null);
getProjects()
.then(setProjects)
.catch(setError)
.finally(() => setLoading(false));
};
useEffect(() => {
loadProjects();
}, []);
const companies = [...new Set(projects.map(p => p.company))];
const groupedProjects = projects.reduce((acc, proj) => {
acc[proj.company] = acc[proj.company] || [];
acc[proj.company].push(proj);
return acc;
}, {});
if (loading) return <Loading/>;
if (error) return <ErrorState message={t("error_generic")} onRetry={loadProjects}/>;
return (
<>
<SeoHead pageKey="projects" path="/projects"/>
<PageSection title={t("projects_title")}>
{(() => {
const currentProjects = groupedProjects[selectedCompany] || [];
const totalPages = Math.ceil(currentProjects.length / ITEMS_PER_PAGE);
const paginated = currentProjects.slice(
(page - 1) * ITEMS_PER_PAGE,
page * ITEMS_PER_PAGE
);
return (
<div className="flex flex-col md:flex-row gap-8">
{/* SIDEBAR */}
<aside className="md:w-64 md:shrink-0 md:sticky md:top-24 h-fit">
<div
className="flex flex-row md:flex-col gap-2 md:gap-3 overflow-x-auto md:overflow-visible snap-x md:snap-none px-1 md:px-0 pb-3 scrollbar-hide"
>
{companies.map((company) => {
const count = groupedProjects[company]?.length ?? 0;
return (
<button
key={company}
onClick={() => {
setSelectedCompany(company);
setPage(1);
window.scrollTo({top: 0, behavior: "smooth"});
}}
className={`snap-start text-left rounded-lg px-3 py-2 border transition-all duration-200 flex items-center justify-between gap-3
${selectedCompany === company
? "bg-blue-600 text-white border-blue-600 shadow-md"
: "bg-white/70 dark:bg-gray-800/60 border-gray-200 dark:border-gray-700 hover:-translate-y-0.5 hover:shadow"
}
`}
>
<span className="truncate">{company}</span>
<span className={`text-xs px-2 py-0.5 rounded-full
${selectedCompany === company
? "bg-white/20 text-white"
: "bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"
}
`}>
{count}
</span>
</button>
);
})}
</div>
</aside>
{/* MAIN */}
<main className="flex-1 min-w-0">
<div className="max-w-6xl mx-auto flex flex-col gap-6">
{/* pagination mobile sticky */}
<div
className="md:hidden sticky top-0 z-20 bg-white/85 dark:bg-gray-900/85 backdrop-blur border-b border-gray-200 dark:border-gray-700 py-2 mb-4">
<Pagination
page={page}
totalPages={totalPages}
onPageChange={setPage}
/>
</div>
{/* GRID */}
{paginated.length > 0 && (
<PageGrid
page={`${selectedCompany}-${page}`}
columns={2}
className="pt-2"
>
{paginated.map((proj, idx) => (
<Card
key={idx}
className="relative w-full p-5 sm:p-6 border border-gray-200/60
dark:border-gray-700/60 bg-white/60 dark:bg-gray-800/40 backdrop-blur-md
rounded-xl hover:shadow-lg transition-all duration-300
flex flex-col md:flex-row items-start gap-4"
>
<CardContent className="p-0">
<div className="flex flex-col gap-3">
<div className="flex flex-col gap-2">
<h3 className="text-lg md:text-xl font-semibold text-gray-900 dark:text-gray-100 leading-snug line-clamp-2">
{proj.name}
</h3>
{/* Meta info container */}
<div className="flex flex-wrap gap-2 items-center">
<span
className="text-xs font-medium px-3 py-1 rounded-full bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300">
{proj.period}
</span>
</div>
</div>
{proj.type && (
<ExpandableText
value={t(`project_types.${proj.type}`)}
maxLines={4}
className="text-sm mb-2 px-4 py-3 bg-white/50 dark:bg-gray-900/50 rounded-xl shadow-inner italic text-gray-800 dark:text-gray-200"
/>
)}
</div>
{/* LOW BLOCK - Tech */}
<TechDisclosure techList={proj.tech}
label={t("show_technologies")}/>
</CardContent>
</Card>
))}
</PageGrid>
)}
{/* pagination desktop bottom */}
<div className="hidden md:flex justify-center mt-8">
<Pagination
page={page}
totalPages={totalPages}
onPageChange={setPage}
/>
</div>
</div>
</main>
</div>
);
})()}
</PageSection>
</>
);
}
|