Refactor: Update brand name and dynamic titles

Consistently use "Oscar Pool" as the brand name. Dynamically update page titles to include the active Oscar year.

Co-authored-by: mathieumoran1 <[email protected]>
This commit is contained in:
Cursor Agent
2025-12-22 07:31:26 +00:00
co-authored by mathieumoran1
parent 88129ca5ac
commit 76e9a934d6
16 changed files with 98 additions and 37 deletions
+20
View File
@@ -7,7 +7,27 @@ function isTokenExpired(decoded) {
return !!decoded.exp && decoded.exp < currentTime;
}
async function applyActiveOscarYearToTitle() {
const base = 'Oscar Pool';
const current = String(document.title || base);
const sep = ' - ';
const idx = current.indexOf(sep);
const suffix = idx >= 0 ? current.slice(idx) : '';
try {
const res = await fetch('/api/settings/year', { method: 'GET' });
const data = res.ok ? await res.json().catch(() => null) : null;
const year = Number(data?.year);
document.title = Number.isInteger(year) ? `${base} (${year})${suffix}` : `${base}${suffix}`;
} catch (_) {
document.title = `${base}${suffix}`;
}
}
window.onload = function () {
// Best-effort: update page title with active year.
applyActiveOscarYearToTitle();
const token = localStorage.getItem('auth_token');
if (!token) {
window.location.href = '/';