import {Action} from '@ngrx/store';

import {SubCategory} from '../../ecm-model/subcategory-model';
import {SubCategoryActions} from '../actions';

export type SubCategoryState = SubCategory;
const initialState: SubCategoryState = {
         scatCode: '',
         catCode:  '',
         descr:  '',
         shDescr:  '',
         curRank: '',
         catLink: '',
         ecmTemplate: ''
}; 

export default function (state = initialState, action: Action): SubCategoryState {
    switch (action.type) {
        case SubCategoryActions.RESET_BLANK_SUBCATEGORY: {
            return initialState;
        }
        case SubCategoryActions.GET_SUBCATEGORY_SUCCESS: {
            return action.payload;
        }
        default: {
            return state;
        }
    }
}