68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
import Image from "next/image";
|
|
|
|
export interface FriendEntry {
|
|
friend_id: string;
|
|
friend_alias: string;
|
|
avatar_url: string | null;
|
|
}
|
|
|
|
export function FriendsList({ friends }: Readonly<{ friends: FriendEntry[] }>) {
|
|
if (friends.length === 0) {
|
|
return (
|
|
<div className="flex flex-col items-center rounded-xl border border-dashed border-neutral-300 py-12">
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
strokeWidth={1}
|
|
className="size-10 text-neutral-300"
|
|
>
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
d="M15 19.128a9.38 9.38 0 0 0 2.625.372 9.337 9.337 0 0 0 4.121-.952 4.125 4.125 0 0 0-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 0 1 8.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0 1 11.964-3.07M12 6.375a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0Zm8.25 2.25a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z"
|
|
/>
|
|
</svg>
|
|
<p className="mt-3 text-sm text-neutral-400">No friends yet</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<h2 className="text-sm font-semibold text-neutral-900">
|
|
Friends
|
|
<span className="ml-2 text-xs font-normal text-neutral-500">
|
|
{friends.length}
|
|
</span>
|
|
</h2>
|
|
<ul className="mt-3 divide-y divide-neutral-100 rounded-xl border border-neutral-200 bg-white">
|
|
{friends.map((friend) => (
|
|
<li
|
|
key={friend.friend_id}
|
|
className="flex items-center gap-3 px-4 py-3"
|
|
>
|
|
{friend.avatar_url ? (
|
|
<Image
|
|
src={friend.avatar_url}
|
|
alt=""
|
|
width={200}
|
|
height={200}
|
|
className="size-16 rounded-full object-cover"
|
|
/>
|
|
) : (
|
|
<div className="flex size-16 items-center justify-center rounded-full bg-neutral-100 text-xs font-medium text-neutral-600">
|
|
{friend.friend_alias.charAt(0).toUpperCase()}
|
|
</div>
|
|
)}
|
|
<span className="text-sm font-medium text-neutral-900">
|
|
{friend.friend_alias} - {friend.friend_id}
|
|
</span>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
);
|
|
}
|