import { useLocalizedName } from "@/shared/common/localizedName"; import { useGoal } from "@/user-management/web-Management/hooks/useGoal"; import { useTheme } from "@/user-management/web-Management/hooks/useTheme"; import { useVision } from "@/user-management/web-Management/hooks/useVision"; import React, { useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; const OrganizationGoals = () => { const [currentGoalIndex, setCurrentGoalIndex] = useState(0); const [isMobile, setIsMobile] = useState(false); const localizedName = useLocalizedName(); const { t } = useTranslation(); const baseParams = { isActive: true, }; const { items } = useGoal(baseParams); const { items: theme, unit } = useTheme(); const { items: vision } = useVision(baseParams); const goals: any[] = items ?? []; // Auto-rotate goals useEffect(() => { if (items?.length) { const interval = setInterval(() => { setCurrentGoalIndex((prevIndex) => prevIndex === goals?.length - 1 ? 0 : prevIndex + 1 ); }, 3000); return () => clearInterval(interval); } }, [goals?.length, items]); // Responsive useEffect(() => { const checkScreenSize = () => { setIsMobile(window.innerWidth < 768); }; checkScreenSize(); window.addEventListener("resize", checkScreenSize); return () => window.removeEventListener("resize", checkScreenSize); }, []); const goToGoal = (index: any) => { setCurrentGoalIndex(index); }; const currentGoal = goals[currentGoalIndex]; function lightenColor(color: string, percent: number) { const R = parseInt(color.substring(1, 3), 16); const G = parseInt(color.substring(3, 5), 16); const B = parseInt(color.substring(5, 7), 16); const newR = Math.min(255, R + Math.round((255 - R) * (percent / 100))); const newG = Math.min(255, G + Math.round((255 - G) * (percent / 100))); const newB = Math.min(255, B + Math.round((255 - B) * (percent / 100))); return `#${newR.toString(16).padStart(2, "0")}${newG .toString(16) .padStart(2, "0")}${newB.toString(16).padStart(2, "0")}`; } return (
i.type === "PRIMARY_COLOR")?.value ? lightenColor( theme.find((i) => i.type === "PRIMARY_COLOR")!.value, 30 ) : "var(--primary-300)" }, ${ theme?.find((i) => i.type === "SECONDARY_COLOR")?.value ? lightenColor( theme.find((i) => i.type === "SECONDARY_COLOR")!.value, 55 ) : "var(--primary-300)" } )`, }}>
{/* Header */}
{/* Logo */}
i.type === "LOGO")?.presigned || "https://www.w3.org/Icons/w3c_home" } alt={localizedName(unit?.name)} className="w-full h-full object-cover" />
{/* Text */}

{localizedName(unit?.name)}

{/* Decorative line */}
i.type === "PRIMARY_COLOR")?.value || "#3b82f6" }, ${ theme?.find((i) => i.type === "SECONDARY_COLOR")?.value || "#9333ea" })`, }}>
{/* Goals */}
i.type === "SECONDARY_COLOR") ?.value || "#32CD32" }, ${ theme?.find((i) => i.type === "SECONDARY_COLOR") ?.value || "#FFFFFF" })`, }}> Goal Icon

{t("Strategic Goal")} {currentGoalIndex + 1} {t("of")}{" "} {goals?.length}

{localizedName(currentGoal?.goalTitle)}

{localizedName(currentGoal?.goalDescription) || t("msg.waitingMsg")}

{t("Our Strategic Goals")}
{goals?.map((_, index) => (
{/* Vision Section */}
Vision Image

{localizedName(vision?.[0]?.visionTitle)}

{localizedName(vision?.[0]?.visionDescription)}

); }; export default OrganizationGoals;