studentdatafields.reducer.ts 837 Bytes
Newer Older
1
import { IStudentDataFields, IStudentDataField } from './studentdatafields.types';
2
import { STUDENT_DATA_FIELDS_INITIAL_STATE } from './studentdatafields.initial-state';
3 4 5 6 7 8 9
import { Seq } from 'immutable';

import {
  STUDENTDATAFIELDS_RECEIVED,
  STUDENTDATAFIELDS_SAVE
} from '../../constants';

10
export function studentDataFieldsReducer(state: IStudentDataFields = STUDENT_DATA_FIELDS_INITIAL_STATE, action): IStudentDataFields {
11 12
  switch (action.type) {
    case STUDENTDATAFIELDS_SAVE:
13
        let studentDataFields = Array<IStudentDataField>();
14 15
        let ind=0;

16 17
        action.payload.studentDataFields.forEach(studentDataField => {
            studentDataFields.push(<IStudentDataField>studentDataField);
18 19 20
            ind++;
        });

21
        return Seq(studentDataFields).map(n => n).toList();
22 23 24
    default: return state;
  }
};