Public Access
feat: Implement API modules for admin, auth, exam, result, and setup functionalities
- Created adminApi.ts for admin-related operations including user management and site settings. - Developed authApi.ts for authentication processes such as registration, login, and profile management. - Added examApi.ts for handling exam CRUD operations. - Introduced resultApi.ts for managing results submission and retrieval. - Established setupApi.ts for initial setup processes and status checks. - Created ErrorBoundary component to handle rendering errors gracefully in the frontend. - Re-exported shared API utilities in index.ts for easier access.
This commit is contained in:
1 parent
62af83ce53
commit
c64cdcd9e3
46 files changed
+2227
-1125
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { apiFetch } from '../utils/api'
|
||||
import type { Exam } from '../types'
|
||||
import * as examApi from '../api/examApi'
|
||||
|
||||
interface SavedExam {
|
||||
id: number
|
||||
@@ -23,7 +22,7 @@ export default function MyExams() {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
try {
|
||||
const data = await apiFetch<SavedExam[]>('/api/exams')
|
||||
const data = await examApi.listExams()
|
||||
setExams(data)
|
||||
} catch (e) {
|
||||
setError((e as Error).message)
|
||||
@@ -38,7 +37,7 @@ export default function MyExams() {
|
||||
|
||||
const deleteExam = async (id: number) => {
|
||||
try {
|
||||
await apiFetch(`/api/exams/${id}`, { method: 'DELETE' })
|
||||
await examApi.deleteExam(id)
|
||||
setDeleteConfirm(null)
|
||||
void loadExams()
|
||||
} catch (e) {
|
||||
|
||||
Reference in new issue
Block a user