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 AccountLayout from "../components/Layout/Account"; import TemplateFile from "./components/TemplateFile"; import { getSupportThemes, resetFilteredThemes, } from "../../actions"; class SupportPage extends React.Component { constructor(props) { super(props); this.state = { themes: null, question_selected: undefined, appeals: null, appeal: null, filtered: null, loading: false, search: "", query: "", searched: false, }; this.question_refs = []; } static getDerivedStateFromProps(nextProps, prevState) { return { themes: nextProps.themes, appeals: nextProps.appeals, appeal: nextProps.appeal, filtered: nextProps.filtered, }; } componentDidMount() { if (!this.state.loading) { this.setState({ loading: true }, () => { getSupportThemes({ dispatch: this.props.dispatch }) .then(() => { let question_selected = undefined; let found = false; for(let t in this.state.themes) { for(let q in this.state.themes[t].questions) { this.question_refs[this.state.themes[t].questions[q].id] = React.createRef(); if(this.props.router.asPath.indexOf(this.state.themes[t].questions[q].id) > -1) { question_selected = this.state.themes[t].questions[q].id; found = true; } } } this.setState({ loading: false, question_selected: question_selected }, () => { if(question_selected !== undefined) { setTimeout(() => { this.question_refs[question_selected].current.scrollIntoView({ behavior: 'smooth', block: 'center', }); }, 100); } }); }) .catch(() => {}); }); } } componentWillUnmount() { } _handle_onQuestion = (question) => { if(this.state.question_selected === question) { this.setState({ question_selected: undefined }); } else { this.setState({ question_selected: question }); } } _handle_onRequest = (question) => { this.props.router.push(`/support/request#${ question }`); } _handle_onChangeSearchQuery = (value) => { this.setState({ search: value }); } _handle_onSearch = () => { const { search } = this.state; this.setState({ searched: true, query: search }, () => { getSupportThemes({ dispatch: this.props.dispatch, query: search }) .then(() => { }); }); } _handle_onSearchReset = () => { this.setState({ searched: false, search: "", query: "" }); } _handle_onLocalLink = (id) => { const { dispatch } = this.props; window.location = `/support/faq#${ id }`; this.setState({ searched: false, search: "", query: "", question_selected: id }, () => { resetFilteredThemes({ dispatch }); setTimeout(() => { this.question_refs[id].current.scrollIntoView({ behavior: 'smooth', block: 'center', }); }, 100); }); } _getMarks = (content) => { const { query } = this.state; const search_array = query.split(" "); const chunks = []; const content_array = content.split(" "); for(let i in content_array) { let found = false; for(let s in search_array) { if(content_array[i].toLowerCase() == search_array[s].toLowerCase()) { found = true; } } if(found) { chunks.push(`${ content_array[i] }`); } else { chunks.push(content_array[i]); } } return chunks.join(" "); } render() { //filtered, const { loading, themes, filtered, question_selected, searched, appleals, search } = this.state; let filtered_count = 0; if(filtered !== undefined && filtered !== null) { for(let i in filtered) { filtered_count = filtered_count + filtered[i].questions.length; } } return ( ЛК Эволюция автолизинга

Обращения

{ loading ? (
) : ( <>
{ event.preventDefault(); }}>
{ this._handle_onChangeSearchQuery(event.target.value);} }/>
{ searched && ( ) }
{/* Результат поиска */} { searched && filtered !== undefined && filtered !== null ? ( <> { filtered_count > 0 ? ( <> { filtered.map((theme, theme_index) => ( { theme.questions.map((question, index) => (

{/*}

К каждой теме свободное html поле для миниинструкции (со ссылками на формы документов и документы). Привязка к теме обращения в CRM

{*/}
)) }
)) } ) : (

К сожалению по Вашему запросу нет результатов.

) } ) : (
{ themes !== undefined && themes !== null && themes.map((theme) => (

{ theme.name }

{ theme.questions.map((question) => (
this._handle_onQuestion(question.id) }>

{ question.title }

Процедура

{ question.documents !== null && (

Документы

) } { question.templates !== null && (

Шаблоны документов

{ question.templates.map((template, index) => ()) }
) } { question.request && ( ) }
)) }
)) }
) } ) }