diff client/src/fairway/store.js @ 1025:a55f20dc8d8d

refac: store profiles by date
author Thomas Junk <thomas.junk@intevation.de>
date Wed, 24 Oct 2018 13:09:54 +0200
parents e89be4af3a9f
children 04a9e78dcc5f
line wrap: on
line diff
--- a/client/src/fairway/store.js	Wed Oct 24 12:29:25 2018 +0200
+++ b/client/src/fairway/store.js	Wed Oct 24 13:09:54 2018 +0200
@@ -24,7 +24,7 @@
     totalLength: 0,
     minAlt: 0,
     maxAlt: 0,
-    currentProfile: [],
+    currentProfile: {},
     waterLevels: [{ year: "2016", level: DEMOLEVEL, color: "#005DFF" }],
     selectedWaterLevel: DEMOLEVEL,
     fairwayCoordinates: [],
@@ -43,7 +43,8 @@
     setSelectedWaterLevel: (state, level) => {
       state.selectedWaterLevel = level;
     },
-    profileLoaded: (state, response) => {
+    profileLoaded: (state, answer) => {
+      const { response, surveyDate } = answer;
       const { data } = response;
       const coordinates = data.geometry.coordinates;
       if (!coordinates) return;
@@ -51,7 +52,7 @@
       const endPoint = state.endPoint;
       const geoJSON = data;
       const result = prepareProfile({ geoJSON, startPoint, endPoint });
-      state.currentProfile = result.points;
+      state.currentProfile[surveyDate] = result.points;
       state.minAlt = result.minAlt;
       state.maxAlt = result.maxAlt;
       state.totalLength = result.lengthPolyLine;
@@ -66,7 +67,7 @@
       state.fairwayCoordinates = coordinates;
     },
     clearCurrentProfile: state => {
-      state.currentProfile = [];
+      state.currentProfile = {};
     }
   }
 };