import React, { useEffect, useState } from 'react'; import { useParams, Link } from 'react-router-dom'; import { useStore } from '../../store/useStore'; import { Area } from '../../entities/Area'; import { useTranslation } from 'react-i18next'; const AreaDetails: React.FC = () => { const { t } = useTranslation(); const { id } = useParams<{ id: string }>(); const { areas } = useStore((state: any) => state.areasStore); const [area, setArea] = useState(null); const [isLoading, setIsLoading] = useState(true); const [isError, setIsError] = useState(false); useEffect(() => { if (!areas.length) setIsLoading(true); const foundArea = areas.find((a: Area) => a.id === Number(id)); setArea(foundArea || null); if (!foundArea) { setIsError(true); } setIsLoading(false); }, [id, areas]); if (isLoading) { return (
{area?.description}
{t('areas.viewProjects', { name: area?.name })}