ChatInput.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { Button } from "@/components/ui/button";
  2. import { Input } from "@/components/ui/input";
  3. import { Send } from "lucide-react";
  4. interface ChatInputProps {
  5. inputMessage: string;
  6. setInputMessage: (message: string) => void;
  7. onSendMessage: () => void;
  8. isLimitReached: boolean;
  9. isLoading: boolean;
  10. }
  11. export const ChatInput = ({
  12. inputMessage,
  13. setInputMessage,
  14. onSendMessage,
  15. isLimitReached,
  16. isLoading,
  17. }: ChatInputProps) => {
  18. const handleKeyPress = (e: React.KeyboardEvent) => {
  19. if (e.key === "Enter" && !e.shiftKey) {
  20. e.preventDefault();
  21. onSendMessage();
  22. }
  23. };
  24. return (
  25. <div className="p-6 border-t border-border bg-muted">
  26. <div className="flex space-x-3">
  27. <Input
  28. value={inputMessage}
  29. onChange={(e) => setInputMessage(e.target.value)}
  30. onKeyPress={handleKeyPress}
  31. placeholder="Describe tu consulta médica aquí..."
  32. disabled={isLimitReached || isLoading}
  33. className="flex-1 rounded-xl"
  34. />
  35. <Button
  36. onClick={onSendMessage}
  37. disabled={!inputMessage.trim() || isLimitReached || isLoading}
  38. size="icon"
  39. className="rounded-xl"
  40. >
  41. <Send className="w-4 h-4" />
  42. </Button>
  43. </div>
  44. </div>
  45. );
  46. };