Skip to content

Commit

Permalink
DBC22-1829: removed routeEdit state (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-oxd authored Mar 26, 2024
1 parent 2439ed0 commit c91fc27
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 29 deletions.
3 changes: 1 addition & 2 deletions src/frontend/src/Components/map/LocationSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function LocationSearch(props) {
// Redux
const dispatch = useDispatch();

const { placeholder, location, action, routeEdit } = props;
const { placeholder, location, action } = props;

const [isSearching, setSearching] = useState(false);
const [options, setLocationOptions] = useState([]);
Expand Down Expand Up @@ -44,7 +44,6 @@ export default function LocationSearch(props) {
// Rendering
return (
<AsyncTypeahead
disabled={!routeEdit}
clearButton={true}
selected={location}
filterBy={() => true}
Expand Down
6 changes: 2 additions & 4 deletions src/frontend/src/Components/map/RouteSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import Spinner from 'react-bootstrap/Spinner';
import './RouteSearch.scss';

export default function RouteSearch(props) {
const { routeEdit } = props;

// Redux
const dispatch = useDispatch();
const { searchLocationFrom, searchLocationTo } = useSelector(useCallback(memoize(state => ({
Expand Down Expand Up @@ -88,7 +86,7 @@ export default function RouteSearch(props) {
</span>
}

<LocationSearch routeEdit={routeEdit} placeholder={'Find a location'} location={searchLocationFrom} action={updateSearchLocationFrom} />
<LocationSearch placeholder={'Find a location'} location={searchLocationFrom} action={updateSearchLocationFrom} />
</div>

{!!searchLocationFrom.length &&
Expand All @@ -97,7 +95,7 @@ export default function RouteSearch(props) {
<FontAwesomeIcon icon={faLocationDot} />
</span>

<LocationSearch routeEdit={routeEdit} placeholder={'Find a destination'} location={searchLocationTo} action={updateSearchLocationTo} />
<LocationSearch placeholder={'Find a destination'} location={searchLocationTo} action={updateSearchLocationTo} />

{showSpinner &&
<Spinner className="typeahead-spinner" size="sm" animation="border" />
Expand Down
10 changes: 1 addition & 9 deletions src/frontend/src/pages/CamerasListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export default function CamerasListPage() {
// UseState hooks
const [displayedCameras, setDisplayedCameras] = useState(null);
const [processedCameras, setProcessedCameras] = useState(null);
const [routeEdit, setRouteEdit] = useState(!(selectedRoute && selectedRoute.routeFound));
const [searchText, setSearchText] = useState('');

// UseEffect hooks and data functions
Expand Down Expand Up @@ -75,9 +74,6 @@ export default function CamerasListPage() {
useEffect(() => {
getCamerasData();

if (selectedRoute && selectedRoute.routeFound) {
setRouteEdit(false);
}
}, [selectedRoute]);

useEffect(() => {
Expand Down Expand Up @@ -130,11 +126,7 @@ export default function CamerasListPage() {

<div className="controls-container">
<div className="route-display-container">
<RouteSearch routeEdit={routeEdit} />

{/* {!routeEdit &&
<Button onClick={() => setRouteEdit(true)}>Change</Button>
} */}
<RouteSearch />
</div>

<div className="search-container">
Expand Down
16 changes: 2 additions & 14 deletions src/frontend/src/pages/EventsListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export default function EventsListPage() {
'roadConditions': false,
});

const [routeEdit, setRouteEdit] = useState(!(selectedRoute && selectedRoute.routeFound));
const [processedEvents, setProcessedEvents] = useState([]); // Nulls for mapping loader
const [showLoader, setShowLoader] = useState(false);

Expand Down Expand Up @@ -130,9 +129,6 @@ export default function EventsListPage() {
useEffect(() => {
setShowLoader(true);

if (selectedRoute && selectedRoute.routeFound) {
setRouteEdit(false);
}
}, [selectedRoute]);

useEffect(() => {
Expand Down Expand Up @@ -230,11 +226,7 @@ export default function EventsListPage() {
<div className="controls-container">
{ largeScreen &&
<div className="route-display-container">
<RouteSearch routeEdit={routeEdit} />

{/* {!routeEdit &&
<Button onClick={() => setRouteEdit(true)}>Change</Button>
} */}
<RouteSearch />
</div>
}

Expand All @@ -259,11 +251,7 @@ export default function EventsListPage() {

{ !largeScreen &&
<div className="route-display-container">
<RouteSearch routeEdit={routeEdit} />

{!routeEdit &&
<Button onClick={() => setRouteEdit(true)}>Change</Button>
}
<RouteSearch />
</div>
}
</div>
Expand Down

0 comments on commit c91fc27

Please sign in to comment.