'use client'; import React, { useState, useContext } from 'react'; import { Panel } from 'primereact/panel'; import { Button } from 'primereact/button'; import { Toast } from 'primereact/toast'; import { useRef } from 'react'; import { LayoutContext } from '../../../../../layout/context/layoutcontext'; import AtlantisResponsivePhasesTable from '../../../../../components/phases/AtlantisResponsivePhasesTable'; import AtlantisAccessibilityControls from '../../../../../components/phases/AtlantisAccessibilityControls'; import PhasesQuickPreview from '../../../../../components/phases/PhasesQuickPreview'; import PhaseValidationPanel from '../../../../../components/phases/PhaseValidationPanel'; import { Dialog } from 'primereact/dialog'; import testDataService from '../../../../../services/testDataService'; import type { PhaseChantier } from '../../../../../types/btp'; const ResponsivePhasesPage: React.FC = () => { const [phases, setPhases] = useState([]); const [selectedPhase, setSelectedPhase] = useState(null); const [validationDialogVisible, setValidationDialogVisible] = useState(false); const [loading, setLoading] = useState(false); const { isDesktop } = useContext(LayoutContext); const toast = useRef(null); // Générer des données de test au chargement React.useEffect(() => { const client = testDataService.generateTestClient(1); const chantier = testDataService.generateTestChantier(1, 'MAISON_INDIVIDUELLE', client); const generatedPhases = testDataService.generatePhasesWithPrerequisites(chantier); setPhases(generatedPhases); }, []); const handlePhaseSelect = (phase: PhaseChantier) => { setSelectedPhase(phase); toast.current?.show({ severity: 'info', summary: 'Phase sélectionnée', detail: `${phase.nom} - ${phase.statut}`, life: 3000 }); }; const handlePhaseStart = (phaseId: string) => { setPhases(prev => prev.map(p => p.id === phaseId ? { ...p, statut: 'EN_COURS' as const, dateDebutReelle: new Date().toISOString().split('T')[0] } : p )); toast.current?.show({ severity: 'success', summary: 'Phase démarrée', detail: 'La phase a été mise en cours', life: 3000 }); }; const handlePhaseValidation = (phase: PhaseChantier) => { setSelectedPhase(phase); setValidationDialogVisible(true); }; const headerTemplate = (

Gestion des phases - Vue responsive

Interface adaptative utilisant le template Atlantis React

{isDesktop() && (
)}
); return (
{/* En-tête de page avec style Atlantis */}
{headerTemplate}
{/* Contrôles d'accessibilité */}
{/* Vue d'ensemble rapide */} {phases.length > 0 && (
)} {/* Tableau principal responsive */}
0 ? 'lg:col-8' : ''}`}>
{/* Informations complémentaires sur mobile */} {!isDesktop() && selectedPhase && (
Phase sélectionnée

{selectedPhase.nom}

{selectedPhase.statut}

{selectedPhase.pourcentageAvancement || 0}%

{selectedPhase.dateDebutPrevue ? new Date(selectedPhase.dateDebutPrevue).toLocaleDateString('fr-FR') : '-' }

{selectedPhase.description && (

{selectedPhase.description}

)}
)} {/* Actions rapides pour mobile */} {!isDesktop() && (
Actions rapides
)} {/* Statistiques rapides */}
{phases.length}
Total phases
{phases.filter(p => p.statut === 'TERMINEE').length}
Terminées
{phases.filter(p => p.statut === 'EN_COURS').length}
En cours
{phases.filter(p => p.critique).length}
Critiques
{/* Dialog de validation */} setValidationDialogVisible(false)} style={{ width: isDesktop() ? '800px' : '95vw' }} modal className="p-fluid" > {selectedPhase && ( { const prereq = phases.find(p => p.id === prereqId); if (prereq) { setSelectedPhase(prereq); } }} /> )}
); }; export default ResponsivePhasesPage;