From dd4e8e67f651f9c6b75f75e9eebf28bf8561399a Mon Sep 17 00:00:00 2001 From: Nishit Suwal <81785002+NSUWAL123@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:26:33 +0545 Subject: [PATCH] fix(frontend): use task status string directly (#1032) * fix: returned task status as string * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix (projectDetails): taskStatus - replace task status enum with task status string --------- Co-authored-by: sujanadh Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/frontend/src/components/DialogTaskActions.jsx | 10 +++++----- src/frontend/src/utilfunctions/getTaskStatusStyle.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/components/DialogTaskActions.jsx b/src/frontend/src/components/DialogTaskActions.jsx index d41bb965e3..5b0a3179c7 100755 --- a/src/frontend/src/components/DialogTaskActions.jsx +++ b/src/frontend/src/components/DialogTaskActions.jsx @@ -12,7 +12,7 @@ export default function Dialog({ taskId, feature, map, view }) { const token = CoreModules.useAppSelector((state) => state.login.loginToken); const loading = CoreModules.useAppSelector((state) => state.common.loading); const [list_of_task_status, set_list_of_task_status] = useState([]); - const [task_status, set_task_status] = useState(task_priority_str['READY']); + const [task_status, set_task_status] = useState('READY'); const geojsonStyles = MapStyles(); const dispatch = CoreModules.useAppDispatch(); @@ -34,11 +34,11 @@ export default function Dialog({ taskId, feature, map, view }) { })[0], }; const findCorrectTaskStatusIndex = environment.tasksStatus.findIndex( - (data) => data.label == task_priority_str[currentStatus.task_status], + (data) => data.label == currentStatus.task_status, ); const tasksStatus = feature.id_ != undefined ? environment.tasksStatus[findCorrectTaskStatusIndex]?.['label'] : ''; - set_task_status(task_priority_str[tasksStatus]); + set_task_status(tasksStatus); const tasksStatusList = feature.id_ != undefined ? environment.tasksStatus[findCorrectTaskStatusIndex]?.['action'] : []; @@ -53,7 +53,7 @@ export default function Dialog({ taskId, feature, map, view }) { const handleOnClick = (event) => { const status = task_priority_str[event.target.id]; const body = token != null ? { ...token } : {}; - const geoStyle = geojsonStyles[status]; + const geoStyle = geojsonStyles[event.target.id]; if (event.target.id != undefined) { if (body.hasOwnProperty('id')) { dispatch( @@ -103,7 +103,7 @@ export default function Dialog({ taskId, feature, map, view }) { {/* {`STATUS : ${task_status?.toString()?.replaceAll('_', ' ')}`} */} - {`STATUS : ${task_priority_str[task_status]}`} + {`STATUS : ${task_status}`} { let id = feature.getId().toString().replace('_', ','); - const status = task_priority_str[id.split(',')[1]]; + const status = id.split(',')[1]; const lockedPolygonStyle = createPolygonStyle(mapTheme.palette.mapFeatureColors.locked_for_mapping_rgb, strokeColor); const lockedValidationStyle = createPolygonStyle( mapTheme.palette.mapFeatureColors.locked_for_validation_rgb,