feat(frontend): add profile page and public user profile page
/profile: two-card layout with personal info form (name, birth date, email, contact) and password change form, each with independent actions. /users/[id]: read-only public view showing name, username, email, contact with avatar circle initials. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
16
frontend/src/routes/users/[id]/+page.server.ts
Normal file
16
frontend/src/routes/users/[id]/+page.server.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { createApiClient } from '$lib/api.server';
|
||||
import { getErrorMessage } from '$lib/errors';
|
||||
|
||||
export const load: PageServerLoad = async ({ params, fetch }) => {
|
||||
const api = createApiClient(fetch);
|
||||
const result = await api.GET('/api/users/{id}', { params: { path: { id: params.id } } });
|
||||
|
||||
if (!result.response.ok) {
|
||||
const code = (result.error as unknown as { code?: string })?.code;
|
||||
throw error(result.response.status, getErrorMessage(code));
|
||||
}
|
||||
|
||||
return { profileUser: result.data! };
|
||||
};
|
||||
Reference in New Issue
Block a user