@@ -6,30 +6,31 @@ import styles from "./inputbox.module.css"
66import { useGptResponseStore } from "../state/gptResponseStore"
77import { LoadingIcon } from "./LoadingIcon"
88import { SettingsIcon } from "./SettingsIcon"
9+ import { useHashLocation } from "../hooks/useHashLocation"
10+ import { Routes } from "../Routes/routes"
911
1012export const InputBox = ( ) => {
13+ const [ _ , navigate ] = useHashLocation ( )
1114 const inputRef = useRef < HTMLInputElement > ( null )
1215 const [ input , setInput ] = useInputStore ( s => [ s . input , s . setInput ] )
1316 const loading = useGptResponseStore ( s => s . loadingResponse )
1417
1518 useEffect ( ( ) => {
16- listen ( "focus-input" , ( ) => {
17- inputRef . current ?. focus ( )
18- } )
19+ listen ( "focus-input" , ( ) => { inputRef . current ?. focus ( ) } )
1920 listen ( "set-input" , ( { payload } ) => {
2021 inputRef . current ?. focus ( )
2122 setInput ( payload as string )
2223 } )
2324 } , [ ] )
2425
25-
2626 const handleChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
2727 setInput ( event . target . value ) ;
2828 }
2929
3030 const handleKeyDown = async ( event : React . KeyboardEvent < HTMLInputElement > ) => {
3131 if ( event . key === "Enter" ) {
3232 askGpt ( input )
33+ navigate ( Routes . Response )
3334 }
3435 } ;
3536
@@ -43,6 +44,6 @@ export const InputBox = () => {
4344 className = { styles . inputBox }
4445 value = { input }
4546 />
46- { loading ? < LoadingIcon /> : < button className = { styles . settingsIcon } onClick = { ( ) => setInput ( ":settings:" ) } > < SettingsIcon /> </ button > }
47+ { loading ? < LoadingIcon /> : < SettingsIcon /> }
4748 </ div >
4849}
0 commit comments