From 895ca1106ea975b96c8d6864a79cd2ac5d79e7c1 Mon Sep 17 00:00:00 2001 From: stdavis Date: Tue, 5 Nov 2024 17:06:40 -0700 Subject: [PATCH] feat: add data submitter to sampling event data Closes #239 --- src/components/location/Location.jsx | 16 ++++++++++++++-- src/config.js | 1 + src/hooks/samplingEventContext.jsx | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/location/Location.jsx b/src/components/location/Location.jsx index 01a743eb..1b498138 100644 --- a/src/components/location/Location.jsx +++ b/src/components/location/Location.jsx @@ -10,6 +10,7 @@ import StartDistDirGeoDef from './StartDistDirGeoDef.jsx'; import StartEndGeoDef from './StartEndGeoDef.jsx'; import Station from './Station.jsx'; import VerifyMap from './VerifyMap.jsx'; +import useAuthentication from '../../hooks/useAuthentication'; // successfullyVerifiedMsg: String // message displayed on the verify location button after success @@ -36,6 +37,17 @@ const Location = () => { const [startEndParams, setStartEndParams] = useState(emptyStartEndParams); const [startDistDirParams, setStartDistDirParams] = useState(emptyStartDistDirParams); const [currentGeoDef, setCurrentGeoDef] = useState(START_END); + const { user } = useAuthentication(); + + useEffect(() => { + if (user) { + eventDispatch({ + type: actionTypes.LOCATION, + meta: fieldNames.SUBMITTER, + payload: user.email, + }); + } + }, [eventDispatch, user]); const path = useRef(null); const geometry = eventState[config.tableNames.samplingEvents].geometry; @@ -198,7 +210,7 @@ const Location = () => { paths.push( path.map(function (c) { return [c[1], c[0]]; - }) + }), ); }); returnData.path = paths; @@ -344,7 +356,7 @@ const Location = () => { actionTypes.LOCATION, config.tableNames.samplingEvents, fieldName, - parser + parser, ); }; diff --git a/src/config.js b/src/config.js index 5a280324..6bce2126 100644 --- a/src/config.js +++ b/src/config.js @@ -37,6 +37,7 @@ const fieldNames = { WEATHER: 'WEATHER', PURPOSE: 'SURVEY_PURPOSE', OBSERVERS: 'OBSERVERS', + SUBMITTER: 'SUBMITTER', }, equipment: { EVENT_ID: fldEVENT_ID, diff --git a/src/hooks/samplingEventContext.jsx b/src/hooks/samplingEventContext.jsx index 1403bfbd..ef476a45 100644 --- a/src/hooks/samplingEventContext.jsx +++ b/src/hooks/samplingEventContext.jsx @@ -153,6 +153,7 @@ const getBlankState = () => { [config.fieldNames.samplingEvents.STATION_ID]: null, [config.fieldNames.samplingEvents.SEGMENT_LENGTH]: null, [config.fieldNames.samplingEvents.NUM_PASSES]: 1, + [config.fieldNames.samplingEvents.SUBMITTER]: null, }, geometry: null, },