"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var humberger_1 = require("./humberger");
var react_router_dom_1 = require("react-router-dom");
var localStorageService_1 = require("../../services/localStorageService");
var Header = /** @class */ (function (_super) {
    __extends(Header, _super);
    function Header() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.state = {
            showHumbergerMenu: false,
            dropdownStyle: {
                position: 'absolute',
                right: '0px',
                left: '30px',
                marginLeft: '0px',
                top: '50px',
                background: '#222222',
                width: '120px',
                zIndex: 9,
                padding: '5px 0',
                textAlign: 'right',
                WebkitTransition: 'all, 0.3s',
                MozTransition: 'all, 0.3s',
                msTransition: 'all, 0.3s',
                OTransition: 'all, 0.3s',
                transition: 'all, 0.3s',
                opacity: '0',
                visibility: 'hidden'
            }
        };
        _this.handleHumbergerMenuClose = function () {
            document.body.style.overflow = "";
            _this.setState({ showHumbergerMenu: false });
        };
        _this.handleHumbergerOpenClick = function () {
            document.body.style.overflow = "hidden";
            _this.setState({ showHumbergerMenu: true });
        };
        _this.handleDropDownClick = function () {
            var dropdownStyle = __assign({}, _this.state.dropdownStyle);
            dropdownStyle.top = "20px";
            dropdownStyle.opacity = 1;
            dropdownStyle.visibility = "visible";
            _this.setState({ dropdownStyle: dropdownStyle });
        };
        _this.handleCloseDropDown = function () {
            var dropdownStyle = __assign({}, _this.state.dropdownStyle);
            dropdownStyle.top = "50px";
            dropdownStyle.opacity = 0;
            dropdownStyle.visibility = "hidden";
            _this.setState({ dropdownStyle: dropdownStyle });
        };
        return _this;
    }
    Header.prototype.componentDidMount = function () {
        var user = (0, localStorageService_1.GetObject)();
        if (user !== null) {
            this.setState({ firstName: user.firstName, lastName: user.lastName });
        }
    };
    Header.prototype.render = function () {
        var _this = this;
        var _a = this.state, dropdownStyle = _a.dropdownStyle, showHumbergerMenu = _a.showHumbergerMenu;
        return (React.createElement(React.Fragment, null,
            React.createElement(humberger_1.default, { dropdownStyle: dropdownStyle, closeDropDownMenu: this.handleCloseDropDown, onDropDownMenuClick: this.handleDropDownClick, cartItemsAmount: this.props.cartItemsAmount, onLougoutClick: this.props.onLougoutClick, closeHumbergerMenu: this.handleHumbergerMenuClose, showHumbergerMenu: showHumbergerMenu, userName: this.props.userName }),
            React.createElement("header", { className: "header" },
                React.createElement("div", { className: "header__top" },
                    React.createElement("div", { className: "container" },
                        React.createElement("div", { className: "row" },
                            React.createElement("div", { className: "col-lg-7 col-md-7" },
                                React.createElement("div", { className: "header__top__left" },
                                    React.createElement("ul", null,
                                        React.createElement("li", null,
                                            React.createElement("i", { className: "fa fa-envelope" }),
                                            "Lhotsky15@seznam.cz"),
                                        React.createElement("li", null,
                                            "Doru\u010Den\u00ED zdarma pro objedn\u00E1vky nad ",
                                            React.createElement("strong", null, "1000 K\u010D"),
                                            "!")))),
                            React.createElement("div", { className: "col-lg-5 col-md-5" },
                                React.createElement("div", { className: "header__top__right" },
                                    React.createElement("div", { className: "header__top__right__auth" }, this.props.userName !== ''
                                        ? React.createElement("div", { className: "user__menu" },
                                            React.createElement("ul", null,
                                                React.createElement("li", { onMouseLeave: function () { return _this.handleCloseDropDown(); } },
                                                    React.createElement("a", { onClick: function () { return _this.handleDropDownClick(); } },
                                                        React.createElement("i", { className: "fa fa-user" }),
                                                        " ",
                                                        this.props.userName),
                                                    React.createElement("ul", { style: dropdownStyle },
                                                        React.createElement("li", { className: "dropdown__item__li" },
                                                            React.createElement(react_router_dom_1.Link, { to: "/account/info", className: "user__dropdown__item__a" }, "Nastaven\u00ED")),
                                                        React.createElement("li", { className: "dropdown__item__li" },
                                                            React.createElement("a", { onClick: function (e) { _this.props.onLougoutClick(e); _this.handleCloseDropDown(); }, className: "user__dropdown__item__a" }, "Odhl\u00E1sit se"))))))
                                        : React.createElement(react_router_dom_1.Link, { to: "/login" },
                                            React.createElement("i", { className: "fa fa-user" }),
                                            " P\u0159ihl\u00E1sit se"))))))),
                React.createElement("div", { className: "container" },
                    React.createElement("div", { className: "row" },
                        React.createElement("div", { className: "col-lg-2" },
                            React.createElement("div", { className: "header__logo" },
                                React.createElement(react_router_dom_1.Link, { to: "/" },
                                    React.createElement("img", { src: "img/logo.png", alt: "Logo firmy" })))),
                        React.createElement("div", { className: "col-lg-8" },
                            React.createElement("nav", { className: "header__menu" },
                                React.createElement("ul", null,
                                    React.createElement("li", null,
                                        React.createElement(react_router_dom_1.NavLink, { exact: true, to: "/" }, "Produkty")),
                                    React.createElement("li", null,
                                        React.createElement(react_router_dom_1.NavLink, { to: "/delivery" }, "Doprava")),
                                    React.createElement("li", null,
                                        React.createElement(react_router_dom_1.NavLink, { to: "/contacts" }, "Kontakty")),
                                    React.createElement("li", null,
                                        React.createElement(react_router_dom_1.NavLink, { to: "/aboutus" }, "O n\u00E1s")),
                                    React.createElement("li", null,
                                        React.createElement(react_router_dom_1.NavLink, { to: "/tradeterms" }, "Obchodn\u00ED podm\u00EDnky"))))),
                        React.createElement("div", { className: "col-lg-2" },
                            React.createElement("div", { className: "header__cart", title: "Zobrazit n\u00E1kupn\u00ED ko\u0161\u00EDk" },
                                React.createElement("ul", null,
                                    React.createElement("li", null,
                                        React.createElement(react_router_dom_1.Link, { to: "/cart" },
                                            React.createElement("i", { className: "fa fa-shopping-bag" }),
                                            this.props.cartItemsAmount > 0 ? React.createElement("span", null, this.props.cartItemsAmount) : ''))),
                                React.createElement("div", { className: "header__cart__price" },
                                    React.createElement(react_router_dom_1.Link, { className: "default__link", to: "/cart" }, "N\u00E1kupn\u00ED ko\u0161\u00EDk"))))),
                    React.createElement("div", { className: "humberger__open", onClick: this.handleHumbergerOpenClick },
                        React.createElement("i", { className: "fa fa-bars" }))))));
    };
    return Header;
}(React.Component));
exports.default = Header;
//# sourceMappingURL=header.js.map