Skip to content

Commit

Permalink
Avoid repeated platforms in the map legend
Browse files Browse the repository at this point in the history
  • Loading branch information
willemarcel committed Dec 18, 2023
1 parent ad52cf2 commit d8c0071
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/timeline/__tests__/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe("MapLegend", () => {
platforms={[
{ name: "Falcon", type: "Jet" },
{ name: "Campaign FS", type: "static" },
{ name: "Campaign FS", type: "static" },
]}
selectedPlatform={""}
setSelectedPlatform={fn}
Expand All @@ -29,11 +30,12 @@ describe("MapLegend", () => {
expect(instance.findByType(LineIcon).props.size).toBe("text")
expect(instance.findByType(CircleIcon).props.size).toBe("extra-tiny")
})
it("render option with one selected", () => {
it("render with one option selected", () => {
const fn = jest.fn()
const element = renderer.create(
<MapLegend
platforms={[
{ name: "Falcon", type: "Jet" },
{ name: "Falcon", type: "Jet" },
{ name: "Campaign FS", type: "static" },
]}
Expand Down
6 changes: 5 additions & 1 deletion src/components/timeline/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,14 @@ export const MapLegend = ({
setSelectedPlatform,
selectedPlatform,
}) => {
const names = platforms.map(i => i.name)
const uniquePlatforms = platforms.filter(
(i, index) => names.indexOf(i.name) === index
)
return (
<LegendBox>
<h3>Platforms</h3>
{platforms.map(platform => (
{uniquePlatforms.map(platform => (
<button
key={platform.name}
onClick={() =>
Expand Down
2 changes: 1 addition & 1 deletion src/components/timeline/timeline-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const TimelineChart = ({ deployments, bounds, campaignName }) => {
const fetchData = async () => {
try {
const response = await fetch(
`https://proxy.willemarcel.workers.dev/?https://65721c8ff4a4f70099bd9ee0--visionary-sopapillas-62534f.netlify.app/${campaignName}.geojson `,
`https://proxy.willemarcel.workers.dev/?https://657ce9f3a6dfa74fdbb10d02--visionary-sopapillas-62534f.netlify.app/${campaignName}.geojson `,
{
method: "GET",
headers: {
Expand Down

0 comments on commit d8c0071

Please sign in to comment.