import React from "react"; import Head from 'next/head'; import Image from 'next/image'; import Link from "next/link"; import cookie from 'cookie'; import { connect } from "react-redux"; import numeral from "numeral"; import moment from 'moment'; import { SpinnerCircular } from 'spinners-react'; import { withRouter } from 'next/router'; import { reduxWrapper } from '../store'; import Header from './components/Header'; import Footer from './components/Footer'; import Company from "./components/Company"; import DateInput from '../components/DatePicker'; import Pagination from './components/Pagination'; import Manager from "./components/Manager"; import AccountLayout from "./components/Layout/Account"; import AnnouncementsList from "./components/AnnouncementsList"; import { getContractsList, getImage } from '../actions'; class IndexPage extends React.Component { constructor(props) { super(props); this.state = { company: {}, contracts: null, order: "date", sort_number: "desc", sort_date: "desc", sort_status: "desc", search: "", date_from: undefined, date_from_type: "text", date_to: undefined, date_to_type: "text", loading: false, page: 1, pages: 1, all: false, }; } static getDerivedStateFromProps(nextProps, prevState) { return { company: nextProps.company, contracts: nextProps.contracts, page: nextProps.page, pages: nextProps.pages, }; } componentDidMount() { this.setState({ loading: true }, () => { getContractsList({ dispatch: this.props.dispatch, order: this.state.order, sort: this.state.sort_number, }).then(() => { this.setState({ loading: false }); }).catch(() => {}); }); } _handle_onChange_search = (value) => { this.setState({ search: value }); } _handle_onChange_date_from = (value) => { this.setState({ date_from: value }); } _handle_onChange_date_to = (value) => { this.setState({ date_to: value }); } _handle_onChangeSort_number = () => { this.setState({ loading: true, order: "number", sort_number: this.state.sort_number === "desc" ? "asc" : "desc" }, () => { getContractsList({ dispatch: this.props.dispatch, order: this.state.order, sort: this.state.sort_number, all: this.state.all, }).then(() => { this.setState({ loading: false }); }).catch(() => {}); }); } _handle_onChangeSort_date = () => { this.setState({ loading: true, order: "date", sort_date: this.state.sort_date === "desc" ? "asc" : "desc" }, () => { getContractsList({ dispatch: this.props.dispatch, order: this.state.order, sort: this.state.sort_date, all: this.state.all, }).then(() => { this.setState({ loading: false }); }).catch(() => {}); }); } _handle_onChangeSort_status = () => { this.setState({ loading: true, order: "status", sort_status: this.state.sort_status === "desc" ? "asc" : "desc" }, () => { getContractsList({ dispatch: this.props.dispatch, order: this.state.order, sort: this.state.sort_status, all: this.state.all, }).then(() => { this.setState({ loading: false }); }).catch(() => {}); }); } _handle_onPage = (page) => { const { order, sort_number, sort_status, search, date_from, date_to, } = this.state; this.setState({ loading: true, }, () => { getContractsList({ dispatch: this.props.dispatch, order, sort_number, sort_status, search, date_from, date_to, page, all: this.state.all, }).then(() => { this.setState({ loading: false }); }).catch(() => {}); }); } _handle_onAll = () => { const { order, sort_number, sort_status, search, date_from, date_to, } = this.state; this.setState({ loading: true, all: true }, () => { getContractsList({ dispatch: this.props.dispatch, order, sort_number, sort_status, search, date_from, date_to, all: this.state.all, }).then(() => { this.setState({ loading: false }); }).catch(() => {}); }); } _handle_onSearch = () => { const { search, date_from, date_to, } = this.state; this.setState({ loading: true, }, () => { getContractsList({ dispatch: this.props.dispatch, search, date_from, date_to, all: this.state.all, }).then(() => { this.setState({ loading: false }); }).catch(() => {}); }); } _handle_onService = (url) => { this.props.router.push(url); } _handle_onQuestionnaire = () => { this.props.router.push("/questionnaire"); } _renderQuestionnaireStatus = () => { const { company, contracts } = this.state; if(company.questionnaire_status === "need_to_fill") { return (
Вам необходимо заполнить анкету лизингополучателя для актуализации данных.
Анкета подписана, скоро здесь появятся ваши договоры лизинга.
Уточните данные Требуется уточнить данные в анкете клиента
{ contract.status }
{ contract.debt_leasing !== undefined && contract.debt_leasing !== null && parseFloat(contract.debt_leasing) > 0 && (Задолжность: { numeral(contract.debt_leasing).format(' ., ') } ₽
) } { contract.debt_penalty_fee !== undefined && contract.debt_penalty_fee !== null && parseFloat(contract.debt_penalty_fee) > 0 && (Пени: { numeral(contract.debt_penalty_fee).format(' ., ') } ₽
) }