wip: refactor chats to use zustand

This commit is contained in:
Ren Amamiya
2023-05-27 12:14:30 +07:00
parent 671b857077
commit 79e948ac05
21 changed files with 229 additions and 278 deletions

View File

@@ -0,0 +1,30 @@
import { Image } from "@shared/image";
import { DEFAULT_AVATAR } from "@stores/constants";
import { useProfile } from "@utils/hooks/useProfile";
import { shortenKey } from "@utils/shortenKey";
export function ChatSidebar({ pubkey }: { pubkey: string }) {
const { user, isError, isLoading } = useProfile(pubkey);
return (
<div className="px-3 py-2">
<div className="flex flex-col gap-3">
<div className="relative h-11 w-11 shrink rounded-md">
<Image
src={user?.picture || DEFAULT_AVATAR}
alt={pubkey}
className="h-11 w-11 rounded-md object-cover"
/>
</div>
<div className="flex flex-col gap-1">
<h3 className="leading-none text-lg font-semibold">
{user?.display_name || user?.name}
</h3>
<p className="leading-none text-zinc-400">
{user?.nip05 || user?.username || shortenKey(pubkey)}
</p>
</div>
</div>
</div>
);
}