Added packages for students to be able to purchase

This commit is contained in:
Tiago Ribeiro
2023-11-26 10:08:57 +00:00
parent c312260721
commit 7e91a989b3
16 changed files with 552 additions and 35 deletions

View File

@@ -27,6 +27,8 @@ import AdminDashboard from "@/dashboards/Admin";
import CorporateDashboard from "@/dashboards/Corporate";
import TeacherDashboard from "@/dashboards/Teacher";
import AgentDashboard from "@/dashboards/Agent";
import PaymentDue from "./(status)/PaymentDue";
import {useRouter} from "next/router";
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
const user = req.session.user;
@@ -51,6 +53,8 @@ export default function Home() {
const [showDiagnostics, setShowDiagnostics] = useState(false);
const [showDemographicInput, setShowDemographicInput] = useState(false);
const {user, mutateUser} = useUser({redirectTo: "/login"});
const {stats} = useStats(user?.id);
const router = useRouter();
useEffect(() => {
if (user) {
@@ -68,7 +72,7 @@ export default function Home() {
return true;
};
if (user && (user.status === "disabled" || checkIfUserExpired())) {
if (user && (user.status === "paymentDue" || user.status === "disabled" || checkIfUserExpired())) {
return (
<>
<Head>
@@ -80,34 +84,15 @@ export default function Home() {
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<Layout user={user} navDisabled>
<div className="flex flex-col items-center justify-center text-center w-full gap-4">
{user.status === "disabled" ? (
<>
<span className="font-bold text-lg">Your account has been disabled!</span>
<span>Please contact an administrator if you believe this to be a mistake.</span>
</>
) : (
<>
<span className="font-bold text-lg">Your subscription has expired!</span>
<div className="flex flex-col items-center">
<span>
Please purchase a new time pack{" "}
<Link
className="font-bold text-mti-purple-light underline hover:text-mti-purple-dark transition ease-in-out duration-300"
href="https://encoach.com/join">
here
</Link>
.
</span>
<span className="max-w-md">
If you are not the one in charge of your subscription, please contact the one responsible to extend it.
</span>
</div>
</>
)}
</div>
</Layout>
{user.status === "disabled" && (
<Layout user={user} navDisabled>
<div className="flex flex-col items-center justify-center text-center w-full gap-4">
<span className="font-bold text-lg">Your account has been disabled!</span>
<span>Please contact an administrator if you believe this to be a mistake.</span>
</div>
</Layout>
)}
{(user.status === "paymentDue" || checkIfUserExpired()) && <PaymentDue user={user} reload={router.reload} />}
</>
);
}