import { createSelector } from "reselect";
import {
    FETCH_EMPHASIS_JOBS_SUCCESS,
    FETCH_EMPHASIS_JOBS_FAILURE,
    FETCH_EMPHASIS_JOBS_REQUEST,

} from "../types";

export function emphasisJobs(state = {
}, action = {}) {

    switch (action.type) {

        case FETCH_EMPHASIS_JOBS_REQUEST:
            return {
                ...state,
                loading:true
            };
        case FETCH_EMPHASIS_JOBS_SUCCESS:
            return {
                ...action.res,
                loading:false
            };
        case FETCH_EMPHASIS_JOBS_FAILURE:
            return {
                ...state,
                errors: action.error,
                loading:false
            };

        default:
            return state;
    }
}


export const emphasisJobsHashSelector = state => state.emphasisJobs.data;

export const emphasisJobsSelector = createSelector(emphasisJobsHashSelector, hash =>
    Object.values(hash)
);
