From e7277585d08416f8d9894d3c539d940aeb6d08aa Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Tue, 9 Apr 2024 21:26:05 +0100 Subject: [PATCH] Error page for user --- src/pages/u/[username]/index.astro | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/pages/u/[username]/index.astro b/src/pages/u/[username]/index.astro index e96280c70..0dcdaa62c 100644 --- a/src/pages/u/[username]/index.astro +++ b/src/pages/u/[username]/index.astro @@ -1,4 +1,5 @@ --- +import { FrownIcon } from 'lucide-react'; import { userApi } from '../../../api/user'; import AccountLayout from '../../../layouts/AccountLayout.astro'; import { UserPublicProfilePage } from '../../../components/UserPublicProfile/UserPublicProfilePage'; @@ -16,11 +17,34 @@ const userClient = userApi(Astro as any); const { response: userDetails, error } = await userClient.getPublicProfile(username); +let errorMessage = ''; if (error || !userDetails) { - return Astro.redirect('/404'); + errorMessage = error?.message || 'User not found'; } --- - - + + {!errorMessage && } + { + errorMessage && ( +
+ + + 😞 + +

Problem loading user!

+

+ {errorMessage} +

+
+ ) + }