1+
2+ import {
3+ Body1 ,
4+ Button ,
5+ Card ,
6+ Text ,
7+ } from "@fluentui/react-components" ;
8+ import {
9+ Send20Regular ,
10+ Person20Regular ,
11+ Phone20Regular ,
12+ ShoppingBag20Regular ,
13+ DocumentEdit20Regular ,
14+ } from "@fluentui/react-icons" ;
15+ import React , { useRef , useEffect } from "react" ;
16+ import "./../../styles/Chat.css" ; // Assuming you have a CSS file for additional styles
17+ import "./../../styles/HomeInput.css" ;
18+ import { HomeInputProps , quickTasks } from "../../models/homeInput" ;
19+
20+
21+ const HomeInput : React . FC < HomeInputProps > = ( {
22+ onInputSubmit,
23+ onQuickTaskSelect,
24+ } ) => {
25+ const [ inputValue , setInputValue ] = React . useState ( "" ) ;
26+ const textareaRef = useRef < HTMLTextAreaElement > ( null ) ;
27+
28+ const handleSubmit = ( ) => {
29+ if ( inputValue . trim ( ) ) {
30+ onInputSubmit ( inputValue . trim ( ) ) ;
31+ setInputValue ( "" ) ;
32+ if ( textareaRef . current ) {
33+ textareaRef . current . style . height = "auto" ;
34+ }
35+ }
36+ } ;
37+
38+ const handleKeyPress = ( e : React . KeyboardEvent ) => {
39+ if ( e . key === "Enter" && ! e . shiftKey ) {
40+ e . preventDefault ( ) ;
41+ handleSubmit ( ) ;
42+ }
43+ } ;
44+
45+ // Auto-resize textarea
46+ useEffect ( ( ) => {
47+ if ( textareaRef . current ) {
48+ textareaRef . current . style . height = "auto" ;
49+ textareaRef . current . style . height = `${ textareaRef . current . scrollHeight } px` ;
50+ }
51+ } , [ inputValue ] ) ;
52+
53+ return ( < div className = "home-input-container" >
54+ < div className = "home-input-content" >
55+ < div className = "home-input-center-content" >
56+ < div className = "home-input-title-wrapper" >
57+ < Text className = "home-input-title" > How can I help?</ Text >
58+ </ div >
59+
60+ < div className = "home-input-input-section" >
61+ < div className = "home-input-input-wrapper" >
62+ < textarea
63+ ref = { textareaRef }
64+ className = "home-input-input-field"
65+ value = { inputValue }
66+ onChange = { ( e ) => setInputValue ( e . target . value ) }
67+ onKeyPress = { handleKeyPress }
68+ placeholder = "Describe what you'd like to do or use / to reference files, people, and more"
69+ rows = { 1 }
70+ />
71+ < Button
72+ className = "home-input-send-button"
73+ onClick = { handleSubmit }
74+ disabled = { ! inputValue . trim ( ) }
75+ icon = { < Send20Regular /> }
76+ />
77+ </ div >
78+ < div className = "home-input-ai-footer" >
79+ AI-generated content may be incorrect
80+ </ div >
81+ </ div >
82+
83+ < div className = "home-input-quick-tasks-section" >
84+ < div className = "home-input-quick-tasks-header" >
85+ < Text className = "home-input-quick-tasks-title" > Quick tasks</ Text >
86+ < Button appearance = "transparent" className = "home-input-refresh-button" >
87+ Refresh
88+ </ Button >
89+ </ div >
90+ < div className = "home-input-quick-tasks" >
91+ { quickTasks . map ( ( task ) => (
92+ < Card
93+ key = { task . id }
94+ className = "home-input-quick-task-card"
95+ onClick = { ( ) => onQuickTaskSelect ( task . id ) }
96+ >
97+ < div className = "home-input-card-content" >
98+ < div className = "home-input-card-icon" > { task . icon } </ div >
99+ < div className = "home-input-card-text-content" >
100+ < Text className = "home-input-card-title" > { task . title } </ Text >
101+ < Text className = "home-input-card-description" > { task . description } </ Text >
102+ </ div >
103+ </ div >
104+ </ Card >
105+ ) ) }
106+ </ div >
107+ </ div >
108+ </ div >
109+ </ div >
110+ </ div >
111+ ) ;
112+ }
113+
114+ export default HomeInput ;
0 commit comments