@@ -2,6 +2,8 @@ import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/rea
22import { useTranslation } from 'react-i18next' ;
33import { useState , useEffect , useRef } from 'react' ;
44import { useLocation } from 'react-router-dom' ;
5+ import { useHistory } from 'react-router' ;
6+ import closeIcon from 'assets/icons/close.svg' ;
57import ChatContainer from '../../common/components/Chat/ChatContainer' ;
68import ChatInput from '../../common/components/Chat/ChatInput' ;
79import { chatService } from '../../common/services/ChatService' ;
@@ -19,11 +21,17 @@ const ChatPage = (): JSX.Element => {
1921 const [ messages , setMessages ] = useState < ChatMessageData [ ] > ( [ ] ) ;
2022 const location = useLocation ( ) ;
2123 const prevPathRef = useRef ( location . pathname ) ;
24+ const history = useHistory ( ) ;
2225
2326 const resetChatState = ( ) => {
2427 setMessages ( [ ] ) ;
2528 } ;
2629
30+ // Handle close button
31+ const handleClose = ( ) => {
32+ history . push ( '/tabs/home' ) ;
33+ } ;
34+
2735 // Handle initial setup and cleanup
2836 useEffect ( ( ) => {
2937 // Create a new session when the component mounts using an IIFE
@@ -92,6 +100,14 @@ const ChatPage = (): JSX.Element => {
92100 < span > { t ( 'pages.chat.title' , 'AI Assistant' ) } </ span >
93101 </ div >
94102 </ 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 >
95111 </ IonToolbar >
96112 </ IonHeader >
97113 < IonContent className = "chat-page-content" >
0 commit comments