76 lines
2.6 KiB
TypeScript
76 lines
2.6 KiB
TypeScript
import Link from "next/link";
|
|
|
|
export interface RoomEntry {
|
|
id: string;
|
|
name: string;
|
|
created_at: string;
|
|
member_count: number;
|
|
}
|
|
|
|
export function RoomsList({ rooms }: Readonly<{ rooms: RoomEntry[] }>) {
|
|
if (rooms.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="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 0 1 1.037-.443 48.282 48.282 0 0 0 5.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z"
|
|
/>
|
|
</svg>
|
|
<p className="mt-3 text-sm text-neutral-400">No rooms yet</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<h2 className="text-sm font-semibold text-neutral-900">
|
|
Your Rooms
|
|
<span className="ml-2 text-xs font-normal text-neutral-500">
|
|
{rooms.length}
|
|
</span>
|
|
</h2>
|
|
<ul className="mt-3 space-y-2">
|
|
{rooms.map((room) => (
|
|
<li key={room.id}>
|
|
<Link
|
|
href={`/rooms/${room.id}`}
|
|
className="flex items-center justify-between rounded-xl border border-neutral-200 bg-white px-4 py-3 shadow-sm transition hover:border-neutral-300"
|
|
>
|
|
<div className="min-w-0 flex-1">
|
|
<p className="text-sm font-medium text-neutral-900">
|
|
{room.name}
|
|
</p>
|
|
<p className="mt-0.5 text-xs text-neutral-500">
|
|
{room.member_count}{" "}
|
|
{room.member_count === 1 ? "member" : "members"}
|
|
</p>
|
|
</div>
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
viewBox="0 0 20 20"
|
|
fill="currentColor"
|
|
className="size-5 text-neutral-400"
|
|
>
|
|
<path
|
|
fillRule="evenodd"
|
|
d="M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z"
|
|
clipRule="evenodd"
|
|
/>
|
|
</svg>
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
);
|
|
}
|