1- import { useDataSources } from "@/app/map/[id]/hooks/useDataSources" ;
21import { useInspector } from "@/app/map/[id]/hooks/useInspector" ;
32import { DataSourceRecordType } from "@/server/models/DataSource" ;
43import { MarkersList , MembersList } from "./MarkersLists" ;
54import type { MarkerFeature } from "@/types" ;
65
76export default function ClusterMarkersList ( ) {
8- const { getDataSourceById } = useDataSources ( ) ;
97 const { selectedRecords, inspectorContent } = useInspector ( ) ;
10- const dataSource = getDataSourceById ( inspectorContent ?. dataSource ?. id ) ;
11- const recordType = dataSource ?. recordType ;
8+ const recordType = inspectorContent ?. dataSource ?. recordType ;
129 const markerFeatures = selectedRecords
1310 . map ( ( r ) : MarkerFeature | null => {
1411 if ( ! r . dataSourceId || ! r . geocodePoint ) {
@@ -18,7 +15,8 @@ export default function ClusterMarkersList() {
1815 return {
1916 type : "Feature" ,
2017 geometry : {
21- coordinates : [ r . geocodePoint . lng , r . geocodePoint . lat ] ,
18+ // [0, 0] should never happen because these records are in a cluster on the map
19+ coordinates : [ r . geocodePoint ?. lng || 0 , r . geocodePoint ?. lat || 0 ] ,
2220 type : "Point" ,
2321 } ,
2422 properties : {
@@ -35,12 +33,15 @@ export default function ClusterMarkersList() {
3533 < div className = "flex flex-col gap-6" >
3634 { recordType === DataSourceRecordType . Members ? (
3735 < MembersList
38- dataSource = { dataSource }
36+ dataSource = { inspectorContent ?. dataSource }
3937 markers = { markerFeatures }
4038 areaType = "cluster"
4139 />
4240 ) : (
43- < MarkersList dataSource = { dataSource } markers = { markerFeatures } />
41+ < MarkersList
42+ dataSource = { inspectorContent ?. dataSource }
43+ markers = { markerFeatures }
44+ />
4445 ) }
4546 </ div >
4647 ) ;
0 commit comments