forked from pinks/eris
1
0
Fork 0

Compare commits

...

1 Commits

Author SHA1 Message Date
nameless 09cb438e0c feat: new admin page 2023-11-10 02:38:10 +00:00
1 changed files with 55 additions and 25 deletions

View File

@ -160,42 +160,72 @@ function AdminListItem(props: { admin: AdminData; sessionId: string | null }) {
: null, : null,
(args) => fetchApi(...args).then(handleResponse), (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 ( return (
<li className="flex flex-col gap-2 rounded-md bg-zinc-100 dark:bg-zinc-800 p-2"> <div className="max-h-sm rounded-md bg-zinc-100 dark:bg-zinc-800">
<p className="font-bold"> <div className="float-left flex flex-col p-10">
{getAdminUser.data?.first_name ?? admin.id} {getAdminUser.data?.last_name}{" "} {/* user avatar */}
{getAdminUser.data?.username {getAdminUser.data
? ( ? (
<a href={`https://t.me/${getAdminUser.data.username}`} className="link"> getAdminPhoto.data
@{getAdminUser.data.username} ? (
</a> <img
src={getAdminPhoto.data}
alt="avatar"
className="w-24 h-24 rounded-full shadow-lg"
/>
)
: (
<div className="w-9 h-9 rounded-full bg-zinc-400 dark:bg-zinc-500 flex items-center justify-center text-white text-2xl font-bold select-none">
{getAdminUser.data.first_name.at(0)?.toUpperCase()}
</div>
)
) )
: null} : null}
</p> </div>
{getAdminUser.data?.bio <div className="flex flex-col p-10">
? ( <h5 className="mb-1 text-xl font-medium text-gray-900 dark:text-white">
<p> {getAdminUser.data?.first_name ?? admin.id} {getAdminUser.data?.last_name}
{getAdminUser.data?.bio} </h5>
</p> <p className="mb-1 text-xl font-medium text-gray-900 dark:text-white">
) {getAdminUser.data?.username
: null} ? (
{getUser.data?.admin && ( <a href={`https://t.me/${getAdminUser.data.username}`} className="link">
<p className="flex gap-2"> @{getAdminUser.data.username}
<button </a>
className="button-outlined" )
onClick={() => deleteDialogRef.current?.showModal()} : null}
>
Delete
</button>
</p> </p>
)} <span className="text-sm text-gray-500 dark:text-gray-400">
{getAdminUser.data?.bio
? (
<p>
{getAdminUser.data?.bio}
</p>
)
: null}
</span>
{getUser.data?.admin && (
<p className="flex gap-2">
<button
className="button-outlined"
onClick={() => deleteDialogRef.current?.showModal()}
>
Delete
</button>
</p>
)}
</div>
<DeleteAdminDialog <DeleteAdminDialog
dialogRef={deleteDialogRef} dialogRef={deleteDialogRef}
adminId={admin.id} adminId={admin.id}
sessionId={sessionId} sessionId={sessionId}
/> />
</li> </div>
); );
} }