import { Mongo } from 'meteor/mongo';
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
let collections = {};

if (Meteor.isServer) {
    debugger
    const result = HTTP.call('GET', `${Meteor.settings.worklistUrl}/HISIntegration.svc/rest/GetHISBrandsRest`);
    let brandsHttpResult = JSON.parse(result.content);

    let collectionNames = brandsHttpResult.Items.map(brandObj => {
        return brandObj.Name
    })

    // let collectionNames = ["TestWLS"];

    for (let collName of collectionNames) {
        collections[collName] = new Mongo.Collection(collName);
    }

}

if (Meteor.isClient || Meteor.isCordova) {
    Meteor.call("getBrandsName", function(err, result) {

        let collectionNames = result;
        // let collectionNames = ["TestWLS"];

        for (let collName of collectionNames) {
            collections[collName] = new Mongo.Collection(collName);
        }
    });
}

export default collections;