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 |
students = Users.find({"role":"STUDENT"}).fetch() ? Users.find({"role":"STUDENT"}).fetch() : ""; |
691a06c2f
|
29 |
console.log(students); |
c32092e5e
|
30 |
studentData = Students.find().fetch() ? Students.find().fetch() : ""; |
b02441289
|
31 32 33 34 35 36 37 38 |
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
|
39 40 |
onData(null, { data: { |
b02441289
|
41 42 43 44 |
user: user, org: org, students: students, studentData: studentData |
d0099dd88
|
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
}, }); } return () => { _.each(handles, (handle) => handle.stop() ); }; }; const reduxTick = (props, onData) => { onData(null, { data: {} }); }; export const StudentDataController = composeAll( composeWithTracker(meteorTick, Loading), compose(reduxTick, Loading), |
7aa6f173b
|
65 |
)(StudentView); |