Blame view

imports/client/views/org/admin/parents/index.js 1.97 KB
691a06c2f   ajaiprakash   Staff profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  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';
  import { Parents }                        from '/imports/collections/parents/index';
  import { ParentsView }                      from './parentsview';
  
  
  
  const meteorTick = (props, onData) => {
  
    const handles = [
      Meteor.subscribe('users.current'),
      Meteor.subscribe('orgs.current'),
      Meteor.subscribe('users.forMyOrg'),
      Meteor.subscribe('parent.forMyOrg'),
    ];
  
    if(_.every(handles, (handle) => (handle.ready()) )) {
      const user = Users.current();
      const org = Orgs.current();
      console.log("parents");
      parent = Users.find({"role":"PARENT"}).fetch() ? Users.find({"role":"PARENT"}).fetch() : "";
      console.log(Users.find({"role":"PARENT"}).fetch());
      parentData = Parents.find().fetch() ? Parents.find().fetch() : "";
      console.log("parentData");
      console.log(parentData);
      for(var i=0; i< parent.length; i++){
        for(var j=0; j< parentData.length; j++){
          if(parent[i]._id == parentData[j].userId){
            parent[i].relationship = parentData[j].relationship;
df05c55ea   Deepak   fixed views for d...
38
39
            parent[i].profession = parentData[j].profession;
            parent[i].relationship = parentData[j].relationship;
691a06c2f   ajaiprakash   Staff profile
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
          }
        }
      }
      onData(null, {
        data: {
          user: user,
          org: org,
          parent: parent
        },
      });
    }
  
    return () => {
      _.each(handles, (handle) => handle.stop() );
    };
  };
  
  
  const reduxTick = (props, onData) => {
    onData(null, {
      data: {}
    });
  };
  
  
  export const ParentViewController = composeAll(
    composeWithTracker(meteorTick, Loading),
    compose(reduxTick, Loading),
  )(ParentsView);