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 numeral from "numeral"; 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 { getContractInfo, getContractHelpCard, getContractInsurance, getContractRegistration, getContractTelematic, } from './../../actions'; import DownloadPdfButton from "../components/DownloadPdfButton"; import AccountLayout from "../components/Layout/Account"; import ContractHeader from "./components/ContractHeader"; import DownloadFileById from "../components/DownloadFileById"; class Insurance extends React.Component { constructor(props) { super(props); } render() { const { type, title, entry, index, number } = this.props; return (

{ title }

{ entry.period_type === "prolong" && entry.invoice_url !== null && (
) }
{ entry.description && (

{ entry.description }

) }
) } } class ContractServicesPage extends React.Component { constructor(props) { super(props); this.state = { loading: false, contracts_info: {}, opened: [], date: null, car: null, helpcard: null, insurance: null, registration: null, telematic: null, insurance_location_checked: false, }; } static getDerivedStateFromProps(nextProps, prevState) { return { contracts_info: nextProps.contracts_info, date: nextProps.date, car: nextProps.car, helpcard: nextProps.helpcard, insurance: nextProps.insurance, registration: nextProps.registration, telematic: nextProps.telematic, }; } componentDidMount() { const { dispatch, number } = this.props; if(!this.state.loading && number !== undefined) { this.setState({ loading: true }, () => { if(this.state.contracts_info[ number ] === undefined) { getContractInfo({ dispatch, number }); } Promise.all([ new Promise((resolve) => { getContractHelpCard({ dispatch, number }).then(resolve())}), new Promise((resolve) => { getContractInsurance({ dispatch, number }).then(resolve())}), new Promise((resolve) => { getContractRegistration({ dispatch, number }).then(resolve())}), new Promise((resolve) => { getContractTelematic({ dispatch, number }).then(resolve())}), ]) .then(() => { this.setState({ loading: false }); }); }); } } componentDidUpdate(prevProps, prevState) { if(prevState.insurance === null && this.state.insurance !== null) { if(!this.state.insurance_location_checked) { this.setState({ insurance_location_checked: true }, () => { if(document.location.hash.indexOf("insurance") > -1) { const o = [ ...this.state.opened ]; o.push("insurance"); this.setState({ opened: o }); } if(document.location.hash.indexOf("ratcard") > -1) { const o = [ ...this.state.opened ]; o.push("ratcard"); this.setState({ opened: o }); } if(document.location.hash.indexOf("telematic") > -1) { const o = [ ...this.state.opened ]; o.push("telematic"); this.setState({ opened: o }); } if(document.location.hash.indexOf("registration") > -1) { const o = [ ...this.state.opened ]; o.push("registration"); this.setState({ opened: o }); } }); } } } _handle_onCard = (card) => { const opened = [ ...this.state.opened ]; if(opened.indexOf(card) === -1) { opened.push(card); } else { opened.splice(opened.indexOf(card), 1); } this.setState({ opened: opened }); } _handle_onContract = (url) => { } _handle_onInvoice = (url) => { } _checkInsuranceAvailable = () => { const { insurance, } = this.state; if(insurance !== undefined && insurance !== null) { for(let i in insurance) { if(insurance[i] !== undefined && insurance[i] !== null) { if(insurance[i].length > 0) { return true; } } } } return false; } render() { const { loading, contracts_info, opened, helpcard, insurance, registration, telematic, } = this.state; const { number } = this.props; let { date, car, status } = contracts_info[ number ] !== undefined ? contracts_info[ number ] : {}; console.log("insurance", { insurance, props: this.props }); return ( ЛК Эволюция автолизинга
{ loading ? (
) : (
-1 ? 'open' : '' }`}>
this._handle_onCard('ratcard') }>

Карта РАТ Карта РАТ

{ helpcard !== undefined && helpcard !== null && helpcard.length > 0 ? ( helpcard.map((entry, index) => ( { entry.card_number !== null ? (

РАТ

  • Номер карты: { entry.card_number }
  • Тип карты: { entry.card_type }
  • Действует до: { moment(entry.date).format("DD.MM.YYYY") }
<> { entry && entry.description && (

") }}/> ) }

) : (

Нет данных

) }
)) ) : (

Нет данных

) }
-1 ? 'open' : '' }`}>
this._handle_onCard('insurance') }>

Страхование Страхование

{ this._checkInsuranceAvailable() ? (
{ insurance.kasko !== undefined && insurance.kasko !== null && insurance.kasko !== "" && insurance.kasko.map !== undefined && insurance.kasko.map((entry, index) => ( )) } { insurance.osago !== undefined && insurance.osago !== null && insurance.osago !== "" && insurance.osago.map !== undefined && insurance.osago.map((entry, index) => ( )) } { insurance.nsib !== undefined && insurance.nsib !== null && insurance.nsib !== "" && insurance.nsib.map !== undefined && insurance.nsib.map((entry, index) => ( )) } { insurance.fingap !== undefined && insurance.fingap !== null && insurance.fingap !== "" && insurance.fingap.map !== undefined && insurance.fingap.map((entry, index) => ( )) }
) : (

Нет данных

) }
-1 ? 'open' : '' }`}>
this._handle_onCard('registration') }>

Регистрация Регистрация

{ registration !== undefined && registration !== null && registration.length > 0 ? registration.map((entry, index) => (

ГИБДД

    { entry.package && (
  • Пакет услуг: { entry.package }
  • ) } { entry.amount && (
  • Стоимость: { numeral(entry.amount).format(' ., ') } ₽
  • ) }
)) : (

Нет данных

) }
-1 ? 'open' : '' }`}>
this._handle_onCard('telematic') }>

Телематика Телематика

{ telematic !== undefined && telematic !== null && telematic.length > 0 ? telematic.map((entry, index) => (
    { entry.provider && (
  • Поставщик: { entry.provider }
  • ) } { entry.equipment && (
  • Оборудование: { entry.equipment }
  • ) } { entry.amount && (
  • Стоимость: { numeral(entry.amount).format(' ., ') } ₽
  • ) }
)) : (

Нет данных

)}
) }