From c8339e7099b312d19fbf8dfaf7b166aac6bb9d22 Mon Sep 17 00:00:00 2001 From: navins94 Date: Tue, 13 Feb 2024 19:14:27 +0530 Subject: [PATCH 1/3] [#1172] Add monitoring response --- frontend/src/components/EditableCell.jsx | 20 ++++++++++ frontend/src/lib/ui-text.js | 3 ++ .../src/pages/submissions/BatchDetail.jsx | 5 +++ .../pages/submissions/SubmissionEditing.jsx | 18 ++++++++- .../src/pages/submissions/UploadDetail.jsx | 39 +++++++++++++++++-- frontend/src/pages/submissions/style.scss | 13 +++++++ 6 files changed, 94 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/EditableCell.jsx b/frontend/src/components/EditableCell.jsx index 8a9ac40a5..b7c3662be 100644 --- a/frontend/src/components/EditableCell.jsx +++ b/frontend/src/components/EditableCell.jsx @@ -17,10 +17,12 @@ const EditableCell = ({ readonly = false, isPublic = false, resetButton, + lastValue = false, }) => { const [editing, setEditing] = useState(false); const [locationName, setLocationName] = useState(null); const [value, setValue] = useState(null); + const [oldValue, setOldValue] = useState(null); useEffect(() => { if ( @@ -34,11 +36,17 @@ const EditableCell = ({ record.newValue || record.newValue === 0 ? record.newValue : record.value; + setValue( record.type === "date" ? moment(newValue).format("YYYY-MM-DD") : newValue ); + setOldValue( + record.type === "date" + ? moment(record.lastValue).format("YYYY-MM-DD") + : record.lastValue + ); } }, [record]); @@ -82,6 +90,16 @@ const EditableCell = ({ : value; }; + const getLastAnswerValue = () => { + return record.type === "multiple_option" + ? oldValue?.join(", ") + : record.type === "option" + ? oldValue + ? oldValue[0] + : "-" + : oldValue; + }; + const renderAnswerInput = () => { return record.type === "option" ? (