Public Access
- 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.
39 lines
777 B
TypeScript
39 lines
777 B
TypeScript
import { apiFetch } from '../utils/api.js'
|
|
|
|
export interface SetupStatus {
|
|
completed: boolean
|
|
siteTitle?: string
|
|
}
|
|
|
|
export function getSetupStatus(): Promise<SetupStatus> {
|
|
return apiFetch('/api/setup/status')
|
|
}
|
|
|
|
export interface SetupPayload {
|
|
email: string
|
|
password: string
|
|
displayName: string
|
|
smtpHost?: string
|
|
smtpPort?: string
|
|
smtpUser?: string
|
|
smtpPass?: string
|
|
smtpFrom?: string
|
|
smtpSecure?: string
|
|
appUrl?: string
|
|
}
|
|
|
|
export interface SetupResponse {
|
|
message: string
|
|
token: string
|
|
user: {
|
|
id: number
|
|
email: string
|
|
displayName: string
|
|
role: 'user' | 'admin'
|
|
}
|
|
}
|
|
|
|
export function completeSetup(data: SetupPayload): Promise<SetupResponse> {
|
|
return apiFetch('/api/setup', { method: 'POST', body: JSON.stringify(data) })
|
|
}
|