diff --git a/src/dashboards/Student.tsx b/src/dashboards/Student.tsx new file mode 100644 index 00000000..ec1e4562 --- /dev/null +++ b/src/dashboards/Student.tsx @@ -0,0 +1,80 @@ +import ProgressBar from "@/components/Low/ProgressBar"; +import ProfileSummary from "@/components/ProfileSummary"; +import useStats from "@/hooks/useStats"; +import {User} from "@/interfaces/user"; +import {MODULE_ARRAY} from "@/utils/moduleUtils"; +import {averageScore, groupBySession} from "@/utils/stats"; +import {capitalize} from "lodash"; +import {BsBook, BsFileEarmarkText, BsHeadphones, BsMegaphone, BsPen, BsPencil, BsStar} from "react-icons/bs"; + +interface Props { + user: User; +} + +export default function StudentDashboard({user}: Props) { + const {stats} = useStats(user.id); + + return ( + <> + , + value: Object.keys(groupBySession(stats)).length, + label: "Exams", + }, + { + icon: , + value: stats.length, + label: "Exercises", + }, + { + icon: , + value: `${stats.length > 0 ? averageScore(stats) : 0}%`, + label: "Average Score", + }, + ]} + /> + +
+ Bio + + {user.bio || "Your bio will appear here, you can change it by clicking on your name in the top right corner."} + +
+ +
+ Score History +
+ {MODULE_ARRAY.map((module) => ( +
+
+
+ {module === "reading" && } + {module === "listening" && } + {module === "writing" && } + {module === "speaking" && } +
+
+ {capitalize(module)} + + Level {user.levels[module]} / Level {user.desiredLevels[module]} + +
+
+
+ +
+
+ ))} +
+
+ + ); +} diff --git a/src/pages/index.tsx b/src/pages/index.tsx index cd92b33a..f1918d82 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -22,6 +22,7 @@ import moment from "moment"; import Link from "next/link"; import {MODULE_ARRAY} from "@/utils/moduleUtils"; import ProfileSummary from "@/components/ProfileSummary"; +import StudentDashboard from "@/dashboards/Student"; export const getServerSideProps = withIronSessionSsr(({req, res}) => { const user = req.session.user; @@ -46,7 +47,6 @@ 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); useEffect(() => { if (user) { @@ -160,65 +160,11 @@ export default function Home() { {user && ( - , - value: Object.keys(groupBySession(stats)).length, - label: "Exams", - }, - { - icon: , - value: stats.length, - label: "Exercises", - }, - { - icon: , - value: `${stats.length > 0 ? averageScore(stats) : 0}%`, - label: "Average Score", - }, - ]} - /> - -
- Bio - - {user.bio || "Your bio will appear here, you can change it by clicking on your name in the top right corner."} - -
- -
- Score History -
- {MODULE_ARRAY.map((module) => ( -
-
-
- {module === "reading" && } - {module === "listening" && } - {module === "writing" && } - {module === "speaking" && } -
-
- {capitalize(module)} - - Level {user.levels[module]} / Level {user.desiredLevels[module]} - -
-
-
- -
-
- ))} -
-
+ {user.type === "student" && } + {user.type === "teacher" && } + {user.type === "admin" && } + {user.type === "owner" && } + {user.type === "developer" && }
)}