Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function form(state = INITIAL_STATE, action) {
switch (action.type) {
case FORM_RECORD_LOADED:
return {
...state,
record: action.record,
formData: cleanRecord(action.record, FORMDATA_IGNORE_FIELDS),
};
case FORM_RECORD_UNLOADED:
return {...state, record: null, formData: null};
case FORM_DATA_RECEIVED:
return {...state, formData: action.formData};
default:
return state;
}
}
return (dispatch, getState) => {
const {record, formData} = getState().form;
const cleanFormData = cleanRecord(formData, FORMDATA_IGNORE_FIELDS);
dispatch(update({...record, ...cleanFormData}));
};
}
return action.conflicts.reduce((acc, conflict) => {
acc[conflict.local.id] = {
...conflict,
local: cleanRecord(conflict.local, ["_status"])
};
return acc;
}, {});
}