11import { IonRouterOutlet , IonTabBar , IonTabButton , IonTabs } from '@ionic/react' ;
22import { Redirect , Route } from 'react-router' ;
33import { useState } from 'react' ;
4- import { useHistory } from 'react-router-dom' ;
4+ import { useHistory , useLocation } from 'react-router-dom' ;
5+ import { useTranslation } from 'react-i18next' ;
56
67import './TabNavigation.scss' ;
78import AppMenu from '../Menu/AppMenu' ;
8- import Icon from '../Icon/Icon ' ;
9+ import SvgIcon from '../Icon/SvgIcon ' ;
910import UploadModal from '../Upload/UploadModal' ;
1011import HomePage from 'pages/Home/HomePage' ;
1112import UserDetailPage from 'pages/Users/components/UserDetail/UserDetailPage' ;
@@ -20,6 +21,13 @@ import ReportsListPage from 'pages/Reports/ReportsListPage';
2021import ReportDetailPage from 'pages/Reports/ReportDetailPage' ;
2122import ProcessingPage from 'pages/Processing/ProcessingPage' ;
2223
24+ // Import SVG icons
25+ import homeIcon from 'assets/icons/home.svg' ;
26+ import reportsIcon from 'assets/icons/reports.svg' ;
27+ import uploadIcon from 'assets/icons/upload.svg' ;
28+ import chatIcon from 'assets/icons/chat.svg' ;
29+ import profileIcon from 'assets/icons/profile.svg' ;
30+
2331/**
2432 * The `TabNavigation` component provides a router outlet for all of the
2533 * application routes. The component renders two main application
@@ -38,6 +46,13 @@ import ProcessingPage from 'pages/Processing/ProcessingPage';
3846const TabNavigation = ( ) : JSX . Element => {
3947 const [ isUploadModalOpen , setIsUploadModalOpen ] = useState ( false ) ;
4048 const history = useHistory ( ) ;
49+ const location = useLocation ( ) ;
50+ const { t } = useTranslation ( ) ;
51+
52+ // Check if the current path starts with the tab path
53+ const isTabActive = ( tabPath : string ) => {
54+ return location . pathname . startsWith ( tabPath ) ;
55+ } ;
4156
4257 const handleUploadClick = ( ) => {
4358 setIsUploadModalOpen ( true ) ;
@@ -101,19 +116,27 @@ const TabNavigation = (): JSX.Element => {
101116
102117 < IonTabBar slot = "bottom" className = "ls-tab-navigation__bar ion-hide-md-up" >
103118 < IonTabButton className = "ls-tab-navigation__bar-button" tab = "home" href = "/tabs/home" >
104- < Icon className = "ls-tab-navigation__bar-button-icon" icon = "home" size = "xl" fixedWidth />
119+ < SvgIcon
120+ className = "ls-tab-navigation__bar-button-icon"
121+ src = { homeIcon }
122+ active = { isTabActive ( '/tabs/home' ) }
123+ alt = { t ( 'navigation.home' , { ns : 'common' , defaultValue : 'Home' } ) }
124+ width = { 24 }
125+ height = { 24 }
126+ />
105127 </ IonTabButton >
106128 < IonTabButton
107129 className = "ls-tab-navigation__bar-button"
108130 tab = "reports"
109131 href = "/tabs/reports"
110132 >
111- < Icon
133+ < SvgIcon
112134 className = "ls-tab-navigation__bar-button-icon"
113- icon = "fileLines"
114- iconStyle = "regular"
115- size = "xl"
116- fixedWidth
135+ src = { reportsIcon }
136+ active = { isTabActive ( '/tabs/reports' ) }
137+ alt = { t ( 'navigation.reports' , { ns : 'common' , defaultValue : 'Reports' } ) }
138+ width = { 24 }
139+ height = { 24 }
117140 />
118141 </ IonTabButton >
119142 < IonTabButton
@@ -122,33 +145,37 @@ const TabNavigation = (): JSX.Element => {
122145 onClick = { handleUploadClick }
123146 >
124147 < div className = "ls-tab-navigation__bar-button-upload-wrapper" >
125- < Icon
148+ < SvgIcon
126149 className = "ls-tab-navigation__bar-button-icon"
127- icon = "arrowUpFromBracket"
128- size = "xl"
129- fixedWidth
150+ src = { uploadIcon }
151+ alt = { t ( 'navigation.upload' , { ns : 'common' , defaultValue : 'Upload' } ) }
152+ width = { 24 }
153+ height = { 24 }
130154 />
131155 </ div >
132156 </ IonTabButton >
133157 < IonTabButton className = "ls-tab-navigation__bar-button" tab = "chat" href = "/tabs/chat" >
134- < Icon
158+ < SvgIcon
135159 className = "ls-tab-navigation__bar-button-icon"
136- icon = "comment"
137- iconStyle = "regular"
138- size = "xl"
139- fixedWidth
160+ src = { chatIcon }
161+ active = { isTabActive ( '/tabs/chat' ) }
162+ alt = { t ( 'navigation.chat' , { ns : 'common' , defaultValue : 'Chat' } ) }
163+ width = { 24 }
164+ height = { 24 }
140165 />
141166 </ IonTabButton >
142167 < IonTabButton
143168 className = "ls-tab-navigation__bar-button"
144169 tab = "account"
145170 href = "/tabs/account"
146171 >
147- < Icon
172+ < SvgIcon
148173 className = "ls-tab-navigation__bar-button-icon"
149- icon = "userCircle"
150- size = "xl"
151- fixedWidth
174+ src = { profileIcon }
175+ active = { isTabActive ( '/tabs/account' ) }
176+ alt = { t ( 'navigation.account' , { ns : 'common' , defaultValue : 'Account' } ) }
177+ width = { 24 }
178+ height = { 24 }
152179 />
153180 </ IonTabButton >
154181 </ IonTabBar >
0 commit comments