"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var robins_1 = require("../../../robins");
var siui_1 = require("@simplus/siui");
var dashboardFilters = robins_1.robins.dashboardFilters;
var Filter = /** @class */ (function (_super) {
    __extends(Filter, _super);
    function Filter() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    /**
     *  ComponentDidMount method to initiate robin get dashboard containers request
     */
    Filter.prototype.componentDidMount = function () {
        dashboardFilters.get("filter " + this.props.id, this.props.id);
    };
    /**
     *  This is the render method
     */
    Filter.prototype.render = function () {
        var filter = dashboardFilters.getResult("filter " + this.props.id) || null;
        if (filter) {
            var filterValue = React.createElement("div", null);
            switch (filter.type) {
                case 'single':
                    filterValue = React.createElement(siui_1.Select, { label: filter.title, style: { width: 100 } }, filter.options.map(function (option) {
                        return React.createElement(siui_1.Select.Option, { value: option.value }, option.title);
                    }));
                    break;
                default:
                    filterValue = React.createElement(siui_1.Select, { style: { width: 100 } }, filter.options.map(function (option) {
                        if (option.title !== '')
                            return React.createElement(siui_1.Select.Option, { value: option.value }, option.title);
                    }));
            }
            return React.createElement("div", { style: { display: 'flex', margin: '1rem 0 1rem 1rem', alignItems: 'flex-end' } },
                filter.text ?
                    React.createElement("div", { style: { marginBottom: '8px', marginRight: '8px' } }, filter.text)
                    : null,
                filterValue);
        }
        else
            return React.createElement("div", null);
    };
    return Filter;
}(React.Component));
exports.Filter = Filter;
exports.default = Filter;
