diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsx index 8d622a5..f67c6ad 100644 --- a/src/components/chat/ChatInput.tsx +++ b/src/components/chat/ChatInput.tsx @@ -23,6 +23,15 @@ import { useLoadApp } from "@/hooks/useLoadApp"; import { Button } from "@/components/ui/button"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; +import { useProposal } from "@/hooks/useProposal"; +import { Proposal } from "@/lib/schemas"; + +interface ChatInputActionsProps { + proposal: Proposal; + onApprove: () => void; + onReject: () => void; + isApprovable: boolean; // Can be used to enable/disable buttons +} interface ChatInputProps { chatId?: number; @@ -38,6 +47,13 @@ export function ChatInput({ chatId, onSubmit }: ChatInputProps) { const [selectedAppId] = useAtom(selectedAppIdAtom); const [showError, setShowError] = useState(true); + // Use the hook to fetch the proposal + const { + proposal, + isLoading: isProposalLoading, + error: proposalError, + } = useProposal(chatId); + const adjustHeight = () => { const textarea = textareaRef.current; if (textarea) { @@ -86,6 +102,16 @@ export function ChatInput({ chatId, onSubmit }: ChatInputProps) { setShowError(false); }; + const handleApprove = () => { + console.log("Approve clicked"); + // Add approve logic here + }; + + const handleReject = () => { + console.log("Reject clicked"); + // Add reject logic here + }; + if (!settings) { return null; // Or loading state } @@ -105,9 +131,28 @@ export function ChatInput({ chatId, onSubmit }: ChatInputProps) { )} + {/* Display loading or error state for proposal */} + {isProposalLoading && ( +
+ Loading proposal... +
+ )} + {proposalError && ( +
+ Error loading proposal: {proposalError} +
+ )}
- + {/* Only render ChatInputActions if proposal is loaded */} + {proposal && ( + + )}