Skip to content

Commit

Permalink
#469 Make ideas/actions pretty and recognisable
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriána Kohanová committed Dec 10, 2020
1 parent 48e5071 commit c21b228
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions js/reducers/tracking/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,8 @@ const getTrackingActions = projectID => (dispatch, getState) => {
let listToSet = [];
results.forEach(r => {
let resultActions = JSON.parse(r.actions);
listToSet.push(...resultActions);
let actions = resultActions.map(obj => ({ ...obj, actionId: r.id }));
listToSet.push(...actions);
});

let projectActions = [...listToSet, ...sendActions];
Expand Down Expand Up @@ -1534,23 +1535,32 @@ export const updateTrackingActions = action => (dispatch, getState) => {
const project = state.projectReducers.currentProject;
const projectActions = state.trackingReducers.project_actions_list;
const projectID = project && project.projectID;
const actionID = action && action.Id;
let actionID = action && action.actionId;

if (projectID && actionID) {
const dataToSend = {
last_update_date: moment().format(),
actions: JSON.stringify(projectActions)
};
return api({
url: `${base_url}/api/session-actions/${projectID}/${actionID}`,
method: METHOD.PUT,
data: JSON.stringify(dataToSend)
})
.then(() => {})
.catch(error => {
throw new Error(error);
if (projectID && actionID && projectActions) {
let actions = projectActions.filter(a => a.actionId === actionID);

if (actions && actions.length > 0) {
const dataToSend = {
session_action_id: actionID,
session_project: projectID,
author: project.authorID,
last_update_date: moment().format(),
actions: JSON.stringify(actions)
};
return api({
url: `${base_url}/api/session-actions/${actionID}`,
method: METHOD.PUT,
data: JSON.stringify(dataToSend)
})
.finally(() => {});
.then(() => {})
.catch(error => {
throw new Error(error);
})
.finally(() => {});
} else {
return Promise.resolve();
}
} else {
return Promise.resolve();
}
Expand Down

0 comments on commit c21b228

Please sign in to comment.