@@ -15,28 +15,29 @@ import {
1515 ShoppingBag20Regular ,
1616 DocumentEdit20Regular ,
1717} from "@fluentui/react-icons" ;
18- import React , { useRef , useEffect } from "react" ;
18+ import React , { useRef , useEffect , useState } from "react" ;
1919import { useNavigate } from 'react-router-dom' ;
2020import "./../../styles/Chat.css" ; // Assuming you have a CSS file for additional styles
2121import "./../../styles/HomeInput.css" ;
2222import { HomeInputProps , quickTasks , QuickTask } from "../../models/homeInput" ;
2323import { TaskService } from "../../services/TaskService" ;
2424import { NewTaskService } from "../../services/NewTaskService" ;
25+ import ChatInput from "@/coral/modules/ChatInput" ;
2526
2627
2728const HomeInput : React . FC < HomeInputProps > = ( {
2829 onInputSubmit,
2930 onQuickTaskSelect,
3031} ) => {
31- const [ inputValue , setInputValue ] = React . useState ( "" ) ;
32+ const [ input , setInput ] = useState ( "" ) ;
3233 const textareaRef = useRef < HTMLTextAreaElement > ( null ) ;
3334 const navigate = useNavigate ( ) ;
3435
3536 /**
3637 * Reset textarea to empty state
3738 */
3839 const resetTextarea = ( ) => {
39- setInputValue ( "" ) ;
40+ setInput ( "" ) ;
4041 if ( textareaRef . current ) {
4142 textareaRef . current . style . height = "auto" ;
4243 textareaRef . current . focus ( ) ;
@@ -50,13 +51,13 @@ const HomeInput: React.FC<HomeInputProps> = ({
5051 } , [ ] ) ;
5152
5253 const handleSubmit = async ( ) => {
53- if ( inputValue . trim ( ) ) {
54+ if ( input . trim ( ) ) {
5455 try {
5556 // Submit the input task using TaskService
56- const response = await TaskService . submitInputTask ( inputValue . trim ( ) ) ;
57+ const response = await TaskService . submitInputTask ( input . trim ( ) ) ;
5758
5859 // Clear the input field
59- setInputValue ( "" ) ;
60+ setInput ( "" ) ;
6061 if ( textareaRef . current ) {
6162 textareaRef . current . style . height = "auto" ;
6263 }
@@ -72,7 +73,7 @@ const HomeInput: React.FC<HomeInputProps> = ({
7273 } ;
7374 const handleQuickTaskClick = ( task : QuickTask ) => {
7475 // Copy task description to textarea
75- setInputValue ( task . description ) ;
76+ setInput ( task . description ) ;
7677
7778 // Focus on textarea
7879 if ( textareaRef . current ) {
@@ -90,40 +91,27 @@ const HomeInput: React.FC<HomeInputProps> = ({
9091 textareaRef . current . style . height = "auto" ;
9192 textareaRef . current . style . height = `${ textareaRef . current . scrollHeight } px` ;
9293 }
93- } , [ inputValue ] ) ;
94+ } , [ input ] ) ;
9495
9596 return (
96-
9797 < div className = "home-input-container" >
9898 < div className = "home-input-content" >
9999 < div className = "home-input-center-content" >
100100 < div className = "home-input-title-wrapper" >
101101 < Title2 > How can I help?</ Title2 >
102102 </ div >
103103
104- < div className = "home-input-input-section" >
105- < div className = "home-input-input-wrapper" >
106- < textarea
107- ref = { textareaRef }
108- className = "home-input-input-field"
109- value = { inputValue }
110- onChange = { ( e ) => setInputValue ( e . target . value ) }
111- placeholder = "Describe what you'd like to do or use / to reference files, people, and more"
112- rows = { 1 }
113- />
114- < Button
115- className = "home-input-send-button"
116- onClick = { handleSubmit }
117- disabled = { ! inputValue . trim ( ) }
118- icon = { < Send20Regular /> }
119- />
120- </ div >
121- < div className = "home-input-ai-footer" >
122- < Caption1 >
123- AI-Generated content may be incorrect
124- </ Caption1 >
125- </ div >
126- </ div >
104+ < ChatInput
105+ value = { input }
106+ placeholder = "Describe what you'd like to do or use / to reference files, people, and more" onChange = { setInput } >
107+ < Button
108+ appearance = "subtle"
109+ className = "home-input-send-button"
110+ onClick = { handleSubmit }
111+ disabled = { ! input . trim ( ) }
112+ icon = { < Send20Regular /> }
113+ />
114+ </ ChatInput >
127115
128116 < div className = "home-input-quick-tasks-section" >
129117 < div className = "home-input-quick-tasks-header" >
@@ -142,7 +130,9 @@ const HomeInput: React.FC<HomeInputProps> = ({
142130 </ div >
143131 < div className = "home-input-quick-task-text-content" >
144132 < Body1Strong > { task . title } </ Body1Strong >
145- < Body1 className = "home-input-quick-task-description" > { task . description } </ Body1 >
133+ < Body1 className = "home-input-quick-task-description" >
134+ { task . description }
135+ </ Body1 >
146136 </ div >
147137 </ div >
148138 </ Card >
0 commit comments