-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Gridiron Survivor. | ||
// Licensed under the MIT License. | ||
|
||
'use client'; | ||
import GlobalSpinner from '@/components/GlobalSpinner/GlobalSpinner'; | ||
import React, { useEffect, JSX } from 'react'; | ||
import { useAuthContext } from '@/context/AuthContextProvider'; | ||
import { useRouter } from 'next/navigation'; | ||
import Heading from '@/components/Heading/Heading'; | ||
|
||
/** | ||
* Renders the logout page. | ||
* @returns {React.JSX.Element} The rendered logout page. | ||
*/ | ||
const Logout = (): JSX.Element => { | ||
const { logoutAccount } = useAuthContext(); | ||
const router = useRouter(); | ||
|
||
useEffect(() => { | ||
/** | ||
* Handles the logout. | ||
* @returns {Promise<void>} The logout promise. | ||
*/ | ||
const handleLogout = async (): Promise<void> => { | ||
try { | ||
await logoutAccount(); | ||
router.push('/login'); | ||
} catch (error) { | ||
throw error; | ||
} | ||
}; | ||
|
||
handleLogout(); | ||
}, [logoutAccount, router]); | ||
|
||
return ( | ||
<> | ||
<section className="mx-auto max-w-5xl pt-10 text-center relative"> | ||
<div className="absolute top-0"> | ||
<Heading as="h2" className="text-2xl font-semibold mb-2"> | ||
Logging Out | ||
</Heading> | ||
<p className="text-muted-foreground"> | ||
Please wait while we securely log you out of your account... | ||
</p> | ||
</div> | ||
<GlobalSpinner /> | ||
</section> | ||
</> | ||
); | ||
}; | ||
|
||
export default Logout; |