import React from 'react';
import { Meteor } from 'meteor/meteor';
import ReactDOM from 'react-dom';
import App from '../imports/ui/App';
import 'bootstrap/dist/css/bootstrap.min.css';

export const PlantTypesCollection = new Meteor.Collection('plantTypes');
export const SensorDataCollection = new Meteor.Collection('sensorData');
export const ActiveDeviceCollection = new Meteor.Collection('activeDevice');

Meteor.startup(() => {
  if(Meteor.isServer) {
    Meteor.publish('plantTypesCollection', function() {
      return PlantTypesCollection.find();
    })

    Meteor.publish('sensorDataCollection', function() {
      return SensorDataCollection.find();
    })

    Meteor.publish('activeDeviceCollection', function() {
      return ActiveDeviceCollection.find();
    })
  }

  if (Meteor.isClient) {
    Meteor.subscribe('plantTypesCollection');
    Meteor.subscribe('sensorDataCollection');
    Meteor.subscribe('activeDeviceCollection');
  }

  ReactDOM.render(<App />, document.getElementById('root'));
});