Added the ability to create an agent using the CodeGenerator

This commit is contained in:
Tiago Ribeiro
2023-11-21 13:24:07 +00:00
parent 51e7c535df
commit 8072cefbe6
9 changed files with 55 additions and 77 deletions

76
src/pages/settings.tsx Normal file
View File

@@ -0,0 +1,76 @@
/* eslint-disable @next/next/no-img-element */
import Head from "next/head";
import {withIronSessionSsr} from "iron-session/next";
import {sessionOptions} from "@/lib/session";
import useUser from "@/hooks/useUser";
import {ToastContainer} from "react-toastify";
import Layout from "@/components/High/Layout";
import CodeGenerator from "./(admin)/CodeGenerator";
import ExamLoader from "./(admin)/ExamLoader";
import {Tab} from "@headlessui/react";
import clsx from "clsx";
import Lists from "./(admin)/Lists";
import BatchCodeGenerator from "./(admin)/BatchCodeGenerator";
import {shouldRedirectHome} from "@/utils/navigation.disabled";
import ExamGenerator from "./(admin)/ExamGenerator";
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
const user = req.session.user;
if (!user || !user.isVerified) {
res.setHeader("location", "/login");
res.statusCode = 302;
res.end();
return {
props: {
user: null,
},
};
}
if (shouldRedirectHome(user) || user.type !== "developer") {
res.setHeader("location", "/");
res.statusCode = 302;
res.end();
return {
props: {
user: null,
},
};
}
return {
props: {user: req.session.user},
};
}, sessionOptions);
export default function Admin() {
const {user} = useUser({redirectTo: "/login"});
return (
<>
<Head>
<title>Settings Panel | 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>
<ToastContainer />
{user && (
<Layout user={user} className="gap-6">
<section className="w-full flex -lg:flex-col -xl:gap-2 gap-8 justify-between">
<ExamLoader />
<CodeGenerator user={user} />
<BatchCodeGenerator user={user} />
</section>
<section className="w-full">
<Lists user={user} />
</section>
</Layout>
)}
</>
);
}