start user pages
This commit is contained in:
parent
ef221b2c45
commit
2915893049
7 changed files with 29 additions and 12 deletions
|
@ -21,11 +21,6 @@ public class UsersController(
|
||||||
public async Task<IActionResult> GetUserAsync(string userRef)
|
public async Task<IActionResult> GetUserAsync(string userRef)
|
||||||
{
|
{
|
||||||
var user = await db.ResolveUserAsync(userRef, CurrentToken);
|
var user = await db.ResolveUserAsync(userRef, CurrentToken);
|
||||||
return await GetUserInnerAsync(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<IActionResult> GetUserInnerAsync(User user)
|
|
||||||
{
|
|
||||||
return Ok(await userRendererService.RenderUserAsync(
|
return Ok(await userRendererService.RenderUserAsync(
|
||||||
user,
|
user,
|
||||||
selfUser: CurrentUser,
|
selfUser: CurrentUser,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { page } from "$app/stores";
|
import { page } from "$app/stores";
|
||||||
import neofox from "./neofox_confused_2048.png";
|
import neofox from "./neofox_confused_2048.png";
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -9,5 +9,5 @@ export async function load({ fetch, locals }) {
|
||||||
user = await request<User>(fetch, "GET", "/users/@me");
|
user = await request<User>(fetch, "GET", "/users/@me");
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
return { meta, user, token: locals.token };
|
return { meta, currentUser: user, token: locals.token };
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,5 @@
|
||||||
export let data: LayoutData;
|
export let data: LayoutData;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Navbar user={data.user} />
|
<Navbar user={data.currentUser} />
|
||||||
<slot />
|
<slot />
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
|
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
are you logged in? {data.user !== undefined}
|
are you logged in? {data.currentUser !== undefined}
|
||||||
{#if data.user}
|
{#if data.currentUser}
|
||||||
<br />hello, {data.user.username}!
|
<br />hello, {data.currentUser.username}!
|
||||||
<br />your ID: {data.user.id}
|
<br />your ID: {data.currentUser.id}
|
||||||
{/if}
|
{/if}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
12
Foxnouns.Frontend/src/routes/@[username]/+page.server.ts
Normal file
12
Foxnouns.Frontend/src/routes/@[username]/+page.server.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { error } from "@sveltejs/kit";
|
||||||
|
import type { User } from "$lib/api/user";
|
||||||
|
import request from "$lib/request";
|
||||||
|
|
||||||
|
export const load = async ({ params, fetch }) => {
|
||||||
|
try {
|
||||||
|
const user = await request<User>(fetch, "GET", `/users/${params.username}`);
|
||||||
|
return { user };
|
||||||
|
} catch {
|
||||||
|
error(404, { message: "User not found" });
|
||||||
|
}
|
||||||
|
};
|
10
Foxnouns.Frontend/src/routes/@[username]/+page.svelte
Normal file
10
Foxnouns.Frontend/src/routes/@[username]/+page.svelte
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import type { PageData } from "./$types";
|
||||||
|
export let data: PageData;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>@{data.user.username} • pronouns.cc</title>
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
|
<h1>this is the user page for @{data.user.username}</h1>
|
Loading…
Reference in a new issue