-
Notifications
You must be signed in to change notification settings - Fork 15
/
reviewLocationsCollection.tsx
38 lines (32 loc) · 1.22 KB
/
reviewLocationsCollection.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from "react";
import { observer, inject } from 'mobx-react';
import "./Styles.scss";
import { IReviewComponentStore, ReviewLocation } from './reviewStore';
import ReviewLocationComponent from './reviewLocationComponent';
interface ReviewLocationCollectionProps {
onLocationClick(reviewLocation: ReviewLocation): void;
reviewStore?: IReviewComponentStore;
currentLocation: ReviewLocation;
}
@inject('reviewStore')
@observer
export default class ReviewLocationsCollection extends React.Component<ReviewLocationCollectionProps> {
onLocationClick = (e, location: ReviewLocation) => {
e.stopPropagation();
this.props.onLocationClick(location);
};
render() {
const { filteredReviewLocations, filter } = this.props.reviewStore!;
const locations = [...filteredReviewLocations];
if (this.props.currentLocation && !locations.some(location => location === this.props.currentLocation)) {
locations.push(this.props.currentLocation);
}
return (
<div>
{filter.showPoints &&
locations.map(location =>
<ReviewLocationComponent key={location.id || "unsaved"} location={location} showDialog={(e) => this.onLocationClick(e, location)} />
)}
</div>)
};
}