Fix Admin test upload API endpoint URL & fix AI coach infinite reload caused by session polling

This commit is contained in:
2026-07-09 17:53:27 +05:30
parent 3cc72cb327
commit 4a899f63e8
2 changed files with 6 additions and 6 deletions

View File

@@ -27,7 +27,7 @@ export default function AdminTestsPage() {
const fetchTests = async () => { const fetchTests = async () => {
try { try {
const res = await fetch("http://localhost:8000/api/admin/tests") const res = await fetch("/api/admin/tests")
if (res.ok) { if (res.ok) {
const data = await res.json() const data = await res.json()
setTests(data) setTests(data)
@@ -83,7 +83,7 @@ export default function AdminTestsPage() {
}; };
try { try {
const res = await fetch("http://localhost:8000/api/admin/tests/create_manual", { const res = await fetch("/api/admin/tests/upload", {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload) body: JSON.stringify(payload)

View File

@@ -41,8 +41,8 @@ export function useActiveUser() {
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const fetchUserProfile = useCallback(async (id: string) => { const fetchUserProfile = useCallback(async (id: string, isPoll: boolean = false) => {
setLoading(true); if (!isPoll) setLoading(true);
setError(null); setError(null);
try { try {
const res = await fetch(`/api/users/${id}`); const res = await fetch(`/api/users/${id}`);
@@ -71,7 +71,7 @@ export function useActiveUser() {
console.error("Error fetching active user profile:", err); console.error("Error fetching active user profile:", err);
setError(err.message || "Failed to load user"); setError(err.message || "Failed to load user");
} finally { } finally {
setLoading(false); if (!isPoll) setLoading(false);
} }
}, []); }, []);
@@ -90,7 +90,7 @@ export function useActiveUser() {
// Poll every 10 seconds for session validity // Poll every 10 seconds for session validity
const interval = setInterval(() => { const interval = setInterval(() => {
fetchUserProfile(userId); fetchUserProfile(userId, true);
}, 10000); }, 10000);
return () => { return () => {