Skip to content

Commit f97191f

Browse files
authored
Merge pull request #1906 from airqo-platform/ft-cleanair
[website] Bug Fix on secondary Nav component
2 parents 4d1e3f5 + 9f4a8c4 commit f97191f

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

website/frontend/src/components/CleanAir/SecondaryNav/index.js

+10-16
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,40 @@ import PropTypes from 'prop-types';
55
import { useTranslation } from 'react-i18next';
66
import { Link, useLocation } from 'react-router-dom';
77

8-
/**
9-
* @description Secondary navigation component for the CleanAir site
10-
* @param {Array} disabledTabs
11-
* @returns {JSX.Element}
12-
*/
138
const SecondaryNavComponent = ({ disabledTabs }) => {
149
const { t } = useTranslation();
1510
const activeTab = useSelector((state) => state.cleanAirData.activeTab);
1611
const tabs = [
17-
t('cleanAirSite.subNav.about'),
18-
t('cleanAirSite.subNav.membership'),
19-
t('cleanAirSite.subNav.events'),
20-
t('cleanAirSite.subNav.resources')
12+
{ label: t('cleanAirSite.subNav.about'), linkName: 'about' },
13+
{ label: t('cleanAirSite.subNav.membership'), linkName: 'membership' },
14+
{ label: t('cleanAirSite.subNav.events'), linkName: 'events' },
15+
{ label: t('cleanAirSite.subNav.resources'), linkName: 'resources' }
2116
];
17+
2218
const dispatch = useDispatch();
2319
const location = useLocation();
24-
2520
useEffect(() => {
26-
dispatch(setActiveTab(tabs[0]));
27-
const currentTab = tabs.findIndex((tab) => location.pathname.includes(tab.toLowerCase()));
21+
const currentTab = tabs.findIndex((tab) => location.pathname.includes(tab.linkName));
2822
if (currentTab !== -1 && !disabledTabs.includes(currentTab)) {
2923
dispatch(setActiveTab(tabs[currentTab]));
3024
}
31-
}, [location, dispatch, tabs, disabledTabs]);
25+
}, [location]);
3226

3327
return (
3428
<div className="header-subnav">
3529
<ul className="tabs">
3630
{tabs.map((tab, index) => (
37-
<Link to={`/clean-air/${tab.toLowerCase()}`} key={index}>
31+
<Link to={`/clean-air/${tab.linkName}`} key={index}>
3832
<li
3933
className={`${
40-
location.pathname.includes(tab.toLowerCase()) || activeTab === tab ? 'active' : ''
34+
location.pathname.includes(tab.linkName) || activeTab === index ? 'active' : ''
4135
} ${disabledTabs.includes(index) ? 'disabled' : ''}`}
4236
onClick={() => {
4337
if (!disabledTabs.includes(index)) {
4438
dispatch(setActiveTab(tab));
4539
}
4640
}}>
47-
<span>{tab}</span>
41+
<span>{tab.label}</span>
4842
</li>
4943
</Link>
5044
))}

website/frontend/src/pages/CleanAir/EventDetails.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import PageMini from '../PageMini';
1010
import { useTranslation } from 'react-i18next';
1111
import LanguageSwitcher from 'src/components/LanguageSwitcher';
1212
import { Link } from 'react-router-dom';
13+
import { useNavigate } from 'react-router-dom';
1314

1415
const EventDetails = () => {
1516
useInitScrollTop();
17+
const navigate = useNavigate();
1618
const { t } = useTranslation();
1719
const { uniqueTitle } = useParams();
1820

@@ -43,11 +45,16 @@ const EventDetails = () => {
4345
}}>
4446
<div className="content">
4547
<div className="breadcrumb">
46-
<span>
47-
<Link to="/clean-air">
48-
{t('cleanAirSite.eventsDetails.header.breadCrumb')}
49-
</Link>
50-
</span>
48+
<button
49+
onClick={() => navigate(-1)}
50+
style={{
51+
color: '#A8B2C7',
52+
background: 'none',
53+
border: 'none',
54+
cursor: 'pointer'
55+
}}>
56+
{t('cleanAirSite.eventsDetails.header.breadCrumb')}
57+
</button>
5158
<span style={{ fontFamily: 'monospace' }}>{'>'}</span>
5259
<span style={{ color: '#A8B2C7' }}>{event.title}</span>
5360
</div>

0 commit comments

Comments
 (0)