Skip to content

Commit

Permalink
hotfix: fix parsing schema in task
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan committed Oct 4, 2023
1 parent 342d5b9 commit a4671df
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import {
CLEAR, ERROR, REQUEST, SUCCESS,
} from './utils/action-type';

function parseTaskData(object) {
if (object?.beneficiary_data_schema) {
return { ...object, beneficiary_data_schema: JSON.stringify(object.beneficiary_data_schema) };
}
return object;
}
export const ACTION_TYPE = {
MUTATION: 'TASK_MANAGEMENT_MUTATION',
SEARCH_TASK_GROUPS: 'TASK_MANAGEMENT_TASK_GROUPS',
Expand Down Expand Up @@ -109,13 +115,13 @@ function reducer(
task: parseData(action.payload.data.task)?.map((task) => ({
...task,
id: decodeId(task.id),
currentEntityData: JSON.parse((JSON.parse(task.currentEntityData))),
data: JSON.parse(task.data, (key, value) => {
currentEntityData: parseTaskData(JSON.parse((JSON.parse(task.currentEntityData)))),
data: parseTaskData(JSON.parse(task.data, (key, value) => {
if (['date_valid_to', 'date_valid_from'].includes(key)) {
return `${value} 00:00:00`;
}
return value;
}),
})),
}))?.[0],
errorTask: null,
};
Expand Down

0 comments on commit a4671df

Please sign in to comment.