feat: Add JWT authentication to backend, configure frontend API client, fix streak layout

This commit is contained in:
2026-09-23 12:11:44 +05:30
parent ea03846b9c
commit a3e430cb67
27 changed files with 210 additions and 120 deletions

View File

@@ -1,5 +1,6 @@
"use client";
import { fetchWithAuth } from "@/lib/apiClient";
import { useEffect, useState } from "react";
import Link from "next/link";
import { Button } from "@/components/ui/button";
@@ -37,7 +38,7 @@ export default function CBTPage() {
async function loadUser() {
try {
const userRes = await fetch(`/api/users/${userId}`);
const userRes = await fetchWithAuth(`/api/users/${userId}`);
if (!userRes.ok) throw new Error("Failed to load user target exam");
const userData = await userRes.json();
const pattern = userData.target_exam;
@@ -75,7 +76,7 @@ export default function CBTPage() {
setExams(testsData);
}
const attemptsRes = await fetch(`/api/users/${userId}/attempts`);
const attemptsRes = await fetchWithAuth(`/api/users/${userId}/attempts`);
if (attemptsRes.ok) {
const attemptsData = await attemptsRes.json();
setAttempts(attemptsData);