import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import { getDashboardData } from '$lib/server/dashboard';

export const load: PageServerLoad = async ({ locals }) => {
	if (!locals.member) {
		throw redirect(303, '/login');
	}

	const dashboard = await getDashboardData(locals.member.id);

	return {
		member: locals.member,
		dashboard
	};
};
