add school year and security fix
Web Client CI/CD / Lint (ESLint + TypeScript) (push) Successful in 28s
Web Client CI/CD / Build (tsc + Vite) (push) Successful in 23s
Web Client CI/CD / Deploy to shared hosting (push) Successful in 33s

This commit is contained in:
root
2026-07-06 00:55:02 -04:00
parent 8cacd0874f
commit b74ddca8b1
27 changed files with 1258 additions and 39 deletions
+13
View File
@@ -1,4 +1,5 @@
import { apiUrl } from '../lib/apiOrigin'
import { selectedSchoolYearHeaders } from '../lib/schoolYearSelection'
const TOKEN_KEY = 'alrahma_api_token'
@@ -30,6 +31,14 @@ export function decodeJwtPayload<T = unknown>(token: string): T | null {
}
}
export function applyStoredSchoolYearHeaders(headers: Headers): Headers {
for (const [key, value] of Object.entries(selectedSchoolYearHeaders())) {
if (!headers.has(key)) headers.set(key, value)
}
return headers
}
export class ApiHttpError extends Error {
readonly status: number
readonly body: unknown
@@ -60,6 +69,10 @@ export async function apiFetch<T>(
headers.set('Authorization', `Bearer ${token}`)
}
if (attachAuth && token) {
applyStoredSchoolYearHeaders(headers)
}
const url = apiUrl(path)
let res: Response