import React from "react"; import Head from 'next/head'; import Image from 'next/image'; import { connect } from "react-redux"; import { withRouter } from 'next/router'; import moment from "moment"; import { SpinnerCircular } from 'spinners-react'; import { reduxWrapper } from '../../store'; import Header from '../components/Header'; import Footer from '../components/Footer'; import Company from "../components/Company"; import InnerMenu from "./components/InnerMenu"; import DownloadPdfButton from "../components/DownloadPdfButton"; import { getContractInfo, getContractMaterials } from "../../actions"; class ContractPage extends React.Component { constructor(props) { super(props); this.state = { date: null, car: null, contract_date: null, materials: null, loading: false, } } static getDerivedStateFromProps(nextProps, prevState) { return { date: nextProps.date, car: nextProps.car, contract_date: nextProps.contract_date, materials: nextProps.materials, }; } componentDidMount() { if(!this.state.loading && this.props.number !== undefined) { this.setState({ loading: true }, () => { getContractInfo({ dispatch: this.props.dispatch, number: this.props.number }).then((info) => { console.log("info", info); getContractMaterials({ dispatch: this.props.dispatch, }).then(() => { this.setState({ loading: false }) }).catch(() => {}); }) .catch(() => { }); }); } } render() { const { loading, date, car, materials, } = this.state; const { number } = this.props; console.log("materials", materials); return ( ЛК Эволюция автолизинга

Договор №{ number }

{ date !== undefined && date !== null && date !== null && (<> от { moment(date).format("DD.MM.YYYY") })}{ car !== undefined && car !== null ? ` - ${ car.brand.name } ${ car.model.name } | ${ car.reg_number !== null ? car.reg_number : 'без рег. номера' } | ${ car.vin_number !== null ? car.vin_number : 'без VIN номера' }` : '' }
{ loading ? (
) : (
{ materials !== undefined && materials !== null && materials.map((document, index ) => (

{ document.name } { document.description !== null && document.description !== "" && ( { document.description } ) }

)) }
) }