import { createSelector } from "reselect";
import {
    FETCH_JOB_REQUEST,
    FETCH_JOB_SUCCESS,
    FETCH_JOB_FAILURE,
    CLEAR_AD
} from "../types";

export function ad(state = {
}, action = {}) {
    switch (action.type) {
        case FETCH_JOB_REQUEST:
            return {
                ...state,
               loading:true
            };
        case FETCH_JOB_SUCCESS:
            return {
                ...state,
                ...action.res,
                loading: false
            };
        case FETCH_JOB_FAILURE:
            return {
                ...state,
                errors: action.error,
                loading: false
            };
        case CLEAR_AD:
            return {};
        default:
            return state;
    }
}


// export const AdHashSelector = state => state.ad.data;

// export const AdSelector = createSelector(AdHashSelector, hash =>
//   Object.values(hash)
// );
