import { useState, useEffect } from 'react'; import { Link } from 'react-router-dom'; import { apiClient } from '@/services/api/client'; import { logger } from '@/utils/logger'; import { parseApiError } from '@/utils/apiErrorHandler'; import { Button } from '@/components/ui/button'; import { Shield, ExternalLink } from 'lucide-react'; interface SessionsResponse { sessions: Array<{ id: string; ip_address: string; user_agent: string; last_activity: string; created_at: string; is_current: boolean; }>; count: number; } export function UserProfile() { const [activeSessionsCount, setActiveSessionsCount] = useState(0); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { fetchSessionsCount(); }, []); const fetchSessionsCount = async () => { try { setLoading(true); setError(null); const response = await apiClient.get('/auth/sessions'); setActiveSessionsCount(response.data.sessions.length); } catch (error: unknown) { const apiError = parseApiError(error); logger.error('Failed to fetch sessions count', { message: apiError.message, }); setError(apiError.message); // Ne pas bloquer l'affichage si l'erreur survient setActiveSessionsCount(0); } finally { setLoading(false); } }; return (

Active Sessions

{loading ? ( Loading... ) : error ? ( Error ) : ( {activeSessionsCount} )}
); }