import { fetchActorRevisions, fetchActorsById } from '#/src/actors.js';

export async function onBeforeRender(pageContext) {
	const [actor] = await fetchActorsById([Number(pageContext.routeParams.actorId)], {}, pageContext.user);

	const {
		revisions,
		avatars,
	} = await fetchActorRevisions(null, {
		actorId: actor.id,
		isFinalized: true,
		limit: 100,
	}, pageContext.user);

	return {
		pageContext: {
			title: `Revs for '${actor.name}'`,
			pageProps: {
				actor,
				revisions,
				avatars,
			},
		},
	};
}
