51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
/* eslint-disable @next/next/no-img-element */
|
|
|
|
import {withIronSessionSsr} from "iron-session/next";
|
|
import {sessionOptions} from "@/lib/session";
|
|
import {shouldRedirectHome} from "@/utils/navigation.disabled";
|
|
import ExamPage from "./(exam)/ExamPage";
|
|
import Head from "next/head";
|
|
|
|
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
|
const user = req.session.user;
|
|
|
|
if (!user || !user.isVerified) {
|
|
return {
|
|
redirect: {
|
|
destination: "/login",
|
|
permanent: false,
|
|
}
|
|
};
|
|
}
|
|
|
|
if (shouldRedirectHome(user)) {
|
|
return {
|
|
redirect: {
|
|
destination: "/",
|
|
permanent: false,
|
|
}
|
|
};
|
|
}
|
|
|
|
return {
|
|
props: {user: req.session.user},
|
|
};
|
|
}, sessionOptions);
|
|
|
|
export default function Page() {
|
|
return (
|
|
<>
|
|
<Head>
|
|
<title>Exercises | EnCoach</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>
|
|
<ExamPage page="exercises" />
|
|
</>
|
|
);
|
|
}
|