Skip to content

Commit

Permalink
Incorporate fire data as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
katamartin committed Jun 18, 2024
1 parent 821536c commit a391bc5
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions pages/research/forest-offsets-fires.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useState } from 'react'
import { useBreakpointIndex } from '@theme-ui/match-media'
import { Box } from 'theme-ui'
import { Layout, Guide, Dimmer, Tray } from '@carbonplan/components'
import { Layout, Guide, Dimmer } from '@carbonplan/components'
import Desktop from '../../components/desktop'
import Mobile from '../../components/mobile'
import projects from '../../data/projects-fires'
Expand Down Expand Up @@ -29,7 +28,7 @@ const Index = ({ fireData, createdAt }) => {
type: 'Feature',
properties: {
id: d.id,
fire: Object.keys(fireData).includes(d.id),
fire: fireData.find((f) => f.opr_id === d.id),
},
geometry: {
type: 'Point',
Expand Down Expand Up @@ -58,6 +57,22 @@ const Index = ({ fireData, createdAt }) => {

const locations = { fires: fireLocations, projects: projectLocations }

const merged = projects.map((project) => {
let fire
const el = fireData.find((f) => f.opr_id === project.id)
if (el && Object.keys(el.fires).length > 0) {
fire = {
overlappingFires: Object.keys(el.fires).map((id) => {
if (el.fires[id])
return { name: el.fires[id].name, href: el.fires[id].url }
}),
burnedFraction: el.burned_fraction,
lastUpdated: createdAt,
}
}
return { ...project, fire }
})

const index = useBreakpointIndex()

return (
Expand All @@ -76,7 +91,7 @@ const Index = ({ fireData, createdAt }) => {
metadata={false}
>
<Desktop
data={projects}
data={merged}
locations={locations}
tiles={tiles}
showFires={true}
Expand Down Expand Up @@ -109,7 +124,7 @@ const Index = ({ fireData, createdAt }) => {
>
<Guide />
<Mobile
data={projects}
data={merged}
locations={locations}
tiles={tiles}
showFires={true}
Expand Down

0 comments on commit a391bc5

Please sign in to comment.