From a4671dfdd847c0f8d2cc15292322a49fd2b9ccf5 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 4 Oct 2023 14:15:25 +0200 Subject: [PATCH] hotfix: fix parsing schema in task --- src/reducer.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/reducer.js b/src/reducer.js index a918303..4fd8666 100644 --- a/src/reducer.js +++ b/src/reducer.js @@ -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', @@ -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, };