'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { Card, Button } from '@zen/core/shared/components'; import AuthPageHeader from '../components/AuthPageHeader.js'; export default function LogoutPage({ onLogout, onSetSessionCookie }) { const [error, setError] = useState(''); const [success, setSuccess] = useState(''); const [isLoading, setIsLoading] = useState(false); const router = useRouter(); const handleLogout = async () => { setError(''); setSuccess(''); setIsLoading(true); try { if (onLogout) { const result = await onLogout(); if (result && !result.success) { setError(result.error || 'Échec de la déconnexion'); setIsLoading(false); return; } } if (onSetSessionCookie) { await onSetSessionCookie('', { expires: new Date(0) }); } setSuccess('Vous avez été déconnecté. Redirection...'); setIsLoading(false); setTimeout(() => router.push('/'), 100); } catch (err) { console.error('Logout error:', err); setError('Une erreur inattendue s\'est produite lors de la déconnexion'); setIsLoading(false); } }; return ( {success && (
{success}
)} {error && !success && (
{error}
)}
Vous avez changé d'avis ? Retour
); }