"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 (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var utils_1 = require("@joincivil/utils");
var react_apollo_1 = require("react-apollo");
var TokensAccountRequirement_1 = require("./TokensAccountRequirement");
var TokensStyledComponents_1 = require("./TokensStyledComponents");
var TokensTextComponents_1 = require("./TokensTextComponents");
var elements_1 = require("@joincivil/elements");
var FullscreenModal_1 = require("../FullscreenModal");
var TokenTutorial_1 = require("../TokenTutorial");
var styleConstants_1 = require("../styleConstants");
var icons_1 = require("../icons");
var Tokens_1 = require("./Tokens");
var UserTokenAccountVerify = /** @class */ (function (_super) {
    __extends(UserTokenAccountVerify, _super);
    function UserTokenAccountVerify() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.isQuizStarted = function (quizPayload) {
            return Object.keys(quizPayload).length > 0;
        };
        return _this;
    }
    UserTokenAccountVerify.prototype.render = function () {
        var _this = this;
        var _a = this.props, step = _a.step, handleClose = _a.handleClose, handleOpen = _a.handleOpen, open = _a.open;
        if (step === Tokens_1.TOKEN_PROGRESS.DISABLED) {
            return (React.createElement(TokensStyledComponents_1.FlexColumnsPrimaryModule, { padding: true },
                React.createElement(TokensStyledComponents_1.TokenAccountSectionHeader, null,
                    React.createElement(TokensTextComponents_1.TokenVerifySectionText, null)),
                React.createElement(TokensAccountRequirement_1.UserTokenAccountRequirement, { step: step },
                    React.createElement(TokensStyledComponents_1.TokenRequirementIcon, { step: step },
                        React.createElement(elements_1.CivilTutorialIcon, { color: styleConstants_1.colors.accent.CIVIL_GRAY_3 })),
                    React.createElement(TokensTextComponents_1.TokenQuizSectionText, null))));
        }
        else if (step === Tokens_1.TOKEN_PROGRESS.ACTIVE) {
            return (React.createElement(TokensStyledComponents_1.FlexColumnsPrimaryModule, { padding: true },
                React.createElement(TokensStyledComponents_1.TokenAccountSectionHeader, null,
                    React.createElement(TokensTextComponents_1.TokenVerifySectionText, null)),
                React.createElement(TokensAccountRequirement_1.UserTokenAccountRequirement, { step: step },
                    React.createElement(TokensStyledComponents_1.TokenRequirementIcon, { step: step },
                        React.createElement(elements_1.CivilTutorialIcon, null)),
                    React.createElement(TokensTextComponents_1.TokenQuizSectionText, null),
                    React.createElement(react_apollo_1.Query, { query: utils_1.getCurrentUserQuery }, function (_a) {
                        var loading = _a.loading, error = _a.error, data = _a.data;
                        var quizPayload = loading || error ? {} : data.currentUser.quizPayload;
                        return (React.createElement(TokensStyledComponents_1.TokenBtns, { onClick: handleOpen }, _this.isQuizStarted(quizPayload) ? "Continue" : React.createElement(TokensTextComponents_1.TokenQuizBtnText, null)));
                    }),
                    React.createElement(FullscreenModal_1.FullScreenModal, { open: open || false, solidBackground: true },
                        React.createElement(TokensStyledComponents_1.CloseBtn, { onClick: handleClose },
                            React.createElement(icons_1.CloseXIcon, { color: styleConstants_1.colors.accent.CIVIL_GRAY_2 })),
                        React.createElement(TokenTutorial_1.TokenTutorial, { handleClose: handleClose })))));
        }
        return React.createElement(React.Fragment, null);
    };
    return UserTokenAccountVerify;
}(React.Component));
exports.UserTokenAccountVerify = UserTokenAccountVerify;
//# sourceMappingURL=TokensAccountVerify.js.map