implement page controller

This commit is contained in:
Amruth Pillai
2020-04-01 12:47:17 +05:30
parent 3a9a0dc811
commit ad9105f4a4
12 changed files with 208 additions and 60 deletions

View File

@ -90,4 +90,25 @@ const moveItemDown = (dispatch, key, value) => {
saveData(dispatch);
};
export { move, hexToRgb, copyToClipboard, saveData, addItem, deleteItem, moveItemUp, moveItemDown };
const importJson = (event, dispatch) => {
const fr = new FileReader();
fr.addEventListener('load', () => {
const importedObject = JSON.parse(fr.result);
console.log(importedObject);
dispatch({ type: 'import_data', payload: importedObject });
dispatch({ type: 'save_data' });
});
fr.readAsText(event.target.files[0]);
};
export {
move,
hexToRgb,
copyToClipboard,
saveData,
addItem,
deleteItem,
moveItemUp,
moveItemDown,
importJson,
};