Navigation rework, added prompt edit to components that were missing
This commit is contained in:
@@ -20,7 +20,7 @@ import {shouldRedirectHome} from "@/utils/navigation.disabled";
|
||||
import {sessionOptions} from "@/lib/session";
|
||||
import qs from "qs";
|
||||
import StatsGridItem from "@/components/Medium/StatGridItem";
|
||||
import useExamStore from "@/stores/examStore";
|
||||
import useExamStore from "@/stores/exam";
|
||||
import {usePDFDownload} from "@/hooks/usePDFDownload";
|
||||
import useAssignments from "@/hooks/useAssignments";
|
||||
import useUsers from "@/hooks/useUsers";
|
||||
@@ -29,7 +29,6 @@ import InfiniteCarousel from "@/components/InfiniteCarousel";
|
||||
import {LuExternalLink} from "react-icons/lu";
|
||||
import {uniqBy} from "lodash";
|
||||
import {getExamById} from "@/utils/exams";
|
||||
import {convertToUserSolutions} from "@/utils/stats";
|
||||
import {sortByModule} from "@/utils/moduleUtils";
|
||||
import { requestUser } from "@/utils/api";
|
||||
import { redirect, serialize } from "@/utils";
|
||||
@@ -46,15 +45,10 @@ export const getServerSideProps = withIronSessionSsr(async ({req, res}) => {
|
||||
}, sessionOptions);
|
||||
|
||||
const TrainingContent: React.FC<{user: User}> = ({user}) => {
|
||||
// Record stuff
|
||||
const setExams = useExamStore((state) => state.setExams);
|
||||
const setShowSolutions = useExamStore((state) => state.setShowSolutions);
|
||||
const setUserSolutions = useExamStore((state) => state.setUserSolutions);
|
||||
const setSelectedModules = useExamStore((state) => state.setSelectedModules);
|
||||
const setInactivity = useExamStore((state) => state.setInactivity);
|
||||
const setTimeSpent = useExamStore((state) => state.setTimeSpent);
|
||||
const renderPdfIcon = usePDFDownload("stats");
|
||||
|
||||
const dispatch = useExamStore((s) => s.dispatch);
|
||||
|
||||
const [trainingContent, setTrainingContent] = useState<ITrainingContent | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [trainingTips, setTrainingTips] = useState<ITrainingTip[]>([]);
|
||||
@@ -125,17 +119,18 @@ const TrainingContent: React.FC<{user: User}> = ({user}) => {
|
||||
|
||||
Promise.all(examPromises).then((exams) => {
|
||||
if (exams.every((x) => !!x)) {
|
||||
if (!!timeSpent) setTimeSpent(timeSpent);
|
||||
if (!!inactivity) setInactivity(inactivity);
|
||||
setUserSolutions(convertToUserSolutions(stats));
|
||||
setShowSolutions(true);
|
||||
setExams(exams.map((x) => x!).sort(sortByModule));
|
||||
setSelectedModules(
|
||||
exams
|
||||
.map((x) => x!)
|
||||
.sort(sortByModule)
|
||||
.map((x) => x!.module),
|
||||
);
|
||||
dispatch({
|
||||
type: 'INIT_SOLUTIONS', payload: {
|
||||
exams: exams.map((x) => x!).sort(sortByModule),
|
||||
modules: exams
|
||||
.map((x) => x!)
|
||||
.sort(sortByModule)
|
||||
.map((x) => x!.module),
|
||||
stats,
|
||||
timeSpent,
|
||||
inactivity
|
||||
}
|
||||
});
|
||||
router.push("/exam");
|
||||
}
|
||||
});
|
||||
@@ -185,12 +180,6 @@ const TrainingContent: React.FC<{user: User}> = ({user}) => {
|
||||
user={user}
|
||||
assignments={assignments}
|
||||
users={users}
|
||||
setExams={setExams}
|
||||
setShowSolutions={setShowSolutions}
|
||||
setUserSolutions={setUserSolutions}
|
||||
setSelectedModules={setSelectedModules}
|
||||
setInactivity={setInactivity}
|
||||
setTimeSpent={setTimeSpent}
|
||||
renderPdfIcon={renderPdfIcon}
|
||||
/>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user