import { Reducer } from 'redux' ; import { createAction } from 'utils/redux' ; /**
 * Actions types.
 */ export enum Actions { EDIT = 'notes/EDIT' , RESTORE = 'notes/RESTORE' } /**
 * Initial state.
 */ export const initialState = { } ; param state param action return const notesReducer = ( state = initialState , action ) => { switch ( action . type ) { case Actions . EDIT : { const { id , note } = action . payload ; return { ... state , [ id ] : note , } ; } case Actions . RESTORE : { return { ... state , ... action . payload . json , } ; } default : { return state ; } } } ; export default notesReducer ; param id param note return export const updateNote = ( id , note ) => createAction ( Actions . EDIT , { id , note , } ) ; param json return export const restoreNotes = ( json ) => createAction ( Actions . RESTORE , { json , } ) ; /**
 * Notes actions.
 */ export type NotesActions = ReturnType < typeof updateNote > | ReturnType < typeof restoreNotes > ; /**
 * Notes state.
 */ export type NotesState = Record < string , string > ;