import React, { useState, useEffect } from 'react'; import { useParams, useLocation } from 'react-router-dom'; import ProjectWorkspaceComponent from '../components/project/ProjectWorkspace'; import { getProject } from '../api/client'; const ProjectWorkspace: React.FC = () => { const { id } = useParams(); const location = useLocation(); const [project, setProject] = useState(null); const [loading, setLoading] = useState(true); const fetchProject = () => { if (id) { getProject(id).then(data => { setProject(data); setLoading(false); }).catch(err => { console.error(err); setLoading(false); }); } }; useEffect(() => { fetchProject(); }, [id]); const projectName = project?.title || location.state?.projectName || 'Nieznany Projekt'; let projectStatus = 'Ładowanie'; if (project) { if (project.status === 'completed') projectStatus = 'Gotowy'; else if (project.status === 'in_progress') projectStatus = 'W Trakcie'; else { const approvedCount = project.sections?.filter((s: any) => s.is_approved).length || 0; const filledCount = project.sections?.filter((s: any) => s.content && s.content.length > 50).length || 0; if (approvedCount > 0 || filledCount > 0) projectStatus = 'W Trakcie'; else projectStatus = 'Szkic'; } } if (loading) { return (

Ładowanie szczegółów projektu...

); } if (!project) { return
Nie udało się załadować projektu.
} return ; }; export default ProjectWorkspace;