| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { Button } from '@mui/material';
- import { getSession, signOut, useSession } from 'next-auth/react';
- import ProfileContent from '../../components/profile-content/ProfileContent';
- import { LOGIN_PAGE } from '../../constants/pages';
-
- const ProfilePage = () => {
- const { data: session } = useSession();
-
- console.log(session);
-
- function logoutHandler() {
- signOut();
- }
- return (
- <>
- <ProfileContent></ProfileContent>
- <Button color="inherit" onClick={logoutHandler}>
- Logout
- </Button>
- </>
- );
- };
-
- export async function getServerSideProps(context) {
- const session = await getSession({ req: context.req });
-
- if (!session) {
- return {
- redirect: {
- destination: LOGIN_PAGE,
- permanent: false,
- },
- };
- }
-
- return {
- props: { session },
- };
- }
-
- export default ProfilePage;
|