Skip to content

Commit

Permalink
fix(frontend): use task status string directly (hotosm#1032)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and nischalstha9 committed Dec 8, 2023
1 parent 00e1413 commit dd4e8e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/frontend/src/components/DialogTaskActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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'] : [];

Expand All @@ -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(
Expand Down Expand Up @@ -103,7 +103,7 @@ export default function Dialog({ taskId, feature, map, view }) {
<CoreModules.Stack direction={'row'} pl={1}>
<CoreModules.Typography variant="h3">
{/* {`STATUS : ${task_status?.toString()?.replaceAll('_', ' ')}`} */}
{`STATUS : ${task_priority_str[task_status]}`}
{`STATUS : ${task_status}`}
</CoreModules.Typography>
</CoreModules.Stack>
<CoreModules.Link
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/utilfunctions/getTaskStatusStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function createIconStyle(iconSrc,customLabel) {
}
const getTaskStatusStyle = (feature,resolution, mapTheme) => {
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,
Expand Down

0 comments on commit dd4e8e6

Please sign in to comment.