"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
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);
};
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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var react_router_dom_1 = require("react-router-dom");
var utils_1 = require("@joincivil/utils");
var EthAddressViewer_1 = require("../EthAddressViewer");
var graphql_tag_1 = __importDefault(require("graphql-tag"));
var react_apollo_1 = require("react-apollo");
var ChevronAnchor_1 = require("../ChevronAnchor");
var Button_1 = require("../Button");
var features_1 = require("../features");
var DashboardStyledComponents_1 = require("./DashboardStyledComponents");
var DashboardNewsroomStripeConnect_1 = require("./DashboardNewsroomStripeConnect");
var DashboardNewsroomSubmitLink_1 = require("./DashboardNewsroomSubmitLink");
var CHANNEL_ID_FROM_NEWSROOM_ADDRESS_QUERY = graphql_tag_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  query($contractAddress: String!) {\n    channelsGetByNewsroomAddress(contractAddress: $contractAddress) {\n      id\n    }\n  }\n"], ["\n  query($contractAddress: String!) {\n    channelsGetByNewsroomAddress(contractAddress: $contractAddress) {\n      id\n    }\n  }\n"])));
var DashboardNewsroomRegistryStatusBase = function (props) {
    var statusDisplay;
    var statusDetails = React.createElement(React.Fragment, null);
    var isAccepted = props.isAccepted, isInProgress = props.isInProgress, isRejected = props.isRejected, acceptedDate = props.acceptedDate, inProgressPhaseDisplayName = props.inProgressPhaseDisplayName, inProgressPhaseCountdown = props.inProgressPhaseCountdown, inProgressPhaseDetails = props.inProgressPhaseDetails, rejectedDate = props.rejectedDate;
    if (isInProgress) {
        statusDisplay = inProgressPhaseDisplayName;
        if (inProgressPhaseCountdown) {
            statusDetails = inProgressPhaseCountdown;
        }
        else if (inProgressPhaseDetails) {
            statusDetails = inProgressPhaseDetails;
        }
    }
    else if (isAccepted) {
        statusDisplay = "Accepted";
        if (acceptedDate) {
            statusDisplay = "Accepted Date";
            statusDetails = React.createElement(React.Fragment, null, acceptedDate);
        }
    }
    else if (isRejected) {
        statusDisplay = "Rejected";
        if (rejectedDate) {
            statusDisplay = "Rejected Date";
            statusDetails = React.createElement(React.Fragment, null, rejectedDate);
        }
    }
    return (React.createElement(React.Fragment, null,
        React.createElement(DashboardStyledComponents_1.StyledChallengeIDKicker, null, statusDisplay),
        statusDetails));
};
var DashboardNewsroomRegistryStatus = React.memo(DashboardNewsroomRegistryStatusBase);
var DashboardNewsroomBase = function (props) {
    return (React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroom, null,
        React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomSection, null,
            React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomSectionContentRow, null,
                React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomName, null, props.newsroomName),
                React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomLinks, null,
                    React.createElement(ChevronAnchor_1.ChevronAnchor, { component: react_router_dom_1.Link, to: props.manageNewsroomURL }, "Manage Newsroom"),
                    React.createElement(ChevronAnchor_1.ChevronAnchor, { component: react_router_dom_1.Link, to: props.listingDetailURL }, "View on Registry")))),
        React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomSection, null,
            React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomSectionContentRow, null,
                React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomHdr, null, "Newsroom Token Balance"),
                React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomTokensContainer, null,
                    props.newsroomMultiSigBalance,
                    " ",
                    React.createElement(DashboardStyledComponents_1.StyledCVLLabel, null, "CVL"),
                    React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomTokensLabel, null, "Tokens in Newsroom Wallet")))),
        React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomSection, null,
            React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomHdr, null, "Status on the Registry"),
            React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomSectionContentRow, null,
                React.createElement("div", null,
                    React.createElement(DashboardNewsroomRegistryStatus, __assign({}, props))),
                React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomTokensContainer, null,
                    props.newsroomDeposit,
                    " ",
                    React.createElement(DashboardStyledComponents_1.StyledCVLLabel, null, "CVL"),
                    React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomTokensLabel, null, "Newsroom Token Deposit")))),
        React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomSection, null,
            props.newsroomMultiSigAddress && (React.createElement(EthAddressViewer_1.EthAddressViewer, { address: props.newsroomMultiSigAddress, displayName: "Newsroom Public Wallet Address", etherscanBaseURL: props.etherscanBaseURL })),
            React.createElement(EthAddressViewer_1.EthAddressViewer, { address: props.newsroomAddress, displayName: "Newsroom Smart Contract Address", etherscanBaseURL: props.etherscanBaseURL })),
        React.createElement(features_1.FeatureFlag, { feature: "pew" },
            React.createElement(react_apollo_1.Query, { query: CHANNEL_ID_FROM_NEWSROOM_ADDRESS_QUERY, variables: { contractAddress: props.newsroomAddress } }, function (_a) {
                var loading = _a.loading, error = _a.error, data = _a.data;
                if (loading || error) {
                    return React.createElement(React.Fragment, null);
                }
                return (React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomSection, null,
                    React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomHdr, null, "Pulse Story Feed"),
                    React.createElement(DashboardNewsroomSubmitLink_1.DashboardNewsroomSubmitLink, { channelID: data.channelsGetByNewsroomAddress.id })));
            })),
        React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomSection, null,
            React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomHdr, null, "Boosts"),
            React.createElement("p", null,
                "Connect with the Civil community eager to fund your newsroom projects.",
                " ",
                React.createElement("a", { href: utils_1.urlConstants.FAQ_BOOSTS, target: "_blank" }, "Learn more")),
            props.boostProceeds,
            React.createElement("p", null,
                React.createElement(Button_1.Button, { size: Button_1.buttonSizes.MEDIUM_WIDE, to: "/manage-newsroom/" + props.newsroomAddress + "/launch-boost" }, "Launch New Boost")),
            React.createElement("p", null,
                "View your current Boosts on the \"Boosts\" tab on",
                " ",
                React.createElement(react_router_dom_1.Link, { to: props.listingDetailURL }, "your newsroom's Registry listing"),
                ".")),
        React.createElement(features_1.FeatureFlag, { feature: "stripe-admin" },
            React.createElement(DashboardStyledComponents_1.StyledDashboardNewsroomSection, null,
                React.createElement(DashboardNewsroomStripeConnect_1.DashboardNewsroomStripeConnect, { newsroomAddress: props.newsroomAddress })))));
};
exports.DashboardNewsroom = React.memo(DashboardNewsroomBase);
var templateObject_1;
//# sourceMappingURL=DashboardNewsroom.js.map