import React from "react";

import Offers from "./components/Offers";
import FinancialProgram from "./components/FinancialProgram";
import DocumentsForm from "./components/DocumentsForm";
import StatusDocumentsCheck from "./components/StatusDocumentsCheck";
import StatusDecisionMaking from "./components/StatusDecisionMaking";
import StatusDecisionRefuse from "./components/StatusDecisionRefuse";
import StatusPositiveDecision from "./components/StatusPositiveDecision";
import LeasingRegistration from "./components/LeasingRegistration";

export default class SingleDeal extends React.Component
{
	constructor(props)
	{
		super(props);
		this.leasing_registration_ref = React.createRef();
	}

	_onDealContractsUpdate = () => 
	{
		const { onDealContractsUpdate, dealSelected } = this.props;
		onDealContractsUpdate(dealSelected);
	}

	render()
	{
		const { index, status, deals, dealSelected, onCloseDeal, } = this.props;

		const offers = deals.details[ dealSelected ] !== undefined ? deals.details[ dealSelected ].offers : undefined;
		const documents = deals.details[ dealSelected ] !== undefined ? deals.details[ dealSelected ].documents : undefined;
		const uploaded = deals.details[ dealSelected ] !== undefined ? deals.details[ dealSelected ].uploaded : undefined;
		const contracts = deals.details[ dealSelected ] !== undefined ? deals.details[ dealSelected ].contracts : undefined;

		return (
			<div className="contractStatus_modal">
				{/*}
				<div className="modal_header">
					<p className="modal_title">Статус сделки</p>
					<button className="modal_close" onClick={close}></button>
				</div>
				{*/}
				<div className="modal_body single_status">
					<Offers { ...this.props } offers={ offers }/>
					<FinancialProgram { ...this.props }/>
					<DocumentsForm { ...this.props } documents={ documents } uploaded={ uploaded }/>
					<StatusDocumentsCheck { ...this.props }/>
					<StatusDecisionMaking { ...this.props }/>
					<StatusDecisionRefuse { ...this.props }/>
					<StatusPositiveDecision { ...this.props }/>
					<LeasingRegistration { ...this.props } contracts={ contracts } onDealContractsUpdate={ this._onDealContractsUpdate }/>
				</div>
				<div className="bottom_button_close" onClick={ onCloseDeal } >
					<span>Свернуть</span>
					<div className="icon"></div>
				</div>
			</div>
		)
	}
}