diff --git a/app/.eslintrc.json b/app/.eslintrc.json index f93713ac9..6a1a835a6 100644 --- a/app/.eslintrc.json +++ b/app/.eslintrc.json @@ -18,7 +18,6 @@ "files": ["**/*.test.js", "**/*.test.jsx"], "env": { "jest": true - } } ], "rules": { 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" ? (