diff --git a/src/dashboards/Owner.tsx b/src/dashboards/Owner.tsx new file mode 100644 index 00000000..b0c3e679 --- /dev/null +++ b/src/dashboards/Owner.tsx @@ -0,0 +1,89 @@ +import ProgressBar from "@/components/Low/ProgressBar"; +import ProfileSummary from "@/components/ProfileSummary"; +import useStats from "@/hooks/useStats"; +import useUsers from "@/hooks/useUsers"; +import {User} from "@/interfaces/user"; +import {MODULE_ARRAY} from "@/utils/moduleUtils"; +import {averageScore, groupBySession} from "@/utils/stats"; +import {capitalize} from "lodash"; +import moment from "moment"; +import { + BsBook, + BsFileEarmarkText, + BsGlobeCentralSouthAsia, + BsHeadphones, + BsMegaphone, + BsPen, + BsPencil, + BsPeopleFill, + BsPerson, + BsPersonFill, + BsPersonFillGear, + BsPersonGear, + BsPersonLinesFill, + BsStar, +} from "react-icons/bs"; + +interface Props { + user: User; +} + +export default function OwnerDashboard({user}: Props) { + const {stats} = useStats(user.id); + const {users} = useUsers(); + + return ( + <> +
+
+ + + Students + {users.filter((x) => x.type === "student").length} + +
+
+ + + Teachers + {users.filter((x) => x.type === "teacher").length} + +
+
+ + + Corporates + {users.filter((x) => x.type === "admin").length} + +
+
+ + + Countries + + {[...new Set(users.filter((x) => x.demographicInformation).map((x) => x.demographicInformation?.country))].length} + + +
+
+ + + Inactive Students + + {users.filter((x) => x.type === "student" && (x.isDisabled || moment().isAfter(x.subscriptionExpirationDate))).length} + + +
+
+ + + Inactive Corporates + + {users.filter((x) => x.type === "admin" && (x.isDisabled || moment().isAfter(x.subscriptionExpirationDate))).length} + + +
+
+ + ); +} diff --git a/src/pages/index.tsx b/src/pages/index.tsx index f1918d82..b2240c96 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -23,6 +23,7 @@ import Link from "next/link"; import {MODULE_ARRAY} from "@/utils/moduleUtils"; import ProfileSummary from "@/components/ProfileSummary"; import StudentDashboard from "@/dashboards/Student"; +import OwnerDashboard from "@/dashboards/Owner"; export const getServerSideProps = withIronSessionSsr(({req, res}) => { const user = req.session.user; @@ -164,7 +165,7 @@ export default function Home() { {user.type === "teacher" && } {user.type === "admin" && } {user.type === "owner" && } - {user.type === "developer" && } + {user.type === "developer" && } )}