import { useContext } from "react";
import Link from "@moduletrace/twui/layout/Link";
import Span from "@moduletrace/twui/layout/Span";
import BotAvatar from "@/src/components/general/bot-avatar";
import type { BotFace } from "@/src/dict/bot-dict";
import botStoneProps from "@/src/utils/bot-stone-props";
import { AppContext } from "@/src/pages/__root";
import { CrewBotsContext } from "../(data)/crew-bots-context";
import AdminShield from "@/src/components/general/admin-shield";
type Props = {
bot_id: number;
};
/**
* A crew member a bot named in a message (`botRef`): a link to its
* conversation, in the open workspace when it's in the crew there, else
* its own chat. A bot the user doesn't reach is shown by name only.
*/
export default function BotRefChip({ bot_id }: Props) {
const { pageProps } = useContext(AppContext);
const workspace_id = pageProps?.workspace?.id;
const bots = useContext(CrewBotsContext);
const bot = bots.find((b) => b.id == bot_id);
if (!bot) {
return {`bot ${bot_id}`};
}
return (
{bot.name}
{workspace_id && bot.is_admin ? : null}
);
}