From d79f32214cde13af6773317fbf0a1bf5117f1579 Mon Sep 17 00:00:00 2001 From: Leon K Date: Sat, 15 Jul 2023 23:57:48 +0200 Subject: [PATCH] change required clicks and automatic update to show table --- frontend/src/components/Markers.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/Markers.tsx b/frontend/src/components/Markers.tsx index bb890f0..9c3f47c 100644 --- a/frontend/src/components/Markers.tsx +++ b/frontend/src/components/Markers.tsx @@ -29,11 +29,15 @@ function Markers({ conditions }: { conditions: WaypointRecord[] }) { const handleMarkerClick = (name: string) => { setDrawnConditions(previousValue => { - const index = previousValue.findIndex(element => element.waypoint.name === name); - - previousValue[index].drawn = !previousValue[index].drawn; - - return previousValue; + return previousValue.map(condition => { + if (condition.waypoint.name === name) { + return { + ...condition, + drawn: !condition.drawn, + }; + } + return condition; + }); }); };