@@ -27,33 +27,6 @@ const ChatLanding: FC = () => {
27
27
const queryClient = useQueryClient ( ) ;
28
28
const createChatMutation = useMutation ( createChat ( queryClient ) ) ;
29
29
30
- const handleInputChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
31
- setInput ( event . target . value ) ;
32
- } ;
33
-
34
- // Placeholder submit handler
35
- const handleFormSubmit = ( e : FormEvent < HTMLFormElement > ) => {
36
- e . preventDefault ( ) ;
37
- if ( ! input . trim ( ) ) return ;
38
- // Actual submission logic will go elsewhere
39
- setInput ( "" ) ; // Clear input after submit (optional)
40
-
41
- createChatMutation . mutateAsync ( ) . then ( ( chat ) => {
42
- navigate ( `/chat/${ chat . id } ` , {
43
- state : {
44
- chat,
45
- message : input ,
46
- } ,
47
- } ) ;
48
- } ) ;
49
- } ;
50
-
51
- // Placeholder suggestion handler
52
- const handleSuggestionClick = ( suggestion : string ) => {
53
- setInput ( suggestion ) ;
54
- // Optionally trigger focus on the input field here
55
- } ;
56
-
57
30
return (
58
31
< Margins >
59
32
< div
@@ -117,33 +90,37 @@ const ChatLanding: FC = () => {
117
90
>
118
91
< Button
119
92
variant = "outlined"
120
- onClick = { ( ) =>
121
- handleSuggestionClick ( "Help me work on issue #..." )
122
- }
93
+ onClick = { ( ) => setInput ( "Help me work on issue #..." ) }
123
94
>
124
95
Work on Issue
125
96
</ Button >
126
97
< Button
127
98
variant = "outlined"
128
- onClick = { ( ) =>
129
- handleSuggestionClick ( "Help me build a template for..." )
130
- }
99
+ onClick = { ( ) => setInput ( "Help me build a template for..." ) }
131
100
>
132
101
Build a Template
133
102
</ Button >
134
103
< Button
135
104
variant = "outlined"
136
- onClick = { ( ) =>
137
- handleSuggestionClick ( "Help me start a new project using..." )
138
- }
105
+ onClick = { ( ) => setInput ( "Help me start a new project using..." ) }
139
106
>
140
107
Start a Project
141
108
</ Button >
142
109
</ Stack >
143
110
< LanguageModelSelector />
144
111
< Paper
145
112
component = "form"
146
- onSubmit = { handleFormSubmit }
113
+ onSubmit = { async ( e : FormEvent < HTMLFormElement > ) => {
114
+ e . preventDefault ( ) ;
115
+ setInput ( "" ) ;
116
+ const chat = await createChatMutation . mutateAsync ( ) ;
117
+ navigate ( `/chat/${ chat . id } ` , {
118
+ state : {
119
+ chat,
120
+ message : input ,
121
+ } ,
122
+ } ) ;
123
+ } }
147
124
elevation = { 2 }
148
125
css = { {
149
126
padding : "16px" ,
@@ -156,8 +133,11 @@ const ChatLanding: FC = () => {
156
133
>
157
134
< TextField
158
135
value = { input }
159
- onChange = { handleInputChange }
136
+ onChange = { ( event : React . ChangeEvent < HTMLInputElement > ) => {
137
+ setInput ( event . target . value ) ;
138
+ } }
160
139
placeholder = "Ask Coder..."
140
+ required
161
141
fullWidth
162
142
variant = "outlined"
163
143
multiline
0 commit comments