import {User} from "@/interfaces/user";
import {sessionOptions} from "@/lib/session";
import {withIronSessionSsr} from "iron-session/next";

export const getServerSideProps = withIronSessionSsr(async ({req, res}) => {
	const user = req.session.user as User | undefined;

	if (!user) {
		return {
			redirect: {
				destination: "/login",
				permanent: false,
			},
		};
	}

	return {
		redirect: {
			destination: `/dashboard/${user.type}`,
			permanent: false,
		},
	};
}, sessionOptions);

export default function Dashboard() {
	return <div></div>;
}
