import type { PageServerLoad } from './$types';
import { redirect } from '@sveltejs/kit';
import { env } from '$env/dynamic/public';
import { StrikeReason } from '$lib/server/database';

export const load: PageServerLoad = async ({ parent }) => {
	const { reportCount } = await parent();
	if (reportCount == null) throw redirect(302, `${env.PUBLIC_BASE_PATH}/admin`);

	const { self } = await parent();

	return {
		strike_reasons: JSON.parse(JSON.stringify(await StrikeReason.findAll())),
		self: self
	};
};
