12345678910111213141516171819202122232425262728293031 |
- import { GetServerSideProps, NextPage } from 'next';
- import { Session } from 'next-auth';
- import { getSession, useSession } from 'next-auth/react';
- import ProfileCard from '../../components/cards/profile-card/ProfileCard';
- import { LOGIN_PAGE } from '../../constants/pages';
-
- interface IProp {
- session: Session;
- }
- const ProfilePage: NextPage<IProp> = (props) => {
- return <ProfileCard profileData={{ name: props.session.user!.name }} />;
- };
-
- export const getServerSideProps: GetServerSideProps = async (context) => {
- const session = await getSession({ req: context.req });
-
- if (!session) {
- return {
- redirect: {
- destination: LOGIN_PAGE,
- permanent: false,
- },
- };
- }
-
- return {
- props: { session },
- };
- };
-
- export default ProfilePage;
|