|
| 1 | + |
| 2 | +import { useState, useEffect } from "react"; |
| 3 | +import { Helmet } from "react-helmet-async"; |
| 4 | +import { UnifiedHeader } from "@/components/shared/UnifiedHeader"; |
| 5 | +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; |
| 6 | +import { Badge } from "@/components/ui/badge"; |
| 7 | +import { CheckCircle, AlertTriangle, XCircle, Clock, Activity, Database, Shield, Zap } from "lucide-react"; |
| 8 | + |
| 9 | +interface ServiceStatus { |
| 10 | + name: string; |
| 11 | + status: 'operational' | 'degraded' | 'outage' | 'maintenance'; |
| 12 | + description: string; |
| 13 | + icon: any; |
| 14 | + lastUpdated: string; |
| 15 | +} |
| 16 | + |
| 17 | +interface Incident { |
| 18 | + id: string; |
| 19 | + title: string; |
| 20 | + status: 'investigating' | 'identified' | 'monitoring' | 'resolved'; |
| 21 | + severity: 'minor' | 'major' | 'critical'; |
| 22 | + description: string; |
| 23 | + createdAt: string; |
| 24 | + updates: { |
| 25 | + time: string; |
| 26 | + message: string; |
| 27 | + status: string; |
| 28 | + }[]; |
| 29 | +} |
| 30 | + |
| 31 | +const StatusPage = () => { |
| 32 | + const [services, setServices] = useState<ServiceStatus[]>([ |
| 33 | + { |
| 34 | + name: "API RefSpring", |
| 35 | + status: "operational", |
| 36 | + description: "Toutes les fonctionnalités API fonctionnent normalement", |
| 37 | + icon: Zap, |
| 38 | + lastUpdated: new Date().toISOString() |
| 39 | + }, |
| 40 | + { |
| 41 | + name: "Dashboard Web", |
| 42 | + status: "operational", |
| 43 | + description: "Interface utilisateur accessible et fonctionnelle", |
| 44 | + icon: Activity, |
| 45 | + lastUpdated: new Date().toISOString() |
| 46 | + }, |
| 47 | + { |
| 48 | + name: "Base de données", |
| 49 | + status: "operational", |
| 50 | + description: "Stockage et récupération des données opérationnels", |
| 51 | + icon: Database, |
| 52 | + lastUpdated: new Date().toISOString() |
| 53 | + }, |
| 54 | + { |
| 55 | + name: "Authentification", |
| 56 | + status: "operational", |
| 57 | + description: "Connexion et sécurité des comptes fonctionnelles", |
| 58 | + icon: Shield, |
| 59 | + lastUpdated: new Date().toISOString() |
| 60 | + } |
| 61 | + ]); |
| 62 | + |
| 63 | + const [incidents, setIncidents] = useState<Incident[]>([]); |
| 64 | + |
| 65 | + const [overallStatus, setOverallStatus] = useState<'operational' | 'degraded' | 'outage'>('operational'); |
| 66 | + |
| 67 | + useEffect(() => { |
| 68 | + // Simuler une vérification périodique du statut |
| 69 | + const checkStatus = () => { |
| 70 | + // En production, ceci ferait des appels API réels |
| 71 | + const hasOutage = services.some(s => s.status === 'outage'); |
| 72 | + const hasDegraded = services.some(s => s.status === 'degraded' || s.status === 'maintenance'); |
| 73 | + |
| 74 | + if (hasOutage) { |
| 75 | + setOverallStatus('outage'); |
| 76 | + } else if (hasDegraded) { |
| 77 | + setOverallStatus('degraded'); |
| 78 | + } else { |
| 79 | + setOverallStatus('operational'); |
| 80 | + } |
| 81 | + }; |
| 82 | + |
| 83 | + checkStatus(); |
| 84 | + const interval = setInterval(checkStatus, 30000); // Vérifier toutes les 30 secondes |
| 85 | + |
| 86 | + return () => clearInterval(interval); |
| 87 | + }, [services]); |
| 88 | + |
| 89 | + const getStatusColor = (status: string) => { |
| 90 | + switch (status) { |
| 91 | + case 'operational': return 'text-green-600'; |
| 92 | + case 'degraded': return 'text-yellow-600'; |
| 93 | + case 'maintenance': return 'text-blue-600'; |
| 94 | + case 'outage': return 'text-red-600'; |
| 95 | + default: return 'text-gray-600'; |
| 96 | + } |
| 97 | + }; |
| 98 | + |
| 99 | + const getStatusIcon = (status: string) => { |
| 100 | + switch (status) { |
| 101 | + case 'operational': return <CheckCircle className="w-5 h-5 text-green-600" />; |
| 102 | + case 'degraded': return <AlertTriangle className="w-5 h-5 text-yellow-600" />; |
| 103 | + case 'maintenance': return <Clock className="w-5 h-5 text-blue-600" />; |
| 104 | + case 'outage': return <XCircle className="w-5 h-5 text-red-600" />; |
| 105 | + default: return <Clock className="w-5 h-5 text-gray-600" />; |
| 106 | + } |
| 107 | + }; |
| 108 | + |
| 109 | + const getStatusBadge = (status: string) => { |
| 110 | + const variants = { |
| 111 | + operational: 'default', |
| 112 | + degraded: 'secondary', |
| 113 | + maintenance: 'outline', |
| 114 | + outage: 'destructive' |
| 115 | + } as const; |
| 116 | + |
| 117 | + const labels = { |
| 118 | + operational: 'Opérationnel', |
| 119 | + degraded: 'Dégradé', |
| 120 | + maintenance: 'Maintenance', |
| 121 | + outage: 'Panne' |
| 122 | + }; |
| 123 | + |
| 124 | + return ( |
| 125 | + <Badge variant={variants[status as keyof typeof variants] || 'outline'}> |
| 126 | + {labels[status as keyof typeof labels] || status} |
| 127 | + </Badge> |
| 128 | + ); |
| 129 | + }; |
| 130 | + |
| 131 | + const redirectToDashboard = () => { |
| 132 | + window.location.href = '/app'; |
| 133 | + }; |
| 134 | + |
| 135 | + return ( |
| 136 | + <> |
| 137 | + <Helmet> |
| 138 | + <title>Statut des Services - RefSpring</title> |
| 139 | + <meta name="description" content="Vérifiez l'état en temps réel de tous les services RefSpring" /> |
| 140 | + </Helmet> |
| 141 | + |
| 142 | + <div className="min-h-screen bg-gray-50"> |
| 143 | + <UnifiedHeader onRedirectToDashboard={redirectToDashboard} currentPage="status" /> |
| 144 | + |
| 145 | + <div className="pt-20 pb-16 px-4 sm:px-6 lg:px-8"> |
| 146 | + <div className="max-w-4xl mx-auto"> |
| 147 | + {/* En-tête de statut global */} |
| 148 | + <div className="text-center mb-12"> |
| 149 | + <div className="flex items-center justify-center mb-4"> |
| 150 | + {getStatusIcon(overallStatus)} |
| 151 | + <h1 className="text-3xl font-bold text-gray-900 ml-3"> |
| 152 | + Statut des Services RefSpring |
| 153 | + </h1> |
| 154 | + </div> |
| 155 | + <p className={`text-lg ${getStatusColor(overallStatus)}`}> |
| 156 | + {overallStatus === 'operational' && 'Tous les systèmes sont opérationnels'} |
| 157 | + {overallStatus === 'degraded' && 'Certains services connaissent des problèmes'} |
| 158 | + {overallStatus === 'outage' && 'Des services sont actuellement indisponibles'} |
| 159 | + </p> |
| 160 | + <p className="text-sm text-gray-500 mt-2"> |
| 161 | + Dernière mise à jour : {new Date().toLocaleString('fr-FR')} |
| 162 | + </p> |
| 163 | + </div> |
| 164 | + |
| 165 | + {/* Statut des services */} |
| 166 | + <Card className="mb-8"> |
| 167 | + <CardHeader> |
| 168 | + <CardTitle className="flex items-center"> |
| 169 | + <Activity className="w-5 h-5 mr-2" /> |
| 170 | + Services |
| 171 | + </CardTitle> |
| 172 | + </CardHeader> |
| 173 | + <CardContent> |
| 174 | + <div className="space-y-4"> |
| 175 | + {services.map((service, index) => { |
| 176 | + const IconComponent = service.icon; |
| 177 | + return ( |
| 178 | + <div key={index} className="flex items-center justify-between p-4 bg-white rounded-lg border border-gray-200"> |
| 179 | + <div className="flex items-center space-x-3"> |
| 180 | + <IconComponent className="w-6 h-6 text-gray-600" /> |
| 181 | + <div> |
| 182 | + <h3 className="font-medium text-gray-900">{service.name}</h3> |
| 183 | + <p className="text-sm text-gray-500">{service.description}</p> |
| 184 | + </div> |
| 185 | + </div> |
| 186 | + <div className="flex items-center space-x-3"> |
| 187 | + {getStatusBadge(service.status)} |
| 188 | + {getStatusIcon(service.status)} |
| 189 | + </div> |
| 190 | + </div> |
| 191 | + ); |
| 192 | + })} |
| 193 | + </div> |
| 194 | + </CardContent> |
| 195 | + </Card> |
| 196 | + |
| 197 | + {/* Incidents récents */} |
| 198 | + {incidents.length > 0 ? ( |
| 199 | + <Card className="mb-8"> |
| 200 | + <CardHeader> |
| 201 | + <CardTitle className="flex items-center"> |
| 202 | + <AlertTriangle className="w-5 h-5 mr-2" /> |
| 203 | + Incidents Récents |
| 204 | + </CardTitle> |
| 205 | + </CardHeader> |
| 206 | + <CardContent> |
| 207 | + <div className="space-y-6"> |
| 208 | + {incidents.map((incident) => ( |
| 209 | + <div key={incident.id} className="border-l-4 border-yellow-400 pl-4"> |
| 210 | + <div className="flex items-center justify-between mb-2"> |
| 211 | + <h3 className="font-medium text-gray-900">{incident.title}</h3> |
| 212 | + <Badge variant={incident.severity === 'critical' ? 'destructive' : 'secondary'}> |
| 213 | + {incident.severity} |
| 214 | + </Badge> |
| 215 | + </div> |
| 216 | + <p className="text-sm text-gray-600 mb-3">{incident.description}</p> |
| 217 | + <div className="space-y-2"> |
| 218 | + {incident.updates.map((update, updateIndex) => ( |
| 219 | + <div key={updateIndex} className="text-xs text-gray-500"> |
| 220 | + <span className="font-medium">{update.time}</span> - {update.message} |
| 221 | + </div> |
| 222 | + ))} |
| 223 | + </div> |
| 224 | + </div> |
| 225 | + ))} |
| 226 | + </div> |
| 227 | + </CardContent> |
| 228 | + </Card> |
| 229 | + ) : ( |
| 230 | + <Card> |
| 231 | + <CardContent className="text-center py-8"> |
| 232 | + <CheckCircle className="w-12 h-12 text-green-600 mx-auto mb-4" /> |
| 233 | + <h3 className="text-lg font-medium text-gray-900 mb-2">Aucun incident signalé</h3> |
| 234 | + <p className="text-gray-500">Tous nos services fonctionnent normalement.</p> |
| 235 | + </CardContent> |
| 236 | + </Card> |
| 237 | + )} |
| 238 | + |
| 239 | + {/* Footer informatif */} |
| 240 | + <div className="mt-12 text-center text-sm text-gray-500"> |
| 241 | + <p>Cette page est mise à jour automatiquement toutes les 30 secondes.</p> |
| 242 | + <p className="mt-2"> |
| 243 | + Des questions ? Contactez notre équipe support à{" "} |
| 244 | + <a href="mailto:support@refspring.com" className="text-blue-600 hover:underline"> |
| 245 | + support@refspring.com |
| 246 | + </a> |
| 247 | + </p> |
| 248 | + </div> |
| 249 | + </div> |
| 250 | + </div> |
| 251 | + </div> |
| 252 | + </> |
| 253 | + ); |
| 254 | +}; |
| 255 | + |
| 256 | +export default StatusPage; |
0 commit comments