1
1
import React from 'react' ;
2
2
import { Popup } from 'react-map-gl' ;
3
3
import { useSelector } from 'react-redux' ;
4
+
5
+ import { getFeatureInfoClick } from 'reducers/osrdconf/selectors' ;
4
6
import PopupInfos from 'common/Map/Popup/PopupInfos' ;
5
7
import PopupInfosCustomContent from 'applications/osrd/components/OSRDConfMap/PopupInfosCustomContent' ;
6
8
import PopupInfosCustomTitle from 'applications/osrd/components/OSRDConfMap/PopupInfosCustomTitle' ;
7
9
8
10
export default function RenderPopup ( ) {
9
- const { featureInfoClick } = useSelector ( ( state ) => state . osrdconf ) ;
11
+ const featureInfoClick = useSelector ( getFeatureInfoClick ) ;
10
12
if ( featureInfoClick . displayPopup ) {
11
13
let backgroundColor ;
12
14
switch ( featureInfoClick . feature . properties . typeVoie ) {
@@ -19,11 +21,14 @@ export default function RenderPopup() {
19
21
break ;
20
22
}
21
23
22
- featureInfoClick . feature . properties . source = featureInfoClick . feature . source ;
23
- featureInfoClick . feature . properties . clickLngLat = [
24
- featureInfoClick . coordinates [ 0 ] ,
25
- featureInfoClick . coordinates [ 1 ] ,
26
- ] ;
24
+ const properties = {
25
+ ...featureInfoClick . feature . properties ,
26
+ source : featureInfoClick . feature . source ,
27
+ clickLngLat : [
28
+ featureInfoClick . coordinates [ 0 ] ,
29
+ featureInfoClick . coordinates [ 1 ] ,
30
+ ]
31
+ }
27
32
28
33
return (
29
34
< Popup
@@ -33,8 +38,8 @@ export default function RenderPopup() {
33
38
className = "mapboxgl-hover-custom-popup"
34
39
>
35
40
< PopupInfos
36
- title = { < PopupInfosCustomTitle properties = { featureInfoClick . feature . properties } /> }
37
- content = { < PopupInfosCustomContent data = { featureInfoClick . feature . properties } /> }
41
+ title = { < PopupInfosCustomTitle properties = { properties } /> }
42
+ content = { < PopupInfosCustomContent data = { properties } /> }
38
43
backgroundColor = { backgroundColor }
39
44
/>
40
45
</ Popup >
0 commit comments