logout.tsx29 lines · main
| 1 | import { useRouter } from 'next/router' |
| 2 | import { useEffect } from 'react' |
| 3 | import { toast } from 'sonner' |
| 4 | import { LogoLoader } from 'ui' |
| 5 | |
| 6 | import { useSignOut } from '@/lib/auth' |
| 7 | import type { NextPageWithLayout } from '@/types' |
| 8 | |
| 9 | const LogoutPage: NextPageWithLayout = () => { |
| 10 | const router = useRouter() |
| 11 | const signOut = useSignOut() |
| 12 | |
| 13 | useEffect(() => { |
| 14 | const logout = async () => { |
| 15 | await signOut() |
| 16 | toast('Successfully logged out') |
| 17 | await router.push('/sign-in') |
| 18 | } |
| 19 | logout() |
| 20 | }, []) |
| 21 | |
| 22 | return ( |
| 23 | <div className="w-full h-screen flex items-center justify-center"> |
| 24 | <LogoLoader /> |
| 25 | </div> |
| 26 | ) |
| 27 | } |
| 28 | |
| 29 | export default LogoutPage |