import { useContext } from "react";
import Button from "@moduletrace/twui/layout/Button";
import Span from "@moduletrace/twui/layout/Span";
import { Check, Monitor } from "lucide-react";
import { twMerge } from "tailwind-merge";
import { BotComputersContext } from "../(data)/bot-computers-context";
type Props = {
computer_id: number;
};
/**
* A computer the bot named in a message (`computerRef`): a chip that opens
* it in the viewer, in its browser. The one the bot is already on says so,
* sunken with a check. A computer the bot can't use (any more) is shown by
* name only.
*/
export default function ComputerRefChip({ computer_id }: Props) {
const { computers, openComputer } = useContext(BotComputersContext);
const computer = computers.find((c) => c.id == computer_id);
const name = computer?.name || `computer ${computer_id}`;
if (!computer?.id) {
return {name};
}
const current = computers[0]?.id == computer.id;
return (
);
}