forked from administration/panel
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { Channel } from "revolt-api";
|
|
import { Card, CardDescription, CardHeader, CardTitle } from "../ui/card";
|
|
import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar";
|
|
import Link from "next/link";
|
|
|
|
export function ChannelCard({
|
|
channel,
|
|
subtitle,
|
|
}: {
|
|
channel: Channel;
|
|
subtitle: string;
|
|
}) {
|
|
if (channel.channel_type === "SavedMessages")
|
|
return <div>Refusing to render.</div>;
|
|
|
|
const name =
|
|
channel.channel_type === "DirectMessage" ? "Direct Message" : channel.name;
|
|
|
|
return (
|
|
<Card className="shadow-none">
|
|
<CardHeader>
|
|
<CardTitle>
|
|
<Avatar>
|
|
{channel.channel_type !== "DirectMessage" && (
|
|
<AvatarImage
|
|
src={`https://autumn.revolt.chat/icons/${channel.icon?._id}`}
|
|
/>
|
|
)}
|
|
<AvatarFallback>
|
|
{name
|
|
.split(" ")
|
|
.slice(0, 2)
|
|
.map((x) => String.fromCodePoint(x.codePointAt(0) ?? 32) ?? "")
|
|
.join("")}
|
|
</AvatarFallback>
|
|
</Avatar>
|
|
{name}
|
|
</CardTitle>
|
|
<CardDescription>{subtitle}</CardDescription>
|
|
</CardHeader>
|
|
</Card>
|
|
);
|
|
}
|