Skip to content

Commit c09d36e

Browse files
committed
DBC22-5424: separated chain-ups into its own page
1 parent 7b5db24 commit c09d36e

3 files changed

Lines changed: 28 additions & 24 deletions

File tree

src/frontend/src/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ function App() {
300300
<Route path="/my-routes" element={<SavedRoutesPage />} />
301301
<Route path="/cameras" element={<CamerasListPage />} />
302302
<Route path="/cameras/:id" element={<CameraDetailsPage />} />
303-
<Route path="/delays" element={<EventsListPage />} />
303+
<Route path="/delays" element={<EventsListPage key="/delays" />} />
304+
<Route path="/chain-ups" element={<EventsListPage key="/chain-ups" chainUpsOnly={true} />} />
304305
<Route path="/advisories" element={<AdvisoriesListPage />} />
305306
<Route path="/advisories/:id/:subid?" element={<AdvisoryDetailsPage />} />
306307
<Route path="/bulletins" element={<BulletinsListPage />} />

src/frontend/src/Components/shared/header/Header.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export default function Header() {
192192

193193
const handleChainUpsClick = (e) => {
194194
e.preventDefault();
195-
navigate('/delays?chainUpsOnly=true');
195+
navigate('/chain-ups');
196196
setIsCommercialOpen(false);
197197
onClickActions();
198198
}
@@ -321,17 +321,17 @@ export default function Header() {
321321
</LinkContainer>
322322

323323
<div className="commercial-dropdown" ref={commercialDropdownRef}>
324-
<Nav.Link
325-
active={false}
324+
<Nav.Link
325+
active={false}
326326
onClick={() => {
327327
setIsCommercialOpen(!isCommercialOpen);
328328
}}
329329
className={isCommercialOpen ? 'open' : ''}
330330
>
331331
<div className='title'>
332332
Commercial
333-
<FontAwesomeIcon
334-
icon={faChevronDown}
333+
<FontAwesomeIcon
334+
icon={faChevronDown}
335335
className={`chevron-icon ${isCommercialOpen ? 'rotated' : ''}`}
336336
/>
337337
</div>

src/frontend/src/pages/EventsListPage.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React, { useCallback, useContext, useEffect, useState, useRef } from 'react';
33

44
// Routing
5-
import { createSearchParams, useNavigate, useSearchParams } from 'react-router-dom';
5+
import { createSearchParams, useNavigate } from 'react-router-dom';
66

77
// Redux
88
import { useSelector, useDispatch } from 'react-redux';
@@ -30,7 +30,7 @@ import Dropdown from 'react-bootstrap/Dropdown';
3030
import Button from 'react-bootstrap/Button';
3131

3232
// Internal imports
33-
import { CMSContext, MapContext, HeaderHeightContext, FilterContext } from '../App';
33+
import { CMSContext, MapContext, FilterContext } from '../App';
3434
import { filterAdvisoryByRoute } from "../Components/map/helpers";
3535
import { getAdvisories, markAdvisoriesAsRead } from '../Components/data/advisories';
3636
import { getEvents, getEventDetails } from '../Components/data/events';
@@ -82,13 +82,15 @@ const sortEvents = (events, key) => {
8282
}
8383
}
8484

85-
export default function EventsListPage() {
85+
export default function EventsListPage(props) {
8686
/* Setup */
8787
document.title = 'DriveBC - Delays';
8888

89+
// Props
90+
const { chainUpsOnly } = props;
91+
8992
// Navigation
9093
const navigate = useNavigate();
91-
const [searchParams] = useSearchParams();
9294

9395
// Redux
9496
const dispatch = useDispatch();
@@ -104,11 +106,10 @@ export default function EventsListPage() {
104106
const { cmsContext, setCMSContext } = useContext(CMSContext);
105107
const { filterContext, setFilterContext } = useContext(FilterContext);
106108
const { mapContext } = useContext(MapContext);
107-
// const { headerHeightContext } = useContext(HeaderHeightContext);
108109

109110
// States
110111
const getFilterState = () => {
111-
if (searchParams.get('chainUpsOnly') === 'true') {
112+
if (chainUpsOnly) {
112113
return {
113114
'closures': false,
114115
'majorEvents': false,
@@ -614,8 +615,8 @@ export default function EventsListPage() {
614615
}
615616

616617
<PageHeader
617-
title="Delays"
618-
description="Find out if there are any delays that might impact your journey before you go.">
618+
title={chainUpsOnly ? 'Commercial chain-ups' : 'Delays'}
619+
description={chainUpsOnly ? 'Segments of the highway that require commercial vehicles over 11,794 kg to have chains on.' : 'Find out if there are any delays that might impact your journey before you go.'}>
619620
</PageHeader>
620621

621622
<Container className="container--sidepanel">
@@ -700,7 +701,7 @@ export default function EventsListPage() {
700701
</Button>
701702
}
702703

703-
{!smallScreen &&
704+
{!smallScreen && !chainUpsOnly &&
704705
<div className="type filter-option-btn">
705706
<ListFilters
706707
disableFeatures={true}
@@ -789,7 +790,7 @@ export default function EventsListPage() {
789790

790791
{(!showLoader && !processedEvents.length) &&
791792
<div className="empty-event-display">
792-
<h2>No delays to display</h2>
793+
<h2>{`No ${chainUpsOnly ? 'chain-ups' : 'delays'} to display`}</h2>
793794

794795
<strong>Do you have a starting location and a destination entered?</strong>
795796
<p>Adding a route will narrow down the information for the whole site, including the delays list. There might not be any delays between those two locations.</p>
@@ -847,14 +848,16 @@ export default function EventsListPage() {
847848

848849
<p className="overlay__header bold">List</p>
849850

850-
<ListFilters
851-
disableFeatures={true}
852-
enableRoadConditions={false}
853-
enableChainUps={true}
854-
textOverride={'List'}
855-
iconOverride={true}
856-
isDelaysPage={true}
857-
fullOverlay={true} />
851+
{!chainUpsOnly &&
852+
<ListFilters
853+
disableFeatures={true}
854+
enableRoadConditions={false}
855+
enableChainUps={true}
856+
textOverride={'List'}
857+
iconOverride={true}
858+
isDelaysPage={true}
859+
fullOverlay={true} />
860+
}
858861
</div>
859862
}
860863

0 commit comments

Comments
 (0)