From 09cb438e0ce113a70aee09a3529fd145bd5f3456 Mon Sep 17 00:00:00 2001 From: nameless Date: Fri, 10 Nov 2023 02:38:10 +0000 Subject: [PATCH] feat: new admin page --- ui/AdminsPage.tsx | 80 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/ui/AdminsPage.tsx b/ui/AdminsPage.tsx index aa98707..37fcf23 100644 --- a/ui/AdminsPage.tsx +++ b/ui/AdminsPage.tsx @@ -160,42 +160,72 @@ function AdminListItem(props: { admin: AdminData; sessionId: string | null }) { : null, (args) => fetchApi(...args).then(handleResponse), ); + const getAdminPhoto = useSWR( + ["users/{userId}/photo", "GET", { params: { userId: String(admin.tgUserId) } }] as const, + (args) => fetchApi(...args).then(handleResponse).then((blob) => URL.createObjectURL(blob)), + ); return ( -
  • -

    - {getAdminUser.data?.first_name ?? admin.id} {getAdminUser.data?.last_name}{" "} - {getAdminUser.data?.username +

    +
    + {/* user avatar */} + {getAdminUser.data ? ( - - @{getAdminUser.data.username} - + getAdminPhoto.data + ? ( + avatar + ) + : ( +
    + {getAdminUser.data.first_name.at(0)?.toUpperCase()} +
    + ) ) : null} -

    - {getAdminUser.data?.bio - ? ( -

    - {getAdminUser.data?.bio} -

    - ) - : null} - {getUser.data?.admin && ( -

    - +

    +
    +
    + {getAdminUser.data?.first_name ?? admin.id} {getAdminUser.data?.last_name} +
    +

    + {getAdminUser.data?.username + ? ( + + @{getAdminUser.data.username} + + ) + : null}

    - )} + + {getAdminUser.data?.bio + ? ( +

    + {getAdminUser.data?.bio} +

    + ) + : null} +
    + {getUser.data?.admin && ( +

    + +

    + )} +
    -
  • + ); }