import type { LayoutServerLoad } from './$types';
import { listSubmissions } from '$lib/server/submissions';
import { unreadCount } from '$lib/server/notifications';

export const load: LayoutServerLoad = ({ locals, url }) => {
  const submissionsCount = locals.admin ? listSubmissions().length : 0;
  const unreadNotifications = locals.admin ? unreadCount() : 0;
  return {
    admin: locals.admin,
    pathname: url.pathname,
    submissionsCount,
    unreadNotifications
  };
};
