Skip to content

Commit

Permalink
DBC22-1879: added button to switch from and to input
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-oxd committed Mar 15, 2024
1 parent 66b82f8 commit b75bf4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/frontend/src/Components/map/LocationSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function LocationSearch(props) {
<AsyncTypeahead
disabled={!routeEdit}
clearButton={true}
defaultSelected={location}
selected={location}
filterBy={() => true}
id="location-search-typeahead"
isLoading={isSearching}
Expand Down
11 changes: 11 additions & 0 deletions src/frontend/src/Components/map/RouteSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
faCircleDot,
faLocationDot
} from '@fortawesome/free-solid-svg-icons';
import Button from 'react-bootstrap/Button';
import Spinner from 'react-bootstrap/Spinner';

// Styling
Expand Down Expand Up @@ -70,6 +71,12 @@ export default function RouteSearch(props) {
}
}, [showSpinner]);

// Handlers
const swapHandler = () => {
dispatch(updateSearchLocationFrom(searchLocationTo));
dispatch(updateSearchLocationTo(searchLocationFrom));
}

// Rendering
return (
<div className="routing-container">
Expand All @@ -96,6 +103,10 @@ export default function RouteSearch(props) {
}
</div>
}

{!!searchLocationFrom.length && !!searchLocationTo.length &&
<Button onClick={() => swapHandler()}>Swap</Button>
}
</div>
);
}

0 comments on commit b75bf4c

Please sign in to comment.