fix: handle non-array translation data before mapping buttons

This commit is contained in:
mouazkh
2026-01-13 20:42:48 +03:00
parent 062a4257e4
commit 301232fef1
4 changed files with 432 additions and 98 deletions

View File

@ -21,7 +21,11 @@ import d21 from "../../../../src/assets/Images/d21.jpeg";
import d22 from "../../../../src/assets/Images/d22.jpg";
const departments = [
{ id: 1, title: "قسم إنشاء وصيانة المنشآت الصناعية وخطوط الإنتاج", image: d1 },
{
id: 1,
title: "قسم إنشاء وصيانة المنشآت الصناعية وخطوط الإنتاج",
image: d1,
},
{ id: 2, title: "قسم تنفيذ المرافق السكنية والخدمية", image: d7 },
{ id: 3, title: "قسم اعادة تأهيل وصيانة المباني", image: d14 },
{ id: 4, title: "قسم محطات الوقود وصيانة المنشآت النفطية", image: d17 },
@ -79,11 +83,14 @@ function DepartmentCard({ dept, offset, index }) {
const progressParallax = useTransform(scrollYProgress, [0, 1], [15, -15]);
const y = useTransform([velocityParallax, progressParallax], ([v, p]) => v + p);
const y = useTransform(
[velocityParallax, progressParallax],
([v, p]) => v + p
);
const handleClick = () => {
if (dept.id === 1) {
navigate("/departments/:id");
navigate("/departments/1");
}
if (dept.id === 9) {
navigate("/department-detail9");
@ -110,7 +117,9 @@ function DepartmentCard({ dept, offset, index }) {
}
};
const translatedTitle = t(`departments.list.${dept.id - 1}`, { defaultValue: dept.title });
const translatedTitle = t(`departments.list.${dept.id - 1}`, {
defaultValue: dept.title,
});
return (
<div
@ -140,7 +149,8 @@ function DepartmentCard({ dept, offset, index }) {
scale: s,
y,
transformStyle: "preserve-3d",
boxShadow: "0 18px 50px rgba(2,6,23,0.12), 0 6px 18px rgba(2,6,23,0.06)",
boxShadow:
"0 18px 50px rgba(2,6,23,0.12), 0 6px 18px rgba(2,6,23,0.06)",
}}
className="cursor-pointer w-full h-56 sm:h-72 md:h-96 lg:h-[28rem] object-cover rounded-2xl bg-white/20 backdrop-blur-md border border-white/10"
/>
@ -152,10 +162,14 @@ export default function Departments() {
const { t } = useTranslation();
return (
<section id="departments" className="min-h-screen text-black bg-transparent" dir="rtl">
<section
id="departments"
className="min-h-screen text-black bg-transparent"
dir="rtl"
>
<header className="max-w-6xl mx-auto px-4 sm:px-6 md:px-8 pt-10 sm:pt-12 relative z-20">
<h1 className="text-3xl sm:text-4xl md:text-5xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-[#041c40] via-[#57acd9] to-[#041c40] drop-shadow-lg">
{t('departments.heading', { defaultValue: 'أقسامنا' })}
{t("departments.heading", { defaultValue: "أقسامنا" })}
</h1>
</header>