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
@@ -2,6 +2,26 @@ function decodeJwt(token) {
return JSON.parse(atob(token.split('.')[1]));
}
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}`;
}
}
// Fire and forget.
applyActiveOscarYearToTitle();
// Check if the user is already logged in by looking for auth_token in localStorage
const existingToken = localStorage.getItem('auth_token');
if (existingToken) {