Last active
August 15, 2020 07:46
-
-
Save skflowne/4ce8056d3cce859696bac872c27f5d68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react" | |
import { useRecoilValue } from "recoil" | |
import { format } from "date-fns" | |
import { mapboxToken } from "../../mapbox-token" | |
import { currentDateState } from "../../state/app" | |
import { API_DATE_FORMAT, statusByDateQuery, countriesQuery } from "../../state/api" | |
import DataMap from "./DataMap" | |
const TimelineMap = () => { | |
const viewDate = useRecoilValue(currentDateState) | |
const formattedDate = format(viewDate, API_DATE_FORMAT) | |
const dateStatus = useRecoilValue(statusByDateQuery(formattedDate)) | |
const countries = useRecoilValue(countriesQuery) | |
const data = dateStatus.map((status) => { | |
const country = countries[status.country] | |
return { | |
name: country.name, | |
coordinates: [country.longitude, country.latitude], | |
...status, | |
} | |
}) | |
return <DataMap mapboxToken={mapboxToken} data={data} /> | |
} | |
export default TimelineMap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment