import type { LayoutServerLoad } from './$types';

export const load: LayoutServerLoad = async ({ locals }) => {
	const groups: { permissions: string[] }[] = locals.user?.groups ?? [];
	return {
		user: locals.user,
		canWrite: groups.some((g) => g.permissions.includes('WRITE_ALL')),
		canAnnotate: groups.some(
			(g) => g.permissions.includes('WRITE_ALL') || g.permissions.includes('ANNOTATE_ALL')
		),
		canBlogWrite: groups.some((g) => g.permissions.includes('BLOG_WRITE'))
	};
};
