Blame view
imports/client/views/org/admin/students/index.js
2.06 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() : ""; |
10b6cd02a
|
30 31 |
var mergedData; console.log(studentData); |
b02441289
|
32 33 |
for(var i=0; i< students.length; i++){ for(var j=0; j< studentData.length; j++){ |
10b6cd02a
|
34 35 |
if(students[i]._id == studentData[j].userId && studentData[j].admissionId){ students[i].admissionId = studentData[j].admissionId; |
b02441289
|
36 37 38 39 40 |
students[i].class = studentData[j].class; students[i].dob = studentData[j].dob; } } } |
d0099dd88
|
41 42 |
onData(null, { data: { |
b02441289
|
43 44 45 46 |
user: user, org: org, students: students, studentData: studentData |
d0099dd88
|
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
}, }); } return () => { _.each(handles, (handle) => handle.stop() ); }; }; const reduxTick = (props, onData) => { onData(null, { data: {} }); }; export const StudentDataController = composeAll( composeWithTracker(meteorTick, Loading), compose(reduxTick, Loading), |
7aa6f173b
|
67 |
)(StudentView); |