feat: Add JWT authentication to backend, configure frontend API client, fix streak layout
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user