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 { getContractInfo, getContractAgreement, getContractRules, getFile, setAppealsRead, } from "../../actions"; import AccountLayout from "../components/Layout/Account"; import RequestFile from "./components/RequestFile"; class SupportAppealsPage extends React.Component { constructor(props) { super(props); this.state = { active: true, appeals: null, loading: false, }; } static getDerivedStateFromProps(nextProps, prevState) { return { appeals: nextProps.appeals, }; } componentDidMount() { setTimeout(() => { const appeals = []; if(this.state.appeals !== undefined && this.state.appeals !== null && this.state.appeals.list !== undefined && this.state.appeals.list !== null) { for(let i in this.state.appeals.list) { if(this.state.appeals.list[i].read !== true) { appeals.push({ number: this.state.appeals.list[i].number, status: this.state.appeals.list[i].status }); } } } console.log("appeals"); console.log(appeals); setAppealsRead({ dispatch: this.props.dispatch, appeals }); }, 1000); } componentWillUnmount() { } _activeAppealsCount = () => { const { appeals } = this.state; let count = 0; if(appeals.list !== undefined && appeals.list !== null) { for(let i in appeals.list) { if(appeals.list[i].status === "active") { count++; } } } return count; } _handle_onActive = () => { this.setState({ active: this.state.active ? false : true }); } render() { const { number } = this.props; const { loading, active, appeals } = this.state; const status = { active: { title: "Активное", color: "#04A8A4" }, closed: { title: "Закрыто", color: "#000", }, cancelled: { title: "Отменено", color: "#A8026B", } }; const active_count = this._activeAppealsCount(); console.log(appeals); return ( ЛК Эволюция автолизинга

Мои обращения

{ appeals !== undefined && appeals !== null && appeals.list !== undefined && appeals.list !== null && ( <> { appeals.list.length > 0 ? ( <> { active && active_count === 0 ? (

У Вас нет активных обращений.
Показать все обращения

) : ( <> { appeals.list.map((appeal, index) => { if(active) { if(appeal.status !== "active") { return null; } } return (

Номер обращения: { appeal.number } от { moment(appeal.created_date, "YYYY-MM-DD").format("DD.MM.YYYY") }

Ваш персональный менеджер: { appeal.owner }

{ appeal.contracts.length > 0 && (

Договор{ appeal.contracts.length > 1 && "ы" }: { appeal.contracts.map((contract, contract_index) => (№ { contract }{ contract_index < appeal.contracts.length - 1 && ", " })) }

) }
{ status[appeal.status].title }

Тема запроса

{ appeal.subject }

{ appeal.client_request !== null && appeal.client_request !== "" && ( <>

Текст запроса

") }}>

) } { appeal.documents.length > 0 && (
{ appeal.documents.map((file, index) => { if(file.doc_direction !== "incoming") { return null; } return () }) }
) }
{ ((appeal.answer !== null && appeal.answer !== "") || (appeal.documents.length > 0)) && (

Ответ службы клиентского сервиса

) } { appeal.answer !== null && appeal.answer !== "" && (

") }}>

) } { appeal.documents.length > 0 && (
{ appeal.documents.map((file, index) => { if(file.doc_direction !== "outgoing") { return null; } return () }) }
) }
) }) } ) } ) : (

У Вас пока нет обращений.

) } )} {/*}

Номер обращения: 123 от 13.04.2022

Отвественный ОРК: Иванов И.И.

Договор: №2021_1655, №2021_1655

Активное

Тема запроса

Текстовый контент

Текст ответа ОРК

Текстовый контент

Номер обращения: 123 от 13.04.2022

Отвественный ОРК: Иванов И.И.

Договор: №2021_1655, №2021_1655

Тема запроса

Текстовый контент

Текст ответа ОРК

Текстовый контент

№2021_1655 от 20.04.2021 2021_1655 от 20.04.2021

№2021_1655 от 20.04.2021 2021_1655 от 20.04.2021

{*/}