import React, { Component } from 'react';
import PropTypes from 'prop-types';

import { PageTitle, PortalContainer, PortalLinks, PortalLink } from 'lib/components';
import { injectIntl } from 'react-intl';

import icons from 'constants/icons';
import messages from './messages';


require("./style.scss");


class ReportPortal extends Component {


	renderReportLink(router, href, title, description, icon, className) {
		return <PortalLink
				icon={ icon } 
				title={ title }
				className={ className }
				description={ description }
				onClick={ () => router.push(href) } />
	}


	render() {
		let { router } = this.context;
		let intl = this.props.intl;

		return (
			<div>
				<PortalContainer>
					<div className="pv10">
						<PageTitle title={ intl.formatMessage(messages.title) } titleIcon={ icons.reports } />
					</div>

					<PortalLinks>
						{ this.renderReportLink(router, "/reports/summary", intl.formatMessage(messages.summaryTitle), intl.formatMessage(messages.summaryDesc), icons.summaryReport) }
						{ this.renderReportLink(router, "/reports/cashflow", intl.formatMessage(messages.cashflowTitle), intl.formatMessage(messages.cashflowDesc), icons.cashflowReport) }
					</PortalLinks>

					<PortalLinks>
						{ this.renderReportLink(router, "/reports/payment", intl.formatMessage(messages.paymentTitle), intl.formatMessage(messages.paymentDesc), icons.paymentReport) }
						{ this.renderReportLink(router, "/reports/customer", intl.formatMessage(messages.customerTitle), intl.formatMessage(messages.customerDesc), icons.customerReport) }
					</PortalLinks>

					<PortalLinks>
						{ this.renderReportLink(router, "/reports/tax", intl.formatMessage(messages.taxTitle), intl.formatMessage(messages.taxDesc), icons.taxReport) }
						{ this.renderReportLink(router, "/reports/dph", intl.formatMessage(messages.epoTitle), intl.formatMessage(messages.epoDesc), icons.reports) }
					</PortalLinks>
				</PortalContainer>
			</div>
		);
	}

}

ReportPortal.contextTypes = {
	router: PropTypes.object.isRequired
};



export default injectIntl(ReportPortal);