This commit is contained in:
Lucas Verney 2021-04-28 20:11:37 +02:00
parent 7fc9077520
commit 3b9cf0917a

View File

@ -9,80 +9,80 @@ export default {
isLoading: (state) => state.loading > 0,
inseeCodesFlatsBuckets: (state, getters) => (filter) => {
const buckets = {};
const buckets = {}
state.flats.forEach((flat) => {
if (!filter || filter(flat)) {
const insee = flat.flatisfy_postal_code.insee_code;
const insee = flat.flatisfy_postal_code.insee_code
if (!buckets[insee]) {
buckets[insee] = {
name: flat.flatisfy_postal_code.name,
flats: [],
};
flats: []
}
}
buckets[insee].flats.push(flat);
buckets[insee].flats.push(flat)
}
});
})
return buckets;
return buckets
},
flatsMarkers: (state, getters) => (router, filter) => {
const markers = [];
const markers = []
state.flats.forEach((flat) => {
if (filter && filter(flat)) {
const gps = findFlatGPS(flat);
const gps = findFlatGPS(flat)
if (gps) {
const previousMarker = markers.find(
(marker) =>
marker.gps[0] === gps[0] && marker.gps[1] === gps[1]
);
)
if (previousMarker) {
// randomize position a bit
// gps[0] += (Math.random() - 0.5) / 500
// gps[1] += (Math.random() - 0.5) / 500
}
const href = router.resolve({
name: "details",
params: { id: flat.id },
}).href;
name: 'details',
params: { id: flat.id }
}).href
const cost = flat.cost
? costFilter(flat.cost, flat.currency)
: "";
: ''
markers.push({
title: "",
title: '',
content:
'<a href="' +
href +
'">' +
flat.title +
"</a>" +
'</a>' +
cost,
gps: gps,
flatId: flat.id,
});
flatId: flat.id
})
}
}
});
})
return markers;
return markers
},
allTimeToPlaces: (state) => {
const places = {};
const places = {}
Object.keys(state.timeToPlaces).forEach((constraint) => {
const constraintTimeToPlaces = state.timeToPlaces[constraint];
const constraintTimeToPlaces = state.timeToPlaces[constraint]
Object.keys(constraintTimeToPlaces).forEach((name) => {
places[name] = constraintTimeToPlaces[name];
});
});
return places;
places[name] = constraintTimeToPlaces[name]
})
})
return places
},
timeToPlaces: (state, getters) => (constraintName) => {
return state.timeToPlaces[constraintName];
return state.timeToPlaces[constraintName]
},
metadata: (state) => state.metadata,
};
metadata: (state) => state.metadata
}