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:
LaurensBartelds committed 2026-04-26 20:10:46 +02:00
1 parent 62af83ce53
commit c64cdcd9e3
46 files changed
+2227 -1125

No files matched your search

+13 -24
View File
@@ -1,5 +1,6 @@
import { useState } from 'react'
import { apiFetch, setToken } from '../utils/api'
import { setToken } from '../utils/api'
import * as setupApi from '../api/setupApi'
interface Props {
onComplete: () => void
@@ -51,29 +52,17 @@ export default function SetupWizard({ onComplete }: Readonly<Props>) {
setError(null)
setSubmitting(true)
try {
const data = await apiFetch<{
message: string
token: string
user: {
id: number
email: string
displayName: string
role: 'user' | 'admin'
}
}>('/api/setup', {
method: 'POST',
body: JSON.stringify({
email,
password,
displayName: displayName.trim(),
smtpHost,
smtpPort,
smtpUser,
smtpPass,
smtpFrom: smtpFrom || 'BrainWave <noreply@brainwave.local>',
smtpSecure,
appUrl,
}),
const data = await setupApi.completeSetup({
email,
password,
displayName: displayName.trim(),
smtpHost,
smtpPort,
smtpUser,
smtpPass,
smtpFrom: smtpFrom || 'BrainWave <noreply@brainwave.local>',
smtpSecure,
appUrl,
})
setToken(data.token)
onComplete()