{"size": 1175, "ext": "js", "max_stars_repo_path": "src/reducers/employeeListReducer.js", "max_stars_repo_name": "vutuanhai237/JewelleryShopManagement", "max_stars_repo_stars_event_min_datetime": "2020-03-26T10:44:18.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-30T07:18:20.000Z", "max_issues_repo_path": "src/reducers/employeeListReducer.js", "max_issues_repo_name": "vutuanhai237/QuanLyCuaHangVBDQ", "max_issues_repo_issues_event_min_datetime": "2020-04-29T08:18:57.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-06T00:38:01.000Z", "max_forks_repo_path": "src/reducers/employeeListReducer.js", "max_forks_repo_name": "vutuanhai237/JewelleryShopManagement", "max_forks_repo_forks_event_min_datetime": "2020-03-26T10:44:29.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-26T10:44:29.000Z"}
{"max_stars_count": 3, "max_issues_count": 11, "max_forks_count": 1, "avg_line_length": 25.0, "max_line_length": 56, "alphanum_fraction": 0.5259574468}
import {
    EMPLOYEES_FETCH_LIST_LOADING,
    EMPLOYEES_FETCH_LIST_SUCCESS,
    EMPLOYEES_CHANGE_SELECTED_EMPLOYEE,
    EMPLOYEES_LIST_CHANGED,
} from '../constants';

const initialState = {
    loading: true,
    employees: [],
    selected: null,
    count: 0,
    changed: false,
}

function employeeReducer(state = initialState, action) {
    switch (action.type) {
        case EMPLOYEES_FETCH_LIST_LOADING:
            return {
                ...state,
                loading: true,
                changed: false,
            }
        case EMPLOYEES_FETCH_LIST_SUCCESS:
            return {
                ...state,
                employees: action.payload.employees,
                count: action.payload.count,
                loading: false,
                changed: false,
            }
        case EMPLOYEES_CHANGE_SELECTED_EMPLOYEE:
            return {
                ...state,
                selected: action.payload,
            }
        case EMPLOYEES_LIST_CHANGED:
            return {
                ...state,
                changed: true,
            }
        default:
            return initialState;
    }
}

export default employeeReducer;