import { useState } from "react"; import { twMerge } from "tailwind-merge"; import Modal from "@moduletrace/twui/elements/Modal"; import Button from "@moduletrace/twui/layout/Button"; import H2 from "@moduletrace/twui/layout/H2"; import Span from "@moduletrace/twui/layout/Span"; import Stack from "@moduletrace/twui/layout/Stack"; import { Webhook } from "lucide-react"; import useHookProposal from "../(hooks)/use-hook-proposal"; import hookProposalTitle from "../(utils)/hook-proposal-title"; import proposalStatusLabel from "../(utils)/proposal-status-label"; import HookProposalCard from "./hook-proposal-card"; type Props = { proposal_id: number; }; /** * A hook a bot proposed (`hookProposalRef`): a chip naming it and where * it stands, which opens the card the user confirms or rejects it from. * Anyone it wasn't proposed to sees its number only. */ export default function HookProposalRefChip({ proposal_id }: Props) { const { view, loading, setView } = useHookProposal({ proposal_id }); const [open, setOpen] = useState(false); if (!view) { return ( {loading ? `hook proposal ${proposal_id}` : `hook proposal ${proposal_id} (not available)`} ); } const title = hookProposalTitle({ view }); const status = proposalStatusLabel({ view }); return ( {`${title} ยท ${status}`} } targetWrapperProps={{ className: "inline-flex max-w-full align-middle" }} open={open} setOpen={setOpen} className="max-w-xl bg-paper p-6" >

{title}

{`${status}. ${view.bot_name} proposed this; nothing is saved until you confirm. Everything above the bot's own words is read from what Confirm would save.`}
setOpen(false)} />
); }