feat(results): add resutls page

fix(leaderboard): fix leaderboard fetch logic

fix(test): fix navigation bug upon test quit
This commit is contained in:
shafin-r
2026-02-10 19:32:46 +06:00
parent 8cfcb11f0a
commit 7f82e640e0
17 changed files with 560 additions and 82 deletions

View File

@ -17,8 +17,8 @@ export const TargetedPractice = () => {
const navigate = useNavigate();
const {
storeTopics,
setDifficulty: storeDifficulty,
storeDuration,
setDifficulty: storeDifficulty,
setMode,
setQuestionCount,
} = useExamConfigStore();
@ -34,7 +34,6 @@ export const TargetedPractice = () => {
const [difficulty, setDifficulty] = useState<
"EASY" | "MEDIUM" | "HARD" | null
>(null);
const [duration, setDuration] = useState<number | null>(null);
const [search, setSearch] = useState("");
const [loading, setLoading] = useState<boolean>(false);
@ -43,8 +42,6 @@ export const TargetedPractice = () => {
const difficulties = ["EASY", "MEDIUM", "HARD"] as const;
const durations = [10, 20, 30, 45];
const toggleTopic = (topic: Topic) => {
setSelectedTopics((prev) => {
const exists = prev.some((t) => t.id === topic.id);
@ -58,7 +55,9 @@ export const TargetedPractice = () => {
};
async function handleStartTargetedPractice() {
if (!user || !token || !topics || !difficulty || !duration) return;
if (!user || !token || !topics || !difficulty) return;
storeDuration(10);
navigate(`/student/practice/${topics[0].id}/test`, { replace: true });
}
@ -193,36 +192,6 @@ export const TargetedPractice = () => {
setDifficulty(d); // local UI
storeDifficulty(d); // ✅ STORE
setDirection(1);
setStep("duration");
}}
/>
))}
</div>
</motion.div>
)}
{step === "duration" && (
<motion.div
key="duration"
custom={direction}
variants={slideVariants}
initial="initial"
animate="animate"
exit="exit"
className="space-y-4"
>
<h2 className="text-xl font-satoshi-bold">Select duration</h2>
<div className="grid grid-cols-1 md:grid-cols-4 gap-3">
{durations.map((d) => (
<ChoiceCard
key={d}
label={`${d} minutes`}
selected={duration === d}
onClick={() => {
setDuration(d);
storeDuration(d); // ✅ STORE
setDirection(1);
setStep("review");
}}
/>
@ -252,9 +221,6 @@ export const TargetedPractice = () => {
<p>
<strong>Difficulty:</strong> {difficulty}
</p>
<p>
<strong>Duration:</strong> {duration} minutes
</p>
</div>
</motion.div>
)}
@ -263,7 +229,7 @@ export const TargetedPractice = () => {
<button
disabled={step === "topic"}
onClick={() => {
const order: Step[] = ["topic", "difficulty", "duration", "review"];
const order: Step[] = ["topic", "difficulty", "review"];
setDirection(-1);
setStep(order[order.indexOf(step) - 1]);
}}