evoleasing-account/actions/dealsActions.js
2023-08-29 15:30:38 +03:00

104 lines
2.5 KiB
JavaScript

import axios from 'axios';
import { Cookies } from 'react-cookie';
import Router from 'next/router';
import moment from 'moment';
import { nSQL } from "@nano-sql/core";
import * as actionTypes from '../constants/actionTypes';
import * as currentState from '../reducers/initialState';
/*DEALS_LIST
/lk/ConsiderationOpportunity/quote
[{
"quote_number": "582189",
"price": 5490000,
"first_payment_perc": 30,
"first_payment_rub": 1647000,
"brand_name": "Volkswagen",
"model_name": "Touareg",
"object_count": 1,
}, {
"quote_number": "580008",
"price": 5341770,
"first_payment_perc": 30,
"first_payment_rub": 1647000,
"brand_name": "Volkswagen",
"model_name": "Touareg",
"object_count": 1,
}]
[{
"opp_number": "780",
"statuscode_id": 107,
"statuscode_name": " ",
"comment": null,
}, {
"opp_number": "37197",
"statuscode_id": 101,
"statuscode_name": " ",
"comment": null,
}]
opp_number- номер Лизинговой сделки
statuscode_id - номер этапа
statuscode_name - имя этапа
comment - сопроводительный текст для данного этапа, который надо выводить
*/
export const getDeals = ({ dispatch }) =>
{
console.log("ACTION", "deals", "getDeals()", `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals`);
return new Promise((resolve, reject) =>
{
console.log("??????????????????????? WTF");
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals`, {}, {
withCredentials: true,
})
.then((response) =>
{
console.log("!!!!!!!!!!!!!!!!!!!!!!!!! GOOOOOOD");
console.log("ACTION", "deals", "getDeals()", "response", response.data);
dispatch({
type: actionTypes.DEALS_LIST,
data: {
list: [{
"opp_number": "780",
"statuscode_id": 107,
"statuscode_name": " ",
"comment": null,
}, {
"opp_number": "37197",
"statuscode_id": 101,
"statuscode_name": " ",
"comment": null,
}]
}
});
resolve();
})
.catch((error) =>
{
console.log("!!!!!!!!!!!!!!!!!!!!!!!!! ERROR", { action: actionTypes.DEALS_LIST });
dispatch({
type: actionTypes.DEALS_LIST,
data: {
list: [{
"opp_number": "780",
"statuscode_id": 107,
"statuscode_name": " ",
"comment": null,
}, {
"opp_number": "37197",
"statuscode_id": 101,
"statuscode_name": " ",
"comment": null,
}]
}
});
console.error(error);
reject();
});
});
}