store.ts 1.33 KB
Newer Older
1
2
import { combineReducers } from 'redux';
import * as courseFields from './coursefields';
3
import * as sectorFields from './sectorfields';
4
import * as regions from './regionschools';
5
import * as sectors from './sectorcourses';
6
import * as studentDataFields from './studentdatafields';
7
8
9
10
11
12
13

/*
 * This is where we 'assemble' the full store out of its modules.
 */

export interface IAppState {
    courseFields?: courseFields.ICourseFields;
14
    sectorFields?: sectorFields.ISectorFields;
15
    regions?: regions.IRegions;
16
    sectors?: sectors.ISectors;
17
    studentDataFields?: studentDataFields.IStudentDataFields;
18
19
20
21
};

export const rootReducer = combineReducers<IAppState>({
   courseFields: courseFields.courseFieldsReducer,
22
   sectorFields: sectorFields.sectorFieldsReducer,
23
   regions: regions.regionSchoolsReducer,
24
   sectors: sectors.sectorCoursesReducer,
25
   studentDataFields: studentDataFields.studentDataFieldsReducer,
26
27
28
29
});

export function deimmutify(state: IAppState): Object {
  return {
30
    courseFields: courseFields.deimmutifyCourseFields(state.courseFields),
31
    sectorFields: sectorFields.deimmutifySectorFields(state.sectorFields),
32
    regions: regions.deimmutifyRegionSchools(state.regions),
33
    sectors: sectors.deimmutifySectorCourses(state.sectors),
34
    studentdataFields: studentDataFields.deimmutifyStudentDataFields(state.studentDataFields),
35
36
  };
}