import React from 'react' import { useRouter } from 'next/navigation' import { signOut } from 'next-auth/react' import Button from './ui/Button' import { IoExitOutline } from 'react-icons/io5' import useUserStore from '@/app/store/userStore' const Logout = () => { const API_URL = process.env.NEXT_PUBLIC_API_URL const router = useRouter() const handleLogout = async () => { try { // бекенд чистит куки await fetch(`${API_URL}/logout`, { method: 'POST', credentials: 'include', }) // чистим стор useUserStore.getState().logout() // если логин был гугловый await signOut({ redirect: false }) // редирект router.push('/') router.refresh() // обновляем страницу чтобы обновить стейты } catch (error) { console.error('Logout error:', error) } } return (