feat(error): add error handling on test screen

This commit is contained in:
shafin-r
2026-02-07 20:21:47 +06:00
parent c9db96f97f
commit 8cfcb11f0a
4 changed files with 52 additions and 48 deletions

View File

@ -37,6 +37,7 @@ import type { Leaderboard } from "../../types/leaderboard";
import { api } from "../../utils/api";
import { Card, CardContent } from "../../components/ui/card";
import { LeaderboardRowSkeleton } from "../../components/LeaderboardSkeleton";
import { useExamConfigStore } from "../../stores/useExamConfigStore";
export const Rewards = () => {
const user = useAuthStore((state) => state.user);
@ -45,6 +46,8 @@ export const Rewards = () => {
const [leaderboard, setLeaderboard] = useState<Leaderboard>();
const [loading, setLoading] = useState<boolean>(false);
const { setUserXp } = useExamConfigStore();
useEffect(() => {
const fetchLeaderboard = async () => {
if (!user) return;
@ -64,6 +67,7 @@ export const Rewards = () => {
const response = await api.fetchLeaderboard(token);
setLeaderboard(response);
setUserXp(response.user_rank.total_xp);
setLoading(false);
} catch (error) {
setLoading(false);