Skip to content

Commit

Permalink
fix leveling higher order components
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Aug 10, 2023
1 parent 56a2d82 commit 9eb8c47
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions src/hooks/UseMRProperties/UseMRProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,47 @@ import AsIdentifiableFeature
const useMRProperties = workspaceContext => {
const [properties, setProperties] = useState({})

if(workspaceContext){
useEffect(() => {
const mrProperties = {
'#mapZoom': workspaceContext['taskMapZoom'],
}
useEffect(() => {
if(workspaceContext){
return null
}

const task = workspaceContext['taskMapTask']
if (task) {
const primaryFeature =
AsIdentifiableFeature(AsMappableTask(task).normalizedGeometries().features[0])

mrProperties['#mrTaskId'] = task.id
mrProperties['#osmId'] = primaryFeature.osmId()
mrProperties['#osmType'] = primaryFeature.osmType()

//map the task specific properties to the workspace properties
const { properties } = primaryFeature;
if (properties) {
Object.keys(properties).map((key) => {
mrProperties[key] = properties[key];
return null;
});
}
}
const mrProperties = {
'#mapZoom': workspaceContext['taskMapZoom'],
}

const task = workspaceContext['taskMapTask']
if (task) {
const primaryFeature =
AsIdentifiableFeature(AsMappableTask(task).normalizedGeometries().features[0])

const mapBounds = workspaceContext['taskMapBounds']
if (mapBounds) {
mrProperties['#mapLat'] = mapBounds.getCenter().lat
mrProperties['#mapLon'] = mapBounds.getCenter().lng
mrProperties['#mapBBox'] = mapBounds.toBBoxString()
mrProperties['#mapWest'] = mapBounds.getWest()
mrProperties['#mapSouth'] = mapBounds.getSouth()
mrProperties['#mapEast'] = mapBounds.getEast()
mrProperties['#mapNorth'] = mapBounds.getNorth()
mrProperties['#mrTaskId'] = task.id
mrProperties['#osmId'] = primaryFeature.osmId()
mrProperties['#osmType'] = primaryFeature.osmType()

//map the task specific properties to the workspace properties
const { properties } = primaryFeature;
if (properties) {
Object.keys(properties).map((key) => {
mrProperties[key] = properties[key];
return null;
});
}
}

const mapBounds = workspaceContext['taskMapBounds']
if (mapBounds) {
mrProperties['#mapLat'] = mapBounds.getCenter().lat
mrProperties['#mapLon'] = mapBounds.getCenter().lng
mrProperties['#mapBBox'] = mapBounds.toBBoxString()
mrProperties['#mapWest'] = mapBounds.getWest()
mrProperties['#mapSouth'] = mapBounds.getSouth()
mrProperties['#mapEast'] = mapBounds.getEast()
mrProperties['#mapNorth'] = mapBounds.getNorth()
}

setProperties(mrProperties)
}, [workspaceContext])
}
setProperties(mrProperties)
}, [workspaceContext])

return properties
}
Expand Down

0 comments on commit 9eb8c47

Please sign in to comment.