feat: Update user profile handling and enhance public user details response

This commit is contained in:
Sean Morley
2025-01-29 22:50:53 -05:00
parent b68e2dedaa
commit 85b55660f9
10 changed files with 274 additions and 212 deletions

View File

@@ -0,0 +1,40 @@
import { redirect, error } from '@sveltejs/kit';
import type { PageServerLoad, RequestEvent } from '../../$types';
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
export const load: PageServerLoad = async (event: RequestEvent) => {
const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
let uuid = event.params.uuid as string;
if (!uuid) {
return error(404, 'Not found');
}
// let sessionId = event.cookies.get('sessionid');
// let stats = null;
// let res = await event.fetch(`${endpoint}/api/stats/counts/`, {
// headers: {
// Cookie: `sessionid=${sessionId}`
// }
// });
// if (!res.ok) {
// console.error('Failed to fetch user stats');
// } else {
// stats = await res.json();
// }
let userData = await event.fetch(`${endpoint}/auth/user/${uuid}/`);
if (!userData.ok) {
return error(404, 'Not found');
}
let data = await userData.json();
return {
user: data.user,
adventures: data.adventures,
collections: data.collections
};
};