index.js 1.13 KB
// import { importCsvController } from 'imports/client/views/org/importCsv/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';
import {importCsv}                        from './importCsvView'

const meteorTick = (props, onData) => {

  const handles = [
    Meteor.subscribe('users.current')
  ];

  if(_.every(handles, (handle) => (handle.ready()) )) {
    const user = Users.current();
    onData(null, {
      data: {
        user: user,
      },
    });
  }

  return () => {
    _.each(handles, (handle) => handle.stop() );
  };
};


const reduxTick = (props, onData) => {
  onData(null, {
    data: {}
  });
};


export const importCsvController = composeAll(
  composeWithTracker(meteorTick, Loading),
  compose(reduxTick, Loading),
)(importCsv);