From bde5aea211e9838b4511a2b57c6a256fe89b66ab Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Thu, 17 Oct 2024 02:19:23 -0400 Subject: Get loaded data using `export let data`, instead of fishing around in $page. This is mostly a how-to-Svelte thing. I've also made the API responses for invites a bit more caller-friendly by flattening them and adding the ID field into them. The ID is redundant (the client knows it because the client has the invitation URL), but it makes presenting invitations and actioning them a bit easier. --- ui/routes/(login)/invite/[invite]/+page.js | 3 ++- ui/routes/(login)/invite/[invite]/+page.svelte | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'ui/routes') diff --git a/ui/routes/(login)/invite/[invite]/+page.js b/ui/routes/(login)/invite/[invite]/+page.js index d90f542..e6664d2 100644 --- a/ui/routes/(login)/invite/[invite]/+page.js +++ b/ui/routes/(login)/invite/[invite]/+page.js @@ -5,7 +5,8 @@ export async function load({ params }) { let response = await getInvite(invite); switch (response.status) { case 200: - return response.data; + let invite = response.data + return { invite }; break; case 404: return null; diff --git a/ui/routes/(login)/invite/[invite]/+page.svelte b/ui/routes/(login)/invite/[invite]/+page.svelte index eea05fc..b9a4a97 100644 --- a/ui/routes/(login)/invite/[invite]/+page.svelte +++ b/ui/routes/(login)/invite/[invite]/+page.svelte @@ -1,20 +1,18 @@ -

Hi there! {invite.issuer.name} invites you to the conversation.

+{#await data} +

Loading invitation…

+{:then { invite }} +

Hi there! {invite.issuer} invites you to the conversation.

+{/await} -- cgit v1.2.3