add fixes to claims and seasons

This commit is contained in:
JCEEE
2026-07-30 11:12:35 +01:00
parent 57ef30d3a7
commit b254564436
24 changed files with 2517 additions and 704 deletions
+27 -2
View File
@@ -1,4 +1,29 @@
export function load(event) {
import { SERVER_IP, PROXY_PORT } from '../../../../config.ts';
const HONO_URL = `http://${SERVER_IP}:${PROXY_PORT}`;
export async function load(event) {
const session = event.locals.session || null;
return { session, isParent: session !== null, role: session?.role || 'child' };
const isParent = session !== null;
let famId = '';
if (isParent) {
famId = session.famId;
} else {
const deviceToken = event.cookies.get('device_token') || '';
if (deviceToken) {
try {
const res = await fetch(`${HONO_URL}/api/members/seasons`, {
headers: { 'x-device-token': deviceToken },
});
if (res.ok) {
const body = await res.json();
famId = body.famId || '';
}
} catch {}
}
}
return { session, isParent, role: session?.role || 'child', famId };
}