Merge branch 'master' of https://github.com/merelendor/evoleasing-account
This commit is contained in:
commit
236501c6fe
@ -8,6 +8,22 @@ import { eachSeries } from 'async';
|
||||
import * as actionTypes from '../constants/actionTypes';
|
||||
import * as currentState from '../reducers/initialState';
|
||||
|
||||
if(process.browser)
|
||||
{
|
||||
FormData.prototype.appendObject = function(obj, namespace)
|
||||
{
|
||||
let keyName;
|
||||
for (var key in obj)
|
||||
{
|
||||
if (obj.hasOwnProperty(key))
|
||||
{
|
||||
keyName = [namespace, '[', key, ']'].join('');
|
||||
this.append(keyName, obj[key]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const getDeals = ({ dispatch, update = false }) =>
|
||||
{
|
||||
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals`;
|
||||
@ -217,6 +233,41 @@ export const getDealContracts = ({ dispatch, deal_id }) =>
|
||||
}
|
||||
});
|
||||
|
||||
reject();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const uploadDocument = ({ number, entity, id, filename, file }) =>
|
||||
{
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
let data = new FormData();
|
||||
data.append('file', file);
|
||||
|
||||
const payload = new URLSearchParams({
|
||||
number,
|
||||
entity,
|
||||
id,
|
||||
filename,
|
||||
});
|
||||
|
||||
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals/upload?${ payload.toString() }`, data,
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
withCredentials: true,
|
||||
})
|
||||
.then(async (response) =>
|
||||
{
|
||||
console.log("ACTION", "deals", "uploadDocument", "response.data", response.data);
|
||||
|
||||
resolve();
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error(error);
|
||||
reject();
|
||||
});
|
||||
});
|
||||
|
||||
@ -17,7 +17,7 @@ export const logDocumentAccess = (payload) =>
|
||||
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
payload.lk_user_id = global.store.getState().user;
|
||||
payload.lk_user_id = global.store.getState().user.email;
|
||||
payload.acc_number = global.store.getState().company.active;
|
||||
|
||||
axios.post(url, payload, {
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import React from "react"
|
||||
import numeral from "numeral";
|
||||
import moment from "moment";
|
||||
import { eachLimit } from "async";
|
||||
|
||||
import { SpinnerCircular } from "spinners-react";
|
||||
import FileDropzoneDeals from "../FileDropzoneDeals";
|
||||
import { acceptDealOffers } from "../../actions";
|
||||
import { acceptDealOffers, uploadDocument } from "../../actions";
|
||||
|
||||
class Step extends React.Component
|
||||
{
|
||||
@ -31,7 +32,6 @@ class Step extends React.Component
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_handle_onSwitch = () =>
|
||||
{
|
||||
const { statuscode_id } = this.props;
|
||||
@ -264,24 +264,68 @@ class DocumentsForm extends Step
|
||||
this.state = {
|
||||
open: false,
|
||||
files: {},
|
||||
uploading: false,
|
||||
completed: false,
|
||||
};
|
||||
this.status = [ 102 ];
|
||||
}
|
||||
|
||||
_renderHeaderButtons = () =>
|
||||
_handle_onSendFiles = (event) =>
|
||||
{
|
||||
const { open, files } = this.state;
|
||||
event.stopPropagation();
|
||||
// event.preventDefault();
|
||||
|
||||
if(open && Object.keys(files).length > 0)
|
||||
const { files } = this.state;
|
||||
const files_array = [];
|
||||
|
||||
for(let g in files)
|
||||
{
|
||||
return (
|
||||
<div className="buttons">
|
||||
<button className="button button button-blue">Отправить документы</button>
|
||||
</div>
|
||||
)
|
||||
for(let f in files[g])
|
||||
{
|
||||
files_array.push(files[g][f])
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
this.setState({ uploading: true }, () =>
|
||||
{
|
||||
eachLimit(files_array, 1, (file, callback) =>
|
||||
{
|
||||
console.log({ file, props: this.props });
|
||||
const { opp_number } = this.props;
|
||||
|
||||
const payload = {
|
||||
number: opp_number,
|
||||
entity: "opportunity",
|
||||
id: file.group,
|
||||
filename: file.name,
|
||||
file,
|
||||
};
|
||||
|
||||
uploadDocument(payload)
|
||||
.then(() =>
|
||||
{
|
||||
this._onSendFileStats(file.group, file.index);
|
||||
|
||||
callback();
|
||||
}, 1000)
|
||||
}, () =>
|
||||
{
|
||||
console.log("ready");
|
||||
this.setState({ uploading: false }, () =>
|
||||
{
|
||||
this._checkFilesCompleted();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_onSendFileStats = (group, index) =>
|
||||
{
|
||||
const files = { ...this.state.files };
|
||||
|
||||
files[group][index].sent = true;
|
||||
|
||||
this.setState({ files });
|
||||
}
|
||||
|
||||
_handle_onAddFile = (file_id, files) =>
|
||||
@ -299,12 +343,18 @@ class DocumentsForm extends Step
|
||||
|
||||
if(!e)
|
||||
{
|
||||
files[nf].index = nf;
|
||||
files[nf].group = file_id;
|
||||
files[nf].sent = false;
|
||||
document_files.push(files[nf]);
|
||||
}
|
||||
|
||||
existed_files[ file_id ] = document_files;
|
||||
|
||||
this.setState({ files: existed_files });
|
||||
this.setState({ files: existed_files }, () =>
|
||||
{
|
||||
this._checkFilesCompleted();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -330,15 +380,84 @@ class DocumentsForm extends Step
|
||||
delete files[file_id];
|
||||
}
|
||||
|
||||
this.setState({ files });
|
||||
this.setState({ files }, () =>
|
||||
{
|
||||
this._checkFilesCompleted();
|
||||
});
|
||||
}
|
||||
|
||||
_checkFilesCompleted = () =>
|
||||
{
|
||||
//Object.keys(files).length > 0
|
||||
const { files } = this.state;
|
||||
const { documents } = this.props;
|
||||
|
||||
let c = true;
|
||||
for(let g in documents)
|
||||
{
|
||||
const group = documents[g].doc_id;
|
||||
|
||||
if(files[group] === undefined || files[group].length === 0)
|
||||
{
|
||||
c = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(let f in files[group])
|
||||
{
|
||||
if(!files[group][f].sent)
|
||||
{
|
||||
c = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if(c)
|
||||
{
|
||||
for(let g in files)
|
||||
{
|
||||
for(let f in files[g])
|
||||
{
|
||||
if(!files[g][f].sent)
|
||||
{
|
||||
c = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
console.log({ c })
|
||||
this.setState({ completed: c });
|
||||
}
|
||||
|
||||
_renderHeaderButtons = () =>
|
||||
{
|
||||
const { open, uploading, completed, } = this.state;
|
||||
|
||||
if(open && !uploading && !completed)
|
||||
{
|
||||
return (
|
||||
<div className="buttons">
|
||||
<button className="button button button-blue" onClick={ this._handle_onSendFiles }>Отправить документы</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
render()
|
||||
{
|
||||
const { index, statuscode_id, dealSelected, documents, questionnaire_status } = this.props;
|
||||
const { open, files } = this.state;
|
||||
const { open, files, uploading } = this.state;
|
||||
|
||||
console.log("DocumentsForm", { documents });
|
||||
// console.log("DocumentsForm", { documents });
|
||||
|
||||
return (
|
||||
<div className={`${ this.status.indexOf( statuscode_id ) > -1 ? "current" : statuscode_id > this.status[ 0 ] ? "done" : "" }`}>
|
||||
@ -383,6 +502,7 @@ class DocumentsForm extends Step
|
||||
</div>
|
||||
<div className="right">
|
||||
<FileDropzoneDeals
|
||||
uploading={ uploading }
|
||||
files={ files[ document.doc_id ] !== undefined ? files[ document.doc_id ] : [] }
|
||||
onAddFile={ (file) => { this._handle_onAddFile(document.doc_id, file) } }
|
||||
onDeleteFile={ (file) => this._handle_onDeleteFile(document.doc_id, file) }
|
||||
@ -391,7 +511,7 @@ class DocumentsForm extends Step
|
||||
</div>
|
||||
)) }
|
||||
</>
|
||||
)}
|
||||
) }
|
||||
{/*}
|
||||
<div className="message documents">
|
||||
<div className="doc_list">
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import Dropzone from 'react-dropzone';
|
||||
import FileDropzone from "../FileDropzone";
|
||||
import moment from "moment";
|
||||
import { SpinnerCircular } from 'spinners-react';
|
||||
|
||||
const LIMIT = 10000000;
|
||||
const LIMIT_FILES = 10;
|
||||
@ -9,7 +10,7 @@ export default class FileDropzoneDeals extends FileDropzone
|
||||
{
|
||||
render()
|
||||
{
|
||||
const { files, onAddFile, onDeleteFile, } = this.props;
|
||||
const { files, onAddFile, onDeleteFile, uploading, } = this.props;
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -17,9 +18,23 @@ export default class FileDropzoneDeals extends FileDropzone
|
||||
<div className="horizontal_dropzone_files">
|
||||
{ files.map((file, index) => (
|
||||
<div className="file" key={ index }>
|
||||
<div className="delete" onClick={ () => onDeleteFile(file) }>
|
||||
<div className="icon"></div>
|
||||
</div>
|
||||
{ file.sent ? (
|
||||
<div className="loading">
|
||||
<div className="success"></div>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{ uploading ? (
|
||||
<div className="loading">
|
||||
<SpinnerCircular size={ 22 } thickness={ 100 } speed={ 100 } color="rgba(255, 255, 255, 1)" secondaryColor="rgba(168, 2, 107, 0.5)" style={{ marginTop: "8px" }}/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="delete" onClick={ () => onDeleteFile(file) }>
|
||||
<div className="icon"></div>
|
||||
</div>
|
||||
) }
|
||||
</>
|
||||
) }
|
||||
<div className="doc_icon">
|
||||
<span className="extension">PDF</span>
|
||||
</div>
|
||||
@ -34,7 +49,7 @@ export default class FileDropzoneDeals extends FileDropzone
|
||||
{*/}
|
||||
</div>
|
||||
) }
|
||||
{ files.length < LIMIT_FILES && (
|
||||
{ !uploading && files.length < LIMIT_FILES && (
|
||||
<Dropzone onDrop={ (acceptedFiles) => onAddFile(acceptedFiles) } maxFiles={ LIMIT_FILES }>
|
||||
{ ({getRootProps, getInputProps}) => (
|
||||
<div className={`file_upload dropzone horizontal_dropzone_wrapper`} { ...getRootProps() }>
|
||||
|
||||
@ -6102,12 +6102,29 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_
|
||||
padding-right: 16px;
|
||||
padding-top: 10px;
|
||||
cursor: pointer;
|
||||
width: 30px;
|
||||
min-width: 30px;
|
||||
padding-left: 3px;
|
||||
}
|
||||
.horizontal_dropzone_files .file .delete .icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2C4.68629 2 2 4.68629 2 8C2 11.3137 4.68629 14 8 14Z' fill='%23ED0A34' stroke='%23ED0A34' stroke-miterlimit='10'/%3E%3Cpath d='M10 6L6 10' stroke='white' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M10 10L6 6' stroke='white' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
}
|
||||
.horizontal_dropzone_files .file .loading {
|
||||
width: 30px;
|
||||
min-width: 30px;
|
||||
}
|
||||
.horizontal_dropzone_files .file .loading .success {
|
||||
width: 24px;
|
||||
min-width: 24px;
|
||||
height: 30px;
|
||||
min-height: 30px;
|
||||
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z' stroke='%235FB158' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M16.125 9.75L10.625 15L7.875 12.375' stroke='%235FB158' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-position-y: 6px;
|
||||
}
|
||||
.horizontal_dropzone_files .file .doc_icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@ -7019,6 +7019,9 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block {
|
||||
padding-right: 16px;
|
||||
padding-top: 10px;
|
||||
cursor: pointer;
|
||||
width: 30px;
|
||||
min-width: 30px;
|
||||
padding-left: 3px;
|
||||
|
||||
.icon {
|
||||
width: 16px;
|
||||
@ -7027,6 +7030,23 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block {
|
||||
}
|
||||
}
|
||||
|
||||
.loading {
|
||||
width: 30px;
|
||||
min-width: 30px;
|
||||
|
||||
.success {
|
||||
width: 24px;
|
||||
min-width: 24px;
|
||||
height: 30px;
|
||||
min-height: 30px;
|
||||
|
||||
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z' stroke='%235FB158' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M16.125 9.75L10.625 15L7.875 12.375' stroke='%235FB158' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-position-y: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.doc_icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@ -43,7 +43,7 @@ export default async function CRMRequestPost(req, res, path, params, array = fal
|
||||
await axios.post(path, payload,
|
||||
{
|
||||
headers: {
|
||||
//"Content-Type": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${ crm_jwt }`,
|
||||
},
|
||||
withCredentials: true,
|
||||
|
||||
@ -1,56 +1,6 @@
|
||||
// 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 { cors } from '../../../lib/cors';
|
||||
import CRMRequestGet from '../../../lib/CRMRequestGet';
|
||||
|
||||
export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
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("----------");
|
||||
console.log(crm_jwt);
|
||||
console.log("----------");
|
||||
|
||||
try
|
||||
{
|
||||
console.log(`${ process.env.CRM_API_HOST }/lk/Contract/GetDocumentList`, { ...client_jwt_decoded, contract_number: req.body.number });
|
||||
|
||||
await axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetDocumentList`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
console.log(`${ process.env.CRM_API_HOST }/lk/Contract/GetDocumentList`, "RESPONSE", crm_response.data);
|
||||
res.status(200).json(crm_response.data);
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error(error);
|
||||
res.status(500);
|
||||
});
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
console.error(e);
|
||||
res.status(500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
}
|
||||
}
|
||||
await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/GetDocumentList`, { contract_number: req.body.number });
|
||||
}
|
||||
@ -11,50 +11,65 @@ export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
if(req.headers.cookie !== undefined)
|
||||
return new Promise(async (resolve) =>
|
||||
{
|
||||
const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : "");
|
||||
if(cookies.jwt !== undefined && cookies.jwt !== null)
|
||||
if(req.headers.cookie !== undefined)
|
||||
{
|
||||
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 });
|
||||
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 });
|
||||
|
||||
const result = {
|
||||
upd: [],
|
||||
upd_avans: [],
|
||||
billfines: [],
|
||||
};
|
||||
const result = {
|
||||
upd: [],
|
||||
upd_avans: [],
|
||||
billfines: [],
|
||||
};
|
||||
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetUPDListByContract`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
console.log(inspect(crm_response.data, true, null, true));
|
||||
for(let i in crm_response.data)
|
||||
{
|
||||
if(crm_response.data[i].type === "UPD")
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetUPDListByContract`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
console.log(inspect(crm_response.data, true, null, true));
|
||||
for(let i in crm_response.data)
|
||||
{
|
||||
result.upd = crm_response.data[i].upd;
|
||||
if(crm_response.data[i].type === "UPD")
|
||||
{
|
||||
result.upd = crm_response.data[i].upd;
|
||||
}
|
||||
if(crm_response.data[i].type === "UPD_Avans")
|
||||
{
|
||||
result.upd_avans = crm_response.data[i].upd;
|
||||
}
|
||||
if(crm_response.data[i].type === "BillFine")
|
||||
{
|
||||
result.billfines = crm_response.data[i].upd;
|
||||
}
|
||||
}
|
||||
if(crm_response.data[i].type === "UPD_Avans")
|
||||
{
|
||||
result.upd_avans = crm_response.data[i].upd;
|
||||
}
|
||||
if(crm_response.data[i].type === "BillFine")
|
||||
{
|
||||
result.billfines = crm_response.data[i].upd;
|
||||
}
|
||||
}
|
||||
|
||||
res.status(200).json(result);
|
||||
})
|
||||
.catch((error) => { console.error(error); resolve(); });
|
||||
res.status(200).json(result);
|
||||
resolve();
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error(error);
|
||||
res.status(500).send();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1,44 +1,6 @@
|
||||
// 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 { cors } from '../../../lib/cors';
|
||||
import { inspect } from 'util';
|
||||
import CRMRequestGet from '../../../lib/CRMRequestGet';
|
||||
|
||||
export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
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 });
|
||||
|
||||
const result = {
|
||||
fines: [],
|
||||
};
|
||||
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetFineGIBDDList`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
result.fines = crm_response.data;
|
||||
|
||||
res.status(200).json(result);
|
||||
})
|
||||
.catch((error) => { console.error(error); });
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
}
|
||||
}
|
||||
await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/GetFineGIBDDList`, { contract_number: req.body.number });
|
||||
}
|
||||
@ -1,46 +1,6 @@
|
||||
// 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 { cors } from '../../../lib/cors';
|
||||
import CRMRequestGet from '../../../lib/CRMRequestGet';
|
||||
|
||||
export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
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 });
|
||||
|
||||
const response = await new Promise((resolve) =>
|
||||
{
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetHelpCard`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
resolve(crm_response.data);
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error(error);
|
||||
resolve(error);
|
||||
});
|
||||
});
|
||||
|
||||
res.status(200).json(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
}
|
||||
}
|
||||
await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/GetHelpCard`, { contract_number: req.body.number });
|
||||
}
|
||||
@ -1,66 +1,6 @@
|
||||
// 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 { cors } from '../../../lib/cors';
|
||||
import CRMRequestGet from '../../../lib/CRMRequestGet';
|
||||
|
||||
export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
if(req.headers.cookie !== undefined)
|
||||
{
|
||||
const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : "");
|
||||
|
||||
console.log("req.body");
|
||||
console.log(req.body);
|
||||
|
||||
if(cookies.jwt !== undefined && cookies.jwt !== null)
|
||||
{
|
||||
console.log("cookies.jwt");
|
||||
console.log(cookies.jwt);
|
||||
|
||||
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", client_jwt_decoded);
|
||||
console.log("crm_jwt", crm_jwt);
|
||||
|
||||
console.log(`${ process.env.CRM_API_HOST }/lk/Contract/GetSchedulePayments`);
|
||||
|
||||
try
|
||||
{
|
||||
await axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetSchedulePayments`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: {
|
||||
"Authorization": `Bearer ${ crm_jwt }`,
|
||||
},
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
console.log("API", "contract", "crm_response.data");
|
||||
//console.log("API", "contract", crm_response.data);
|
||||
|
||||
res.status(200).json(crm_response.data);
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error(error);
|
||||
res.status(500);
|
||||
});
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
console.error(e);
|
||||
res.status(500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
}
|
||||
}
|
||||
await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/GetSchedulePayments`, { contract_number: req.body.number });
|
||||
}
|
||||
@ -1,49 +1,6 @@
|
||||
// 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 { cors } from '../../../lib/cors';
|
||||
import CRMRequestGet from '../../../lib/CRMRequestGet';
|
||||
|
||||
export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
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 });
|
||||
|
||||
try
|
||||
{
|
||||
await axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetAddInfoForContract`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
res.status(200).json(crm_response.data);
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error(error);
|
||||
res.status(500);
|
||||
});
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
console.error(e);
|
||||
res.status(500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
}
|
||||
}
|
||||
await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/GetAddInfoForContract`, { contract_number: req.body.number });
|
||||
}
|
||||
@ -10,103 +10,108 @@ export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
if(req.headers.cookie !== undefined)
|
||||
return new Promise(async (resolve) =>
|
||||
{
|
||||
const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : "");
|
||||
|
||||
console.log("req.body");
|
||||
console.log(req.body);
|
||||
|
||||
if(cookies.jwt !== undefined && cookies.jwt !== null)
|
||||
if(req.headers.cookie !== undefined)
|
||||
{
|
||||
console.log("cookies.jwt");
|
||||
console.log(cookies.jwt);
|
||||
const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : "");
|
||||
|
||||
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("req.body");
|
||||
console.log(req.body);
|
||||
|
||||
console.log("client_jwt_decoded", client_jwt_decoded);
|
||||
console.log("crm_jwt", crm_jwt);
|
||||
|
||||
console.log(`${ process.env.CRM_API_HOST }/lk/Contract/GetOsago`);
|
||||
|
||||
const result = {
|
||||
osago: null,
|
||||
kasko: null,
|
||||
nsib: null,
|
||||
};
|
||||
|
||||
await Promise.all([
|
||||
new Promise((resolve) => {
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetOsago`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
})
|
||||
.then((crm_response) => { result.osago = crm_response.data; resolve(); })
|
||||
.catch((error) => { console.error(error); resolve(); });
|
||||
}),
|
||||
new Promise((resolve) => {
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetKasko`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
})
|
||||
.then((crm_response) => { result.kasko = crm_response.data; resolve(); })
|
||||
.catch((error) => { console.error(error); resolve(); });
|
||||
}),
|
||||
new Promise((resolve) => {
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetNsib`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
})
|
||||
.then((crm_response) => { result.nsib = crm_response.data; resolve(); })
|
||||
.catch((error) => { console.error(error); resolve(); });
|
||||
}),
|
||||
new Promise((resolve) => {
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetFinGap`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
})
|
||||
.then((crm_response) => {
|
||||
result.fingap = crm_response.data;
|
||||
/*result.fingap = [
|
||||
{
|
||||
paid: true,
|
||||
period_type: "current",
|
||||
invoice_url: null,
|
||||
company: "АО \"ГСК \"ЮГОРИЯ\"",
|
||||
site: null,
|
||||
phone: null,
|
||||
number: "ТестФингап",
|
||||
url: null,
|
||||
period: "14.07.2021 - 13.07.2022",
|
||||
amount: 1200000.00
|
||||
},
|
||||
{
|
||||
paid: false,
|
||||
period_type: "prolong",
|
||||
invoice_url: "353082cc-f38f-4da6-bcd4-3a6048eceb10",
|
||||
company: "АО \"ГСК \"ЮГОРИЯ\"",
|
||||
site: null,
|
||||
phone: null,
|
||||
number: "ТестФингап",
|
||||
url: null,
|
||||
period: "14.07.2022 - 13.07.2023",
|
||||
amount: null
|
||||
}
|
||||
];*/
|
||||
resolve();
|
||||
})
|
||||
.catch((error) => { console.error(error); resolve(); });
|
||||
}),
|
||||
])
|
||||
.then(() =>
|
||||
if(cookies.jwt !== undefined && cookies.jwt !== null)
|
||||
{
|
||||
res.status(200).json(result);
|
||||
});
|
||||
console.log("cookies.jwt");
|
||||
console.log(cookies.jwt);
|
||||
|
||||
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", client_jwt_decoded);
|
||||
console.log("crm_jwt", crm_jwt);
|
||||
|
||||
console.log(`${ process.env.CRM_API_HOST }/lk/Contract/GetOsago`);
|
||||
|
||||
const result = {
|
||||
osago: null,
|
||||
kasko: null,
|
||||
nsib: null,
|
||||
};
|
||||
|
||||
await Promise.all([
|
||||
new Promise((resolve_osago) => {
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetOsago`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
})
|
||||
.then((crm_response) => {
|
||||
result.osago = crm_response.data;
|
||||
resolve_osago();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
resolve_osago();
|
||||
});
|
||||
}),
|
||||
new Promise((resolve_kasko) => {
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetKasko`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
})
|
||||
.then((crm_response) => {
|
||||
result.kasko = crm_response.data;
|
||||
resolve_kasko();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
resolve_kasko();
|
||||
});
|
||||
}),
|
||||
new Promise((resolve_nsib) => {
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetNsib`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
})
|
||||
.then((crm_response) => {
|
||||
result.nsib = crm_response.data;
|
||||
resolve_nsib();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
resolve_nsib();
|
||||
});
|
||||
}),
|
||||
new Promise((resolve_fingap) => {
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetFinGap`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
})
|
||||
.then((crm_response) => {
|
||||
result.fingap = crm_response.data;
|
||||
resolve_fingap();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
resolve_fingap();
|
||||
});
|
||||
}),
|
||||
])
|
||||
.then(() =>
|
||||
{
|
||||
res.status(200).json(result);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -10,14 +10,14 @@ export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
if(req.headers.cookie !== undefined)
|
||||
return new Promise(async (resolve) =>
|
||||
{
|
||||
const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : "");
|
||||
if(cookies.jwt !== undefined && cookies.jwt !== null)
|
||||
if(req.headers.cookie !== undefined)
|
||||
{
|
||||
if(jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT))
|
||||
const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : "");
|
||||
if(cookies.jwt !== undefined && cookies.jwt !== null)
|
||||
{
|
||||
const response = await new Promise((resolve, reject) =>
|
||||
if(jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT))
|
||||
{
|
||||
axios.post(`${ process.env.NEXT_PUBLIC_API_HOST }/api/account/materials/`, {
|
||||
})
|
||||
@ -26,27 +26,34 @@ export default async function handler(req, res)
|
||||
console.log("RESPONSE");
|
||||
console.log(api_response.data);
|
||||
|
||||
resolve(api_response.data);
|
||||
res.status(200).json(api_response.data);
|
||||
resolve();
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.log("error");
|
||||
console.error(error);
|
||||
|
||||
reject([]);
|
||||
res.status(500).send();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
res.status(200).json(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1,51 +1,6 @@
|
||||
// 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 { cors } from '../../../lib/cors';
|
||||
import CRMRequestGet from '../../../lib/CRMRequestGet';
|
||||
|
||||
export default async function handler(req, res)
|
||||
{
|
||||
console.log("API", "penalties");
|
||||
await cors(req, res);
|
||||
|
||||
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 });
|
||||
|
||||
const response = await new Promise((resolve) =>
|
||||
{
|
||||
console.log("API", "penalties", `${ process.env.CRM_API_HOST }/lk/Contract/GetPlannedFines`, { contract_number: req.body.number, planned_date: req.body.date });
|
||||
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetPlannedFines`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number, planned_date: req.body.date },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
console.log("API", "penalties", "crm_response.data", crm_response.data);
|
||||
|
||||
resolve(crm_response.data);
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error(error);
|
||||
resolve(error);
|
||||
});
|
||||
});
|
||||
|
||||
res.status(200).json(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
}
|
||||
}
|
||||
await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/GetPlannedFines`, { contract_number: req.body.number, planned_date: req.body.date });
|
||||
}
|
||||
@ -1,46 +1,6 @@
|
||||
// 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 { cors } from '../../../lib/cors';
|
||||
import CRMRequestGet from '../../../lib/CRMRequestGet';
|
||||
|
||||
export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
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 });
|
||||
|
||||
const response = await new Promise((resolve) =>
|
||||
{
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetRegistration`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
resolve(crm_response.data);
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error(error);
|
||||
resolve(error);
|
||||
});
|
||||
});
|
||||
|
||||
res.status(200).json(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
}
|
||||
}
|
||||
await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/GetRegistration`, { contract_number: req.body.number });
|
||||
}
|
||||
@ -10,14 +10,14 @@ export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
if(req.headers.cookie !== undefined)
|
||||
return new Promise(async (resolve) =>
|
||||
{
|
||||
const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : "");
|
||||
if(cookies.jwt !== undefined && cookies.jwt !== null)
|
||||
if(req.headers.cookie !== undefined)
|
||||
{
|
||||
if(jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT))
|
||||
const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : "");
|
||||
if(cookies.jwt !== undefined && cookies.jwt !== null)
|
||||
{
|
||||
const response = await new Promise((resolve, reject) =>
|
||||
if(jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT))
|
||||
{
|
||||
axios.post(`${ process.env.NEXT_PUBLIC_API_HOST }/api/account/rules/`, {
|
||||
date: req.body.date,
|
||||
@ -27,27 +27,34 @@ export default async function handler(req, res)
|
||||
console.log("RESPONSE");
|
||||
console.log(api_response.data);
|
||||
|
||||
resolve(api_response.data);
|
||||
res.status(200).json(api_response.data);
|
||||
resolve();
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.log("error");
|
||||
console.error(error);
|
||||
|
||||
reject([]);
|
||||
res.status(500).send();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
res.status(200).json(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1,46 +1,6 @@
|
||||
// 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 { cors } from '../../../lib/cors';
|
||||
import CRMRequestGet from '../../../lib/CRMRequestGet';
|
||||
|
||||
export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
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 });
|
||||
|
||||
const response = await new Promise((resolve) =>
|
||||
{
|
||||
axios.get(`${ process.env.CRM_API_HOST }/lk/Contract/GetTelematics`, {
|
||||
params: { ...client_jwt_decoded, contract_number: req.body.number },
|
||||
headers: { "Authorization": `Bearer ${ crm_jwt }`, },
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
resolve(crm_response.data);
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error(error);
|
||||
resolve(error);
|
||||
});
|
||||
});
|
||||
|
||||
res.status(200).json(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
}
|
||||
}
|
||||
await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/GetTelematics`, { contract_number: req.body.number });
|
||||
}
|
||||
@ -3,82 +3,9 @@
|
||||
GET /lk/ConsiderationOpportunity
|
||||
*/
|
||||
|
||||
import axios from 'axios';
|
||||
import { Cookies } from 'react-cookie';
|
||||
import cookie from 'cookie';
|
||||
import moment from 'moment';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { cors } from '../../../lib/cors';
|
||||
import CRMRequestGet from '../../../lib/CRMRequestGet';
|
||||
|
||||
export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
return new Promise(async (resolve) =>
|
||||
{
|
||||
if(req.headers.cookie !== undefined)
|
||||
{
|
||||
const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : "");
|
||||
|
||||
console.log("req.body");
|
||||
console.log(req.body);
|
||||
|
||||
if(cookies.jwt !== undefined && cookies.jwt !== null)
|
||||
{
|
||||
console.log("cookies.jwt");
|
||||
console.log(cookies.jwt);
|
||||
|
||||
var client_jwt_decoded = jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT);
|
||||
const crm_payload = { acc_number: client_jwt_decoded.acc_number };
|
||||
var crm_jwt = jwt.sign(crm_payload, process.env.JWT_SECRET_CRM, { noTimestamp: true });
|
||||
|
||||
console.log("client_jwt_decoded", client_jwt_decoded);
|
||||
console.log("crm_jwt", crm_jwt);
|
||||
|
||||
const url = `${ process.env.CRM_API_HOST }/lk/ConsiderationOpportunity/`;
|
||||
console.log({ url });
|
||||
|
||||
try
|
||||
{
|
||||
await axios.get(url, {
|
||||
params: crm_payload,
|
||||
headers: {
|
||||
"Authorization": `Bearer ${ crm_jwt }`,
|
||||
},
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
console.log("API", "contract", "crm_response.data");
|
||||
//console.log("API", "contract", crm_response.data);
|
||||
|
||||
res.status(200).json(crm_response.data);
|
||||
resolve();
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error(error);
|
||||
res.status(500).send();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
console.error(e);
|
||||
res.status(500).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/ConsiderationOpportunity/`, {});
|
||||
}
|
||||
@ -1,4 +1,107 @@
|
||||
/*
|
||||
2.7.5 - Метод отправки документов по Сделке на проверку
|
||||
POST /lk/document
|
||||
*/
|
||||
*/
|
||||
|
||||
import axios from 'axios';
|
||||
import { Cookies } from 'react-cookie';
|
||||
import cookie from 'cookie';
|
||||
import moment from 'moment';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { inspect } from 'util';
|
||||
import FormData from 'form-data';
|
||||
import multer from 'multer';
|
||||
|
||||
import { cors } from '../../../lib/cors';
|
||||
|
||||
const storage = multer.memoryStorage();
|
||||
const upload = multer({ storage: storage });
|
||||
|
||||
export default async function handler(req, res)
|
||||
{
|
||||
await cors(req, res);
|
||||
|
||||
console.log("Qqqqqqq", req);
|
||||
const { number, entity, id, filename } = req.query;
|
||||
|
||||
return new Promise((resolve) =>
|
||||
{
|
||||
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({ acc_number: client_jwt_decoded.acc_number }, process.env.JWT_SECRET_CRM, { noTimestamp: true });
|
||||
|
||||
const payload = new URLSearchParams({
|
||||
name: number,
|
||||
entity: entity,
|
||||
documentTypeNumber: id,
|
||||
documentName: filename,
|
||||
});
|
||||
const path = `${ process.env.CRM_API_HOST }/lk/incident/RequestClient/UploadDocument?${ payload.toString() }`;
|
||||
|
||||
// res.status(200).json({ path });
|
||||
// resolve();
|
||||
|
||||
upload.single("file")(req, {}, err =>
|
||||
{
|
||||
const { file } = req;
|
||||
file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf8');
|
||||
|
||||
const data = new FormData();
|
||||
data.append("file", file.buffer, file.originalname);
|
||||
|
||||
try
|
||||
{
|
||||
axios.post(path, data,
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": `multipart/form-data; boundary=${ data._boundary }`,
|
||||
"Authorization": `Bearer ${ crm_jwt }`,
|
||||
},
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((crm_response) =>
|
||||
{
|
||||
res.status(200).json(crm_response.data);
|
||||
resolve();
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error("-".repeat(30), "error.response.data:");
|
||||
console.error(error.response.data);
|
||||
|
||||
res.status(500).json(error.response.data);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
console.error(e);
|
||||
res.status(500).send(e);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: false
|
||||
}
|
||||
}
|
||||
@ -21,7 +21,7 @@ export default async function handler(req, res)
|
||||
try
|
||||
{
|
||||
axios.get(`${ process.env.CRM_API_HOST }/file/GetFile/`, {
|
||||
params: { ...client_jwt_decoded, id: req.query.id },
|
||||
params: { acc_number: client_jwt_decoded.acc_number, id: req.query.id },
|
||||
responseType: 'arraybuffer',
|
||||
headers: {
|
||||
"Authorization": `Bearer ${ crm_jwt }`,
|
||||
@ -42,22 +42,26 @@ export default async function handler(req, res)
|
||||
console.log("-".repeat(50));
|
||||
|
||||
res.status(200).send(crm_response.data);
|
||||
resolve();
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error(error);
|
||||
res.status(500);
|
||||
res.status(500).send();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
console.error(e);
|
||||
res.status(500);
|
||||
res.status(500).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.status(403);
|
||||
res.status(403).send();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,6 +123,7 @@ class ContractPage extends React.Component
|
||||
log={{
|
||||
contract_number: this.props.number,
|
||||
document_type: type,
|
||||
document_name: file.number,
|
||||
document_date: file.date,
|
||||
description: file.type,
|
||||
}}
|
||||
|
||||
@ -312,16 +312,16 @@ class ContractServicesPage extends React.Component
|
||||
{ this._checkInsuranceAvailable() ? (
|
||||
<div className="block_body full">
|
||||
{ insurance.kasko !== undefined && insurance.kasko !== null && insurance.kasko !== "" && insurance.kasko.map !== undefined && insurance.kasko.map((entry, index) => (
|
||||
<Insurance type="kasko" title="КАСКО" entry={ entry } index={ index } />
|
||||
<Insurance type="kasko" title="КАСКО" entry={ entry } index={ index } key={ index } />
|
||||
)) }
|
||||
{ insurance.osago !== undefined && insurance.osago !== null && insurance.osago !== "" && insurance.osago.map !== undefined && insurance.osago.map((entry, index) => (
|
||||
<Insurance type="osago" title="ОСАГО" entry={ entry } index={ index } />
|
||||
<Insurance type="osago" title="ОСАГО" entry={ entry } index={ index } key={ index }/>
|
||||
)) }
|
||||
{ insurance.nsib !== undefined && insurance.nsib !== null && insurance.nsib !== "" && insurance.nsib.map !== undefined && insurance.nsib.map((entry, index) => (
|
||||
<Insurance type="nsib" title="НСИБ" entry={ entry } index={ index } />
|
||||
<Insurance type="nsib" title="НСИБ" entry={ entry } index={ index } key={ index }/>
|
||||
)) }
|
||||
{ insurance.fingap !== undefined && insurance.fingap !== null && insurance.fingap !== "" && insurance.fingap.map !== undefined && insurance.fingap.map((entry, index) => (
|
||||
<Insurance type="fingap" title="Safe Finance" entry={ entry } index={ index } />
|
||||
<Insurance type="fingap" title="Safe Finance" entry={ entry } index={ index } key={ index }/>
|
||||
)) }
|
||||
</div>
|
||||
) : (
|
||||
|
||||
@ -103,7 +103,6 @@ class SupportAppealsPage extends React.Component
|
||||
const active_count = this._activeAppealsCount();
|
||||
//console.log(appeals);
|
||||
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Head>
|
||||
@ -166,13 +165,14 @@ class SupportAppealsPage extends React.Component
|
||||
<div className="dosc_list medium-icon">
|
||||
{ appeal.documents.map((file, index) => {
|
||||
if(file.doc_direction !== "incoming") { return null; }
|
||||
|
||||
return (
|
||||
<RequestFile
|
||||
key={ `template_${ index }` }
|
||||
file={ file }
|
||||
log={{
|
||||
incident_number: file.number,
|
||||
document_name: file.doc_number,
|
||||
incident_number: appeal.number,
|
||||
document_name: file.doc_url,
|
||||
}}
|
||||
/>)
|
||||
}) }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user