import { createSelector } from "reselect";
import {
    FETCH_COMPANY_REQUEST,
    FETCH_COMPANY_SUCCESS,
    FETCH_COMPANY_FAILURE,
    CLEAR_COMPANY
} from "../types";

export function company(state = {
}, action = {}) {
    switch (action.type) {
        case FETCH_COMPANY_REQUEST:
            return {
                ...state,
                loading: true
            };
        case FETCH_COMPANY_SUCCESS:
            return {
                ...state,
                ...action.res,
                loading: false
            };
        case FETCH_COMPANY_FAILURE:
            return {
                ...state,
                errors: action.error,
                loading: false
            };
        case CLEAR_COMPANY:
            return {};
        default:
            return state;
    }
}
