/* eslint-disable max-len */ import React from 'react'; import { render } from 'react-dom'; import { Router, Route, IndexRoute, browserHistory } from 'react-router'; import { Meteor } from 'meteor/meteor'; import App from '../../ui/layouts/App.js'; import Documents from '../../ui/pages/Documents.js'; import NewDocument from '../../ui/pages/NewDocument.js'; import EditDocument from '../../ui/containers/EditDocument.js'; import ViewDocument from '../../ui/containers/ViewDocument.js'; import Index from '../../ui/pages/Index.js'; import Login from '../../ui/pages/Login.js'; import NotFound from '../../ui/pages/NotFound.js'; import RecoverPassword from '../../ui/pages/RecoverPassword.js'; import ResetPassword from '../../ui/pages/ResetPassword.js'; import Signup from '../../ui/pages/Signup.js'; import { Orgs } from '/imports/collections/orgs/index'; const authenticate = (nextState, replace) => { if (!Meteor.loggingIn() && !Meteor.userId()) { replace({ pathname: '/login', state: { nextPathname: nextState.location.pathname }, }); } }; const detectOrg = (nextState, replace) => { orgSlug = ""; var hostnameArray = document.location.hostname.split( "." ); if(hostnameArray[1]=='localhost'){ orgSlug = hostnameArray[0]; } if(orgSlug!=""){ Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { if(res.length>0){ console.log(res); console.log(res[0]._id._str); Session.set('orgId', res[0]._id._str); render(getOrgRoutes(),document.getElementById('react-root')); }else{ render(getInvalidOrgRoute(),document.getElementById('react-root')); } }); }else{ render(getNonOrgRoutes(),document.getElementById('react-root')); } } const checkSlug = (nextState, replace) => { orgId = Session.get('orgId'); console.log("orgId"); console.log(orgId); } const getOrgRoutes = () => ( ) const getNonOrgRoutes = () => ( ) const getInvalidOrgRoute = () => ( ) Meteor.startup(() => { detectOrg(); });