add fixes to claims and seasons
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user