From 93f3e46730dcf2f9ee20c39a7f1db1eb70fbfa12 Mon Sep 17 00:00:00 2001 From: merelendor Date: Wed, 10 Aug 2022 11:40:49 +0300 Subject: [PATCH] fixes for support pages, admin panel --- actions/calendarActions.js | 11 +- actions/supportActions.js | 53 ++++ pages/api/support/appeals.js | 169 +++++++++++ pages/api/support/read.js | 53 ++++ .../Events/NotificationMessage/index.js | 24 ++ pages/components/Header/index.js | 19 +- pages/settings/{index.js => admin.js} | 73 +++-- pages/settings/components/InnerMenu/index.js | 1 + pages/settings/password.js | 35 ++- pages/settings/phone.js | 35 ++- pages/support/appeals.js | 252 ++++++++++++++++ pages/support/components/InnerMenu/index.js | 36 ++- pages/support/index.js | 31 +- pages/support/messages.js | 217 -------------- pages/support/new.js | 219 -------------- pages/support/request.js | 270 ++++++++++++++++++ reducers/initialState.js | 2 +- reducers/supportReducer.js | 2 +- 18 files changed, 1005 insertions(+), 497 deletions(-) create mode 100644 pages/api/support/appeals.js create mode 100644 pages/api/support/read.js rename pages/settings/{index.js => admin.js} (70%) create mode 100644 pages/support/appeals.js delete mode 100644 pages/support/messages.js delete mode 100644 pages/support/new.js create mode 100644 pages/support/request.js diff --git a/actions/calendarActions.js b/actions/calendarActions.js index 87823dd..25fcb3f 100644 --- a/actions/calendarActions.js +++ b/actions/calendarActions.js @@ -42,10 +42,13 @@ export const getCalendar = ({ dispatch, date_from, date_to }) => let payments = []; for(let i in contract.payments) { - const mdate = moment(contract.payments[i].date, "DD-MM-YYYY"); - periods[mdate.format('YYYYMM')] = mdate.format('YYYYMM'); - - payments.push({ ...contract.payments[i], ...{ contract: { number: contract.number, date: contract.date }, date: mdate.format("YYYY-MM-DD"), js_date: mdate.toDate() } }); + if(contract.payments[i].date !== null) + { + const mdate = moment(contract.payments[i].date, "DD-MM-YYYY"); + periods[mdate.format('YYYYMM')] = mdate.format('YYYYMM'); + + payments.push({ ...contract.payments[i], ...{ contract: { number: contract.number, date: contract.date }, date: mdate.format("YYYY-MM-DD"), js_date: mdate.toDate() } }); + } } let query = nSQL(payments) diff --git a/actions/supportActions.js b/actions/supportActions.js index 1bb9656..70e01f0 100644 --- a/actions/supportActions.js +++ b/actions/supportActions.js @@ -19,6 +19,59 @@ if(process.browser) }; } +export const setAppealsRead = ({ dispatch, appeals }) => +{ + return new Promise((resolve, reject) => + { + axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/support/read`, { appeals }, { + withCredentials: true, + }) + .then((response) => + { + dispatch({ type: actionTypes.SUPPORT_APPEALS, data: { appeals: { new: 0, } } }); + resolve(); + }) + .catch((error) => + { + console.log("error"); + console.error(error); + + reject(); + }); + }); +} + +export const getAppeals = ({ dispatch }) => +{ + console.log("ACTION", "support", "getAppeals", `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/support/appeals`); + + return new Promise((resolve, reject) => + { + axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/support/appeals`, {}, { + withCredentials: true, + }) + .then((response) => + { + console.log("getEvents", "response", response.data); + const events = response.data; + const filtered_events = []; + + console.log("events"); + console.log(events); + + dispatch({ type: actionTypes.SUPPORT_APPEALS, data: { appeals: { list: response.data.appeals, new: response.data.new, } } }); + resolve(); + }) + .catch((error) => + { + console.log("error"); + console.error(error); + + reject(); + }); + }); +} + export const getSupportThemes = ({ dispatch, query, }) => { console.log("ACTION", "support", "getSupportThemes", { query }); diff --git a/pages/api/support/appeals.js b/pages/api/support/appeals.js new file mode 100644 index 0000000..7a3ef85 --- /dev/null +++ b/pages/api/support/appeals.js @@ -0,0 +1,169 @@ +// Next.js API route support: https://nextjs.org/docs/api-routes/introduction +import axios from 'axios'; +import { Cookies } from 'react-cookie'; +import cookie from 'cookie'; +import moment from 'moment'; +import jwt from 'jsonwebtoken'; +import Redis from 'ioredis'; + +import { cors } from '../../../lib/cors'; + +const redis = new Redis(process.env.REDIS_URL); + +export default async function handler(req, res) +{ + await cors(req, res); + + console.log("API", "support", "appeals", req.headers); + + if(req.headers.cookie !== undefined) + { + const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : ""); + + if(cookies.jwt !== undefined && cookies.jwt !== null) + { + var client_jwt_decoded = jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT); + var crm_jwt = jwt.sign(client_jwt_decoded, process.env.JWT_SECRET_CRM, { noTimestamp: true }); + + console.log("client_jwt_decoded"); + console.log(client_jwt_decoded); + + const read = await redis.keys(`${ client_jwt_decoded.acc_number }_appeal_*`); + console.log("API", "support", "appeals", "read", read); + + try + { + await axios.get(`${ process.env.CRM_API_HOST }/lk/Account/GetIncidents/`, { + params: client_jwt_decoded, + headers: { + "Authorization": `Bearer ${ crm_jwt }`, + } + }) + .then((crm_response) => + { + let unread = 0; + console.log("API", "support", "appeals", "response", crm_response.data); + + const appeals = [ + { + number: "CAS-02991-J2M9B8", + created_date: "2021-09-06", + subject: "Вопросы по пени и штрафам", + owner: "Анастасия Ломакина", + status: "cancelled", + answer: "", + contracts: "No2021_1889, No2021_2453, No2021_2465, No2021_2857", + documents: [ + { + doc_name: "Письмо от ЛП", + doc_url: "24bfe404-9905-4b69-8898-09a7229a8fc1", + doc_extension: "pdf", + }, + { + doc_name: "Пояснения СБ", + doc_url: "24bfe404-9905-4b69-8898-09a7229a8fc1", + doc_extension: "pdf", + }, + ], + }, + { + number: "CAS-01779-S2Q3Q6", + created_date: "2021-06-22", + subject: "Изменение графика", + owner: "Анастасия Ломакина", + status: "active", + answer: "", + contracts: "No2021_1889, No2021_1891, No2021_1914, No2021_2453, No2021_3023, No2021_7349, No2021_9969, No2021_125 95", + documents: [ + { + doc_name: "Запрос на выезд за границу", + doc_url: "4291c8b0-2aff-47a1-b246-fc8e5e196c24", + doc_extension: "pdf", + }, + { + doc_name: "согласование УЭБ", + doc_url: "4291c8b0-2aff-47a1-b246-fc8e5e196c24", + doc_extension: "pdf", + }, + ], + }, + { + number: "CAS-01691-L2Z7H2", + created_date: "2021-06-08", + subject: "Выдача документов по сделке", + owner: "Анастасия Ломакина", + status: "closed", + answer: "", + contracts: "No2021_1889, No2021_3023, No2021_7349, No2021_9969, No2021_12595", + documents: [ + { + doc_name: "Доп. соглашение по КАСКО", + doc_url: "7e11a7b0-0246-44ea-8f92-65698b79ea36", + doc_extension: "pdf", + }, + { + doc_name: "Запрос на выезд за границу", + doc_url: "7e11a7b0-0246-44ea-8f92-65698b79ea36", + doc_extension: "pdf", + }, + { + doc_name: "письмо о назначении платежей", + doc_url: "7e11a7b0-0246-44ea-8f92-65698b79ea36", + doc_extension: "pdf", + }, + { + doc_name: "ПП по платежу за июнь", + doc_url: "7e11a7b0-0246-44ea-8f92-65698b79ea36", + doc_extension: "pdf", + }, + { + doc_name: "ПП по расширению страхового покрытия", + doc_url: "7e11a7b0-0246-44ea-8f92-65698b79ea36", + doc_extension: "pdf", + } + ], + } + ]; + + for(let i in appeals) + { + const key = `${ client_jwt_decoded.acc_number }_appeal_${ appeals[i].number }_${ appeals[i].status }`; + console.log("LOOK", key); + + if(read.indexOf(key) > -1) + { + appeals[i].read = true; + } + else + { + unread++; + } + } + //res.status(200).json(crm_response.data); + res.status(200).json({ + new: unread, + appeals + }); + }) + .catch((error) => + { + console.error(error); + res.status(500).send(); + }); + } + catch(e) + { + console.error(e); + res.status(500).send(); + } + } + else + { + res.status(403).send(); + } + } + else + { + res.status(403).send(); + } +} \ No newline at end of file diff --git a/pages/api/support/read.js b/pages/api/support/read.js new file mode 100644 index 0000000..f1a9f36 --- /dev/null +++ b/pages/api/support/read.js @@ -0,0 +1,53 @@ +// Next.js API route support: https://nextjs.org/docs/api-routes/introduction +import axios from 'axios'; +import { Cookies } from 'react-cookie'; +import cookie from 'cookie'; +import moment from 'moment'; +import jwt from 'jsonwebtoken'; +import Redis from 'ioredis'; +import md5 from 'md5'; + +import { cors } from '../../../lib/cors'; + +const redis = new Redis(process.env.REDIS_URL); + +export default async function handler(req, res) +{ + await cors(req, res); + + let { appeals } = req.body; + + if(req.headers.cookie !== undefined) + { + const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : ""); + + if(cookies.jwt !== undefined && cookies.jwt !== null) + { + var client_jwt_decoded = jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT); + var crm_jwt = jwt.sign(client_jwt_decoded, process.env.JWT_SECRET_CRM, { noTimestamp: true }); + + console.log("client_jwt_decoded"); + console.log(client_jwt_decoded); + + try + { + for(let i in appeals) + { + const key = `${ client_jwt_decoded.acc_number }_appeal_${ appeals[i].number }_${ appeals[i].status }`; + console.log("API", "support", "read", "key", key); + + await redis.set(key, appeals[i].status); + } + } + catch(exception) + { + console.error("EXCEPTION", "API", "support", "read"); + console.error(exception); + } + } + } + + res.status(200).json({ + status: "success", + }); +} \ No newline at end of file diff --git a/pages/components/Events/NotificationMessage/index.js b/pages/components/Events/NotificationMessage/index.js index 7ce892f..b6ba69c 100644 --- a/pages/components/Events/NotificationMessage/index.js +++ b/pages/components/Events/NotificationMessage/index.js @@ -122,6 +122,30 @@ export default class NotificationMessage extends React.Component ) } + + case "return_pts": + { + return ( +
  • + { event.important ? ( +

    Внимание! Просрочена дата возврата СТС по договору №{ event.contract_number }. Посмотрите порядок возврата СТС или загрузите скан СТС по ссылке.

    + ) : ( +

    Приближается дата возврата СТС по договору №{ event.contract_number }. Посмотрите порядок возврата СТС или загрузите скан СТС по ссылке.

    + ) } + { event.important && (

    Важное

    ) } +

    { event.event_date }

    +

    + + Посмотрите порядок возврата СТС + +   или   + + Загрузите скан СТС (какой раздел FAQ ?) + +

    +
  • + ) + } } return null; diff --git a/pages/components/Header/index.js b/pages/components/Header/index.js index 952c56d..fbc0990 100644 --- a/pages/components/Header/index.js +++ b/pages/components/Header/index.js @@ -2,7 +2,7 @@ import React from "react"; import Link from "next/link"; import { connect } from "react-redux"; -import { logout, getEvents } from "../../../actions"; +import { logout, getEvents, getAppeals } from "../../../actions"; import NotificationsList from "./NotificationsList"; class Header extends React.Component @@ -17,6 +17,7 @@ class Header extends React.Component messagesOpened: false, events: [], events_loaded: false, + appeals: 0, }; } @@ -24,7 +25,8 @@ class Header extends React.Component { return { observer: nextProps.observer, - events: nextProps.events, + events: nextProps.events, + appeals: nextProps.appeals, }; } @@ -32,6 +34,8 @@ class Header extends React.Component { console.log("Header", "CDM"); getEvents({ dispatch: this.props.dispatch }); + console.log("Header", "CDM", "222222"); + getAppeals({ dispatch: this.props.dispatch }); } componentDidUpdate(prevProps, prevState) @@ -138,7 +142,7 @@ class Header extends React.Component render() { - const { observer, menuOpened, notificationsOpened, messagesOpened, events, events_loaded } = this.state; + const { observer, menuOpened, notificationsOpened, messagesOpened, events, events_loaded, appeals } = this.state; console.log("events", events); return ( @@ -187,13 +191,11 @@ class Header extends React.Component - {/*}
  • Обращения
  • - {*/} {/*
  • @@ -227,15 +229,13 @@ class Header extends React.Component
  • - {/*}
  • - - + + Сообщения
  • - {*/}
  • -
    ФИО пользователя
    @@ -84,26 +112,26 @@ class IndexPage extends React.Component
    Статус
    - + { user !== undefined && user !== null && user.email !== undefined && user.email !== null && ( +
    +
    { `${ user.lastname } ${ user.name } ${ user.secondname }` }
    +
    { user.email }
    +
    Администратор
    +
    Все организации
    +
    Активен
    +
    +
    +
    + ) } + {/*}
    Иванов Иван Иванович
    iivanov@mail.com
    Администратор
    Все организации
    Активен
    -
    - -
    -
    - -
    -
    Иванов Иван Иванович
    -
    iivanov@mail.com
    -
    Администратор
    -
    Все организации
    -
    Активен
    -
    - +
    +
    @@ -140,10 +168,11 @@ class IndexPage extends React.Component
    -
    -
    - +
    +
    + {*/}
    diff --git a/pages/settings/components/InnerMenu/index.js b/pages/settings/components/InnerMenu/index.js index 129e026..43be922 100644 --- a/pages/settings/components/InnerMenu/index.js +++ b/pages/settings/components/InnerMenu/index.js @@ -4,6 +4,7 @@ import Link from "next/link"; const menu = [ {id: 1, name: "Номер телефона", link: "/settings/phone"}, {id: 2, name: "Пароль", link: "/settings/password"}, + {id: 3, name: "Настройки доступа", link: "/settings/admin"}, ] export default class InnerMenu extends React.Component diff --git a/pages/settings/password.js b/pages/settings/password.js index 51dbe68..ab774c6 100644 --- a/pages/settings/password.js +++ b/pages/settings/password.js @@ -1,4 +1,5 @@ import React from "react"; +import * as ReactDOM from 'react-dom'; import Head from 'next/head'; import Image from 'next/image'; import Link from "next/link"; @@ -43,6 +44,38 @@ class IndexPage extends React.Component }; } + componentDidMount() + { + ReactDOM.findDOMNode(this).parentNode.style.height = "100%"; + ReactDOM.findDOMNode(this).parentNode.style.display = "flex"; + ReactDOM.findDOMNode(this).parentNode.style.flexDirection = "column"; + ReactDOM.findDOMNode(this).parentNode.style.justifyContent = "spaceBetween"; + ReactDOM.findDOMNode(this).parentNode.style.alignItems = "stretch"; + + document.documentElement.style.height = "100%"; + document.documentElement.style.display = "flex"; + document.documentElement.style.flexDirection = "column"; + document.body.style.height = "100%"; + document.body.style.display = "flex"; + document.body.style.flexDirection = "column"; + } + + componentWillUnmount() + { + ReactDOM.findDOMNode(this).parentNode.style.height = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.display = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.flexDirection = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.justifyContent = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.alignItems = "unset"; + + document.documentElement.style.height = "unset"; + document.documentElement.style.display = "unset"; + document.documentElement.style.flexDirection = "unset"; + document.body.style.height = "unset"; + document.body.style.display = "unset"; + document.body.style.flexDirection = "unset"; + } + _handle_onPasswordSubmit = (event) => { event.preventDefault(); @@ -130,7 +163,7 @@ class IndexPage extends React.Component />
    -
    +
    diff --git a/pages/settings/phone.js b/pages/settings/phone.js index 7ed46f9..51ba697 100644 --- a/pages/settings/phone.js +++ b/pages/settings/phone.js @@ -1,4 +1,5 @@ import React from "react"; +import * as ReactDOM from 'react-dom'; import Head from 'next/head'; import Image from 'next/image'; import Link from "next/link"; @@ -49,6 +50,38 @@ class IndexPage extends React.Component }; } + componentDidMount() + { + ReactDOM.findDOMNode(this).parentNode.style.height = "100%"; + ReactDOM.findDOMNode(this).parentNode.style.display = "flex"; + ReactDOM.findDOMNode(this).parentNode.style.flexDirection = "column"; + ReactDOM.findDOMNode(this).parentNode.style.justifyContent = "spaceBetween"; + ReactDOM.findDOMNode(this).parentNode.style.alignItems = "stretch"; + + document.documentElement.style.height = "100%"; + document.documentElement.style.display = "flex"; + document.documentElement.style.flexDirection = "column"; + document.body.style.height = "100%"; + document.body.style.display = "flex"; + document.body.style.flexDirection = "column"; + } + + componentWillUnmount() + { + ReactDOM.findDOMNode(this).parentNode.style.height = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.display = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.flexDirection = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.justifyContent = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.alignItems = "unset"; + + document.documentElement.style.height = "unset"; + document.documentElement.style.display = "unset"; + document.documentElement.style.flexDirection = "unset"; + document.body.style.height = "unset"; + document.body.style.display = "unset"; + document.body.style.flexDirection = "unset"; + } + _handle_onPhoneSubmit = (event) => { event.preventDefault(); @@ -161,7 +194,7 @@ class IndexPage extends React.Component />
    -
    +
    diff --git a/pages/support/appeals.js b/pages/support/appeals.js new file mode 100644 index 0000000..7f26e30 --- /dev/null +++ b/pages/support/appeals.js @@ -0,0 +1,252 @@ +import React from "react"; +import * as ReactDOM from 'react-dom'; +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"; + +class SupportAppealsPage extends React.Component +{ + constructor(props) + { + super(props); + this.state = { + appeals: null, + loading: false, + }; + } + + static getDerivedStateFromProps(nextProps, prevState) + { + return { + appeals: nextProps.appeals, + }; + } + + componentDidMount() + { + ReactDOM.findDOMNode(this).parentNode.style.height = "100%"; + ReactDOM.findDOMNode(this).parentNode.style.display = "flex"; + ReactDOM.findDOMNode(this).parentNode.style.flexDirection = "column"; + ReactDOM.findDOMNode(this).parentNode.style.justifyContent = "spaceBetween"; + ReactDOM.findDOMNode(this).parentNode.style.alignItems = "stretch"; + + document.documentElement.style.height = "100%"; + document.documentElement.style.display = "flex"; + document.documentElement.style.flexDirection = "column"; + document.body.style.height = "100%"; + document.body.style.display = "flex"; + document.body.style.flexDirection = "column"; + + 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() + { + ReactDOM.findDOMNode(this).parentNode.style.height = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.display = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.flexDirection = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.justifyContent = "unset"; + ReactDOM.findDOMNode(this).parentNode.style.alignItems = "unset"; + + document.documentElement.style.height = "unset"; + document.documentElement.style.display = "unset"; + document.documentElement.style.flexDirection = "unset"; + document.body.style.height = "unset"; + document.body.style.display = "unset"; + document.body.style.flexDirection = "unset"; + } + + render() + { + const { loading, appeals } = this.state; + const { number } = this.props; + const status = { + active: { title: "Активное", color: "#04A8A4" }, + closed: { title: "Закрыто", color: "#000", }, + cancelled: { title: "Отменено", color: "#A8026B", } + }; + + console.log(appeals); + + return ( + + + ЛК Эволюция автолизинга + + +
    +
    +
    +
    +
    +
    +
    +

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

    +
    + +
    +
    + +
    +
    + { appeals !== undefined && appeals !== null && appeals.list !== undefined && appeals.list !== null && ( + <> + { appeals.list.length > 0 ? ( + <> + { appeals.list.map((appeal, index) => + ( +
    +
    +

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

    +

    Отвественный ОРК: { appeal.owner }

    +

    Договор(ы): { appeal.contracts }

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

    Тема запроса

    +

    { appeal.subject }

    +
    +
    +

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

    +

    { appeal.answer === "" ? "Без ответа" : appeal.answer }

    + { appeal.documents.length > 0 && ( +
    + { appeal.documents.map((document, document_index) => + ( +
    +

    + { document.doc_name } + Скачать документ +

    +
    + )) } +
    + ) } +
    +
    +
    + )) } + + ) : ( +

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

    + ) } + + )} + {/*} +
    +
    +

    Номер обращения: 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 +

    +
    +
    +
    +
    +
    + {*/} +
    +
    +
    +
    +
    +
    +
    + + ); + } +} + +function mapStateToProps(state, ownProps) +{ + return { + appeals: state.support.appeals, + }; +} + +export const getServerSideProps = reduxWrapper.getServerSideProps( +(store) => + async ({ req, res, query }) => { + return { + props: { + }, + }; + } +); + +export default withRouter(connect(mapStateToProps)(SupportAppealsPage)); diff --git a/pages/support/components/InnerMenu/index.js b/pages/support/components/InnerMenu/index.js index d474254..48ee111 100644 --- a/pages/support/components/InnerMenu/index.js +++ b/pages/support/components/InnerMenu/index.js @@ -1,14 +1,26 @@ import React from "react"; import Link from "next/link"; +import { connect } from "react-redux"; -export default class InnerMenu extends React.Component +class InnerMenu extends React.Component { constructor(props) { super(props); + this.state = { + appeals: 0, + } + this.menuRef = React.createRef(); } + static getDerivedStateFromProps(nextProps, prevState) + { + return { + appeals: nextProps.appeals, + }; + } + componentDidMount() { let l = 0; @@ -33,26 +45,25 @@ export default class InnerMenu extends React.Component _handle_onNewAppeal = () => { - this.props.router.push('/support/new/'); + this.props.router.push('/support/request/'); } render() { + const { appeals } = this.state; const { number } = this.props; return ( ) } -} \ No newline at end of file +} + +function mapStateToProps(state, ownProps) +{ + return { + appeals: state.support.appeals.new, + } +} + +export default connect(mapStateToProps)(InnerMenu); \ No newline at end of file diff --git a/pages/support/index.js b/pages/support/index.js index 0843950..65b4815 100644 --- a/pages/support/index.js +++ b/pages/support/index.js @@ -15,10 +15,6 @@ import Company from "../components/Company"; import InnerMenu from "./components/InnerMenu"; import { - getContractInfo, - getContractAgreement, - getContractRules, - getFile, getSupportThemes, } from "../../actions"; @@ -34,7 +30,7 @@ class ContractPage extends React.Component appeal: null, searched: null, loading: false, - search: "", + query: "", }; } @@ -61,7 +57,7 @@ class ContractPage extends React.Component document.documentElement.style.flexDirection = "column"; document.body.style.height = "100%"; document.body.style.display = "flex"; - document.body.style.flexDirection = "column"; + document.body.style.flexDirection = "column"; if (!this.state.loading) { @@ -105,12 +101,19 @@ class ContractPage extends React.Component } } + _handle_onRequest = (question) => + { + this.props.router.push(`/support/request#${ question }`); + } + + _handle_onChangeSearchQuery = (value) => + { + this.setState({ query: value }); + } + render() { - const { loading, themes, question_selected, searched, appleals, search } = this.state; - - console.log("themesthemesthemesthemesthemes"); - console.log(themes); + const { loading, themes, question_selected, searched, appleals, query } = this.state; return ( @@ -141,10 +144,10 @@ class ContractPage extends React.Component
    { event.preventDefault(); }}>
    - { this._handle_onChange_search(event.target.value);} } + { this._handle_onChangeSearchQuery(event.target.value);} } />
    -
    @@ -162,7 +165,7 @@ class ContractPage extends React.Component

    { question.title }

    -
    +

    Процедура

    @@ -187,7 +190,7 @@ class ContractPage extends React.Component
    ) } - +
    diff --git a/pages/support/messages.js b/pages/support/messages.js deleted file mode 100644 index f17ddd6..0000000 --- a/pages/support/messages.js +++ /dev/null @@ -1,217 +0,0 @@ -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, -} from "../../actions"; - -class ContractPage extends React.Component -{ - constructor(props) - { - super(props); - this.state = { - date: null, - car: null, - contract_date: null, - agreement: null, - rules: null, - loading: false, - }; - } - - static getDerivedStateFromProps(nextProps, prevState) - { - return { - date: nextProps.date, - car: nextProps.car, - contract_date: nextProps.contract_date, - agreement: nextProps.agreement, - rules: nextProps.rules, - }; - } - - componentDidMount() {} - - render() - { - const { loading, date, car, contract_date, agreement, rules } = this.state; - const { number } = this.props; - - 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 -

    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -