Added remaining elements to alert dialog.

This commit is contained in:
2024-05-19 05:07:35 +02:00
parent 715e5ac58a
commit 014758241c
22 changed files with 1210 additions and 30 deletions

View File

@@ -1,11 +1,17 @@
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
import { fetchUser } from '#/src/users.js';
import { fetchAlerts } from '#/src/alerts.js';
export async function onBeforeRender(pageContext) {
const profile = await fetchUser(pageContext.routeParams.username, {}, pageContext.user);
const [profile, alerts] = await Promise.all([
fetchUser(pageContext.routeParams.username, {}, pageContext.user),
pageContext.routeParams.username === pageContext.user?.username
? fetchAlerts(pageContext.user)
: [],
]);
// console.log(profile);
console.log('out alerts', alerts);
if (!profile) {
throw render(404, `Cannot find user '${pageContext.routeParams.username}'.`);
@@ -16,6 +22,7 @@ export async function onBeforeRender(pageContext) {
title: profile.username,
pageProps: {
profile, // differentiate from authed 'user'
alerts,
},
},
};