Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const editRow = (endpoint, rowId, data) => (dispatch, getState) => {
dispatch(loadingStart());
return API.patch("treehacks", `/${endpoint}/${rowId}`, {
body: data
}).then(e => {
const adminState = (getState().admin as IAdminState);
const applicationList = adminState.applicationList;
let application = find(applicationList, { "_id": rowId });
for (let key in data) {
set(application, key, data[key]);
}
dispatch(setApplicationList(applicationList, adminState.pages)); // So that the table refreshes
dispatch(loadingEnd());
}).catch(e => {
console.error(e);
dispatch(loadingEnd());
alert("Error performing edit row " + e);
});
}