Blame view
imports/client/views/org/admin/students/index.js
1.95 KB
d0099dd88
|
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
|
12 |
import { StudentView } from './StudentView'; |
c6b4fc634
|
13 |
import { Students } from '/imports/collections/students/index'; |
d0099dd88
|
14 15 16 17 18 19 20 |
const meteorTick = (props, onData) => { const handles = [ Meteor.subscribe('users.current'), Meteor.subscribe('orgs.current'), |
c6b4fc634
|
21 22 |
Meteor.subscribe('users.forMyOrg'), Meteor.subscribe('student.forMyOrg'), |
d0099dd88
|
23 24 25 26 27 |
]; if(_.every(handles, (handle) => (handle.ready()) )) { const user = Users.current(); const org = Orgs.current(); |
c32092e5e
|
28 29 |
students = Users.find({"role":"STUDENT"}).fetch() ? Users.find({"role":"STUDENT"}).fetch() : ""; studentData = Students.find().fetch() ? Students.find().fetch() : ""; |
bdd4abb61
|
30 31 32 33 34 35 |
for(var i=0; i< studentData.length; i++){ for(var j=0; j< students.length; j++){ if(studentData[i].userId == students[j]._id && studentData[i].admissionId){ studentData[i].firstName = students[j].firstName; studentData[i].lastName = students[j].lastName; }else{ |
b02441289
|
36 37 38 |
} } } |
d0099dd88
|
39 40 |
onData(null, { data: { |
b02441289
|
41 42 |
user: user, org: org, |
b02441289
|
43 |
studentData: studentData |
d0099dd88
|
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
|
64 |
)(StudentView); |