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 { useParams, useRouter } from "next/navigation"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
@@ -46,7 +47,7 @@ export default function StudentKundliPage() {
const [editExam, setEditExam] = useState("")
useEffect(() => {
fetch(`/api/admin/students/${studentId}`)
fetchWithAuth(`/api/admin/students/${studentId}`)
.then(r => { if (!r.ok) throw new Error("Not found"); return r.json() })
.then(d => {
setData(d)
@@ -62,7 +63,7 @@ export default function StudentKundliPage() {
const handleSave = async () => {
setSaving(true)
try {
const res = await fetch(`/api/admin/students/${studentId}`, {
const res = await fetchWithAuth(`/api/admin/students/${studentId}`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
@@ -74,7 +75,7 @@ export default function StudentKundliPage() {
})
if (!res.ok) throw new Error("Failed to save")
// Refresh data
const fresh = await fetch(`/api/admin/students/${studentId}`).then(r => r.json())
const fresh = await fetchWithAuth(`/api/admin/students/${studentId}`).then(r => r.json())
setData(fresh)
setEditing(false)
} catch (e: any) {