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
- {/*}
-
-
+
+
Сообщения
- {*/}