Skip to content

Commit

Permalink
If searching through parkings, take in account paring type filter
Browse files Browse the repository at this point in the history
  • Loading branch information
bartwr committed Jul 15, 2024
1 parent 7f80008 commit 0d67b56
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/components/ParkingFacilityBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ function ParkingFacilityBrowser({
(state: AppState) => state.map.selectedParkingId
);

const filterTypes = useSelector(
(state: AppState) => state.filter.activeTypes
);

const filterTypes2 = useSelector(
(state: AppState) => state.filter.activeTypes2
);
Expand All @@ -100,11 +104,14 @@ function ParkingFacilityBrowser({

// Create variable that represents all parkings
let allParkings = fietsenstallingen;
// Show voorstellen only
if (filterTypes2 && filterTypes2.includes('show_submissions')) {
allParkings = allParkings.filter((x) => {
return x.ID.substring(0, 8) === 'VOORSTEL'
});
} else {
}
// Or show everything except voorstellen
else {
allParkings = allParkings.filter((x) => {
// console.log("filter-is", x.ID, x.ID.substring(0, 8), x.ID.substring(0, 7) !== 'VOORSTEL')
return x.ID.substring(0, 8) !== 'VOORSTEL'
Expand All @@ -130,6 +137,11 @@ function ParkingFacilityBrowser({
// - If no active municipality: Search through everything
// - If active municipality: First show parkings of this municipality, then the rest
else {
// Filter types (like 'bewaakte stalling', 'fietskluis', etc)
if (filterTypes && filterTypes.length > 0) {
filtered = filtered.filter(x => filterTypes.indexOf(x.Type) > -1);
}

// If searchQuery given and zoomed out: Only keep parkings with the searchQuery
if (
mapZoom < 12 &&
Expand Down
2 changes: 1 addition & 1 deletion src/components/parking/ParkingEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ const ParkingEdit = ({ parkingdata, onClose, onChange }: { parkingdata: ParkingD

const renderTabOpeningstijden = (visible: boolean = false) => {
const handlerSetNewOpening = (tijden: OpeningChangedType, Openingstijden: string): void => {
console.log("set new opening", tijden, Openingstijden);
// console.log("set new opening", tijden, Openingstijden);
setNewOpening(tijden);
setNewOpeningstijden(Openingstijden);
return;
Expand Down

0 comments on commit 0d67b56

Please sign in to comment.