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 (
{localizedName(currentGoal?.goalDescription) || t("msg.waitingMsg")}
{localizedName(vision?.[0]?.visionDescription)}