Implemented a simple page to view the currently registered users

This commit is contained in:
Tiago Ribeiro
2023-04-14 12:34:56 +01:00
parent 399e222791
commit f88db929f4
16 changed files with 433 additions and 32 deletions

49
src/pages/profile.tsx Normal file
View File

@@ -0,0 +1,49 @@
import {withIronSessionSsr} from "iron-session/next";
import {sessionOptions} from "@/lib/session";
import {User} from "@/interfaces/user";
import Head from "next/head";
import Navbar from "@/components/Navbar";
import {Avatar} from "primereact/avatar";
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
const user = req.session.user;
if (!user) {
res.setHeader("location", "/login");
res.statusCode = 302;
res.end();
return {
props: {
user: null,
},
};
}
return {
props: {user: req.session.user},
};
}, sessionOptions);
export default function Profile({user}: {user: User}) {
return (
<>
<Head>
<title>IELTS GPT | Profile</title>
<meta
name="description"
content="A training platform for the IELTS exam provided by the Muscat Training Institute and developed by eCrop."
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className="w-full h-screen flex flex-col items-center bg-neutral-100">
<Navbar profilePicture={user.profilePicture} />
<div className="w-full h-full flex flex-col items-center justify-center p-4 relative">
<section className="bg-white drop-shadow-xl p-4 rounded-xl w-96 flex flex-col items-center">
<Avatar image={user.profilePicture} size="xlarge" shape="circle" />
</section>
</div>
</main>
</>
);
}