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

export const load: PageServerLoad = async ({ locals, fetch }) => {
  const session = await locals.auth();
  if (!session) throw redirect(302, '/login');

  const statsRes = await fetch('/api/tasks/stats');

  return {
    session,
    stats: await statsRes.json()
  };
};
