{"size": 1231, "ext": "js", "max_stars_repo_path": "src/reducers/tasks.js", "max_stars_repo_name": "AAlsop12/CheckList", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/reducers/tasks.js", "max_issues_repo_name": "AAlsop12/CheckList", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/reducers/tasks.js", "max_forks_repo_name": "AAlsop12/CheckList", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.7608695652, "max_line_length": 84, "alphanum_fraction": 0.358245329}
import { FETCH_TASKS, REDO_TASK, FINISH_TASK, FORGET_TASK } from '../actions/types';

export default function(state = [], action) {
    switch(action.type) {

        case FETCH_TASKS:
            return [ ...state, ...action.payload ]


        case REDO_TASK:
                return [ 
                    ...state.map((chore, index) => {
                        if(chore == action.payload) {
                            chore.finished = false,
                            chore.fluff = false
                        }
                        return chore
                    })
                 ]

        case FINISH_TASK:
            return [ 
                ...state.map((chore, index) => {
                    if(chore == action.payload) {
                        chore.finished = true
                    }
                    return chore
                })
        ]

        case FORGET_TASK:
                return [ 
                    ...state.map((chore, index) => {
                        if(chore == action.payload) {
                            chore.fluff = true
                        }
                        return chore
                    })
                 ]


        default: return state
    }
}

