@@ -2,6 +2,8 @@ import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/rea
2
2
import { useTranslation } from 'react-i18next' ;
3
3
import { useState , useEffect , useRef } from 'react' ;
4
4
import { useLocation } from 'react-router-dom' ;
5
+ import { useHistory } from 'react-router' ;
6
+ import closeIcon from 'assets/icons/close.svg' ;
5
7
import ChatContainer from '../../common/components/Chat/ChatContainer' ;
6
8
import ChatInput from '../../common/components/Chat/ChatInput' ;
7
9
import { chatService } from '../../common/services/ChatService' ;
@@ -19,11 +21,17 @@ const ChatPage = (): JSX.Element => {
19
21
const [ messages , setMessages ] = useState < ChatMessageData [ ] > ( [ ] ) ;
20
22
const location = useLocation ( ) ;
21
23
const prevPathRef = useRef ( location . pathname ) ;
24
+ const history = useHistory ( ) ;
22
25
23
26
const resetChatState = ( ) => {
24
27
setMessages ( [ ] ) ;
25
28
} ;
26
29
30
+ // Handle close button
31
+ const handleClose = ( ) => {
32
+ history . push ( '/tabs/home' ) ;
33
+ } ;
34
+
27
35
// Handle initial setup and cleanup
28
36
useEffect ( ( ) => {
29
37
// Create a new session when the component mounts using an IIFE
@@ -92,6 +100,14 @@ const ChatPage = (): JSX.Element => {
92
100
< span > { t ( 'pages.chat.title' , 'AI Assistant' ) } </ span >
93
101
</ div >
94
102
</ IonTitle >
103
+ < div slot = "end" >
104
+ < button
105
+ onClick = { handleClose }
106
+ style = { { backgroundColor : 'transparent' , marginRight : '2em' } }
107
+ >
108
+ < img src = { closeIcon } alt = "Close" />
109
+ </ button >
110
+ </ div >
95
111
</ IonToolbar >
96
112
</ IonHeader >
97
113
< IonContent className = "chat-page-content" >
0 commit comments