Blame view

imports/client/views/org/admin/staff/index.js 1.96 KB
a8c5a7fb6   Deepak   added teachers view
1
2
3
4
5
6
7
8
9
10
11
  // import { InviteSignupController } from '/imports/client/views/invite/signup/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';
925ffa9d3   Deepak   changed teachers ...
12
13
  import { Staffs }                          from '/imports/collections/staff/index';
  import { StaffView }                      from './StaffView';
a8c5a7fb6   Deepak   added teachers view
14
15
16
17
18
  
  const meteorTick = (props, onData) => {
  
    const handles = [
      Meteor.subscribe('users.current'),
ec5f044a9   Deepak   Finished add teac...
19
20
21
      Meteor.subscribe('orgs.current'),
      Meteor.subscribe('users.forMyOrg'),
      Meteor.subscribe('staff.forMyOrg'),
a8c5a7fb6   Deepak   added teachers view
22
23
24
25
26
    ];
  
    if(_.every(handles, (handle) => (handle.ready()) )) {
      const user = Users.current();
      const org = Orgs.current();
ec5f044a9   Deepak   Finished add teac...
27
28
      staff = Users.find({"role":"STAFF"}).fetch() ? Users.find({"role":"STAFF"}).fetch() : "";
      console.log(Users.find({"role":"STAFF"}).fetch());
925ffa9d3   Deepak   changed teachers ...
29
      staffData = Staffs.find().fetch() ? Staffs.find().fetch() : "";
ec5f044a9   Deepak   Finished add teac...
30
31
      console.log("staffData");
      console.log(staffData);
925ffa9d3   Deepak   changed teachers ...
32
      for(var i=0; i< staff.length; i++){
ec5f044a9   Deepak   Finished add teac...
33
        for(var j=0; j< staffData.length; j++){
925ffa9d3   Deepak   changed teachers ...
34
          if(staff[i]._id == staffData[j].userId){
ec5f044a9   Deepak   Finished add teac...
35
            staff[i].type = staffData[j].type;
df05c55ea   Deepak   fixed views for d...
36
            staff[i].employeeId = staffData[j].employeeId;
925ffa9d3   Deepak   changed teachers ...
37
            staff[i].dob = staffData[j].dob;
d75229d74   Deepak   fixed dob issue a...
38
39
40
          }
        }
      }
a8c5a7fb6   Deepak   added teachers view
41
42
43
      onData(null, {
        data: {
          user: user,
d75229d74   Deepak   fixed dob issue a...
44
          org: org,
925ffa9d3   Deepak   changed teachers ...
45
          staff: staff
a8c5a7fb6   Deepak   added teachers view
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
        },
      });
    }
  
    return () => {
      _.each(handles, (handle) => handle.stop() );
    };
  };
  
  
  const reduxTick = (props, onData) => {
    onData(null, {
      data: {}
    });
  };
925ffa9d3   Deepak   changed teachers ...
61
  export const staffViewController = composeAll(
a8c5a7fb6   Deepak   added teachers view
62
63
    composeWithTracker(meteorTick, Loading),
    compose(reduxTick, Loading),
925ffa9d3   Deepak   changed teachers ...
64
  )(StaffView);