Blame view

imports/client/views/org/admin/students/index.js 1.92 KB
d0099dd88   Deepak   student detail pa...
1
2
3
4
5
6
7
8
9
10
11
  // import { StudentDataController }            from '/imports/client/views/org/admin/students/index'
  import _                                  from 'lodash';
  import {
           composeWithTracker,
           compose,
           composeAll
         }                                  from 'react-komposer';
  import { Loading }                        from '/imports/client/components/Loading';
  
  import { Orgs }                           from '/imports/collections/orgs/index';
  import { Users }                          from '/imports/collections/users/index';
7aa6f173b   Deepak   added student view
12
  import { StudentView }                    from './StudentView';
c6b4fc634   Deepak   added students pu...
13
  import { Students }                       from '/imports/collections/students/index';
d0099dd88   Deepak   student detail pa...
14
15
16
17
18
19
20
  
  
  const meteorTick = (props, onData) => {
  
    const handles = [
      Meteor.subscribe('users.current'),
      Meteor.subscribe('orgs.current'),
c6b4fc634   Deepak   added students pu...
21
22
      Meteor.subscribe('users.forMyOrg'),
      Meteor.subscribe('student.forMyOrg'),
d0099dd88   Deepak   student detail pa...
23
24
25
26
27
    ];
  
    if(_.every(handles, (handle) => (handle.ready()) )) {
      const user = Users.current();
      const org = Orgs.current();
c32092e5e   Deepak   added condition o...
28
29
      students = Users.find({"role":"STUDENT"}).fetch() ? Users.find({"role":"STUDENT"}).fetch() : "";
      studentData = Students.find().fetch() ? Students.find().fetch() : "";
b02441289   Deepak   added verify module
30
31
32
33
34
35
36
37
      for(var i=0; i< students.length; i++){
        for(var j=0; j< studentData.length; j++){
          if(students[i]._id == studentData[j].userId){
            students[i].class = studentData[j].class;
            students[i].dob = studentData[j].dob;
          }
        }
      }
d0099dd88   Deepak   student detail pa...
38
39
      onData(null, {
        data: {
b02441289   Deepak   added verify module
40
41
42
43
          user:         user,
          org:          org,
          students:     students,
          studentData:  studentData
d0099dd88   Deepak   student detail pa...
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
        },
      });
    }
  
    return () => {
      _.each(handles, (handle) => handle.stop() );
    };
  };
  
  
  const reduxTick = (props, onData) => {
    onData(null, {
      data: {}
    });
  };
  
  
  export const StudentDataController = composeAll(
    composeWithTracker(meteorTick, Loading),
    compose(reduxTick, Loading),
7aa6f173b   Deepak   added student view
64
  )(StudentView);