diff --git a/src/routes/b/[id]/+page.svelte b/src/routes/b/[id]/+page.svelte new file mode 100644 index 0000000..8a82783 --- /dev/null +++ b/src/routes/b/[id]/+page.svelte @@ -0,0 +1,27 @@ + + +{#if data.ban} + {#await fetchhandle(data.ban.did)} + fetching handle + {:then result} + {result.alsoKnownAs[0]} + {:catch} + error fetching handle + {/await} + ({data.ban.did}) was banned {smartAbsoluteTimestamp(data.ban.bannedAt)} + {#if data.ban.reason} + for {data.ban.reason}. + {/if} + {#if data.ban.till} + the ban will end on {dumbAbsoluteTimestamp(data.ban.till)}. + {/if} +{:else} + i can't find ban +{/if} diff --git a/src/routes/b/[id]/+page.ts b/src/routes/b/[id]/+page.ts new file mode 100644 index 0000000..afdb612 --- /dev/null +++ b/src/routes/b/[id]/+page.ts @@ -0,0 +1,27 @@ +import type { PageLoad } from './$types' + +export const load: PageLoad = async ({ params, fetch }) => { + const base = import.meta.env.VITE_API_URL + const query = `?id=${params.id}` + + const fetchSafely = async (url: string) => { + try { + const res = await fetch(url) + return res.ok ? await res.json() : null + } catch { + return null + } + } + + const [ban] = await Promise.allSettled([ + fetchSafely(`${base}/oauth/ban${query}`), + ]).then(results => + results.map(result => + result.status === 'fulfilled' ? result.value : null + ) + ) + + return { + ban, + } +}