Added entity reporting.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { render } from 'vike/abort';
|
||||
|
||||
import { canReviewReports, fetchReports } from '#/src/reports.js';
|
||||
|
||||
export async function onBeforeRender(pageContext) {
|
||||
if (!canReviewReports(pageContext.user)) {
|
||||
throw render(404);
|
||||
}
|
||||
|
||||
const completed = pageContext.urlParsed.search.completed === 'true';
|
||||
const reports = await fetchReports({ completed }, pageContext.user);
|
||||
|
||||
return {
|
||||
pageContext: {
|
||||
title: 'Reports',
|
||||
pageProps: {
|
||||
reports,
|
||||
completed,
|
||||
},
|
||||
routeParams: {
|
||||
section: 'reports',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user