edo initial

This commit is contained in:
merelendor 2023-09-21 11:52:54 +03:00
parent da4383b4fe
commit 9cd9a6916b
14 changed files with 161 additions and 8 deletions

50
actions/edoActions.js Normal file
View File

@ -0,0 +1,50 @@
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 { eachSeries } from 'async';
import * as actionTypes from '../constants/actionTypes';
import * as currentState from '../reducers/initialState';
export const getEDOList = ({ dispatch, update = false }) =>
{
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/list`;
console.log("ACTION", "edo", "getList()", { url });
return new Promise((resolve, reject) =>
{
axios.post(url, {}, {
withCredentials: true,
})
.then((response) =>
{
console.log("ACTION", "edo", "getList()", "response", response.data);
dispatch({
type: actionTypes.EDO_LIST,
data: {
list: response.data
}
});
resolve();
})
.catch((error) =>
{
console.error("ACTION", "edo", "getList()", "ERROR");
console.error(error);
dispatch({
type: actionTypes.EDO_LIST,
data: {
list: []
}
});
reject();
});
});
}

View File

@ -161,10 +161,10 @@ class Offers extends Step
) : (
<>
{ offers.length > 0 ? (
<table>
<table className="deal_offers_table">
<thead>
<tr>
<th></th>
{ statuscode_id === 100 && <th></th> }
<th></th>
<th>Стоимость</th>
<th>Первый платеж, р.</th>
@ -178,12 +178,16 @@ class Offers extends Step
<tbody>
{ offers.map((offer, offer_index) => (
<tr key={ offer_index }>
<td>
<div className="form_field checkbox">
<input type="checkbox" name="row" id={`offer_${ offer.quote_number }`} checked={ checked.indexOf(offer.quote_number) > -1 } onChange={ () => { this._handle_onCheckOffer(offer.quote_number) } }/>
<label htmlFor={`offer_${ offer.quote_number }`}></label>
</div>
</td>
{ offer.quote_status ? (
<td>
<div className="form_field checkbox">
<input type="checkbox" name="row" id={`offer_${ offer.quote_number }`} checked={ checked.indexOf(offer.quote_number) > -1 } onChange={ () => { this._handle_onCheckOffer(offer.quote_number) } }/>
<label htmlFor={`offer_${ offer.quote_number }`}></label>
</div>
</td>
) : (
<td></td>
)}
<td>{ offer_index + 1 }</td>
<td>{ numeral(offer.price).format(' ., ') } р.</td>
<td>{ numeral(offer.first_payment_rub).format(' ., ') } р.</td>

View File

@ -54,3 +54,7 @@ export const DEAL_DOCUMENTS_LIST = 'DEAL_DOCUMENTS_LIST';
export const DEAL_CONTRACTS_LIST = 'DEAL_CONTRACTS_LIST';
export const DEALS_RESET = 'DEALS_RESET';
export const DEAL_RESET = 'DEAL_RESET';
export const EDO_LOADED = 'EDO_LOADED';
export const EDO_LIST = 'EDO_LIST';
export const EDO_RESET = 'EDO_RESET';

View File

@ -1668,3 +1668,6 @@
margin: 0px!important;
}
}
.deal_offers_table {
width: 100%;
}

View File

@ -1955,4 +1955,8 @@
margin: 0px!important;
}
}
}
.deal_offers_table {
width: 100%;
}

3
pages/api/edo/check.js Normal file
View File

@ -0,0 +1,3 @@
/*
2.8.2 - Метод ограничений количества отправок Приглашений Клиенту(для ЭДО) (lk/Account/GetAccessInviteEdoBox)
*/

View File

@ -0,0 +1,3 @@
/*
2.8.4 - Метод получения отправленных (но еще не принятых) приглашений Клиенту (для ЭДО) (lk/Account/GetInviteEdoBox)
*/

View File

@ -0,0 +1,3 @@
/*
2.8.3 - Метод отправки Приглашения Клиенту(для ЭДО) (lk/Account/InviteEdoBox)
*/

View File

@ -0,0 +1,3 @@
/*
2.8.5 - Метод обновления (по кнопке!) Приглашений Клиенту(для ЭДО) (lk/Account/UpdateEdoBox)
*/

11
pages/api/edo/list.js Normal file
View File

@ -0,0 +1,11 @@
/*
2.8.1 - Метод получения доступных для работы в ЭДО ящиков (lk/Account/GetEdoBox)
*/
import CRMRequestGet from '../../../lib/CRMRequestGet';
export default async function handler(req, res)
{
console.log("API", "EDO", "/list");
await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Account/GetEdoBox`, {});
}

View File

@ -22,6 +22,7 @@ import Company from "../components/Company";
import { sendPhoneChangeNumber, sendPhoneChangeNumberSmsCode, setUserPhone } from '../../actions';
import AccountLayout from "../components/Layout/Account";
import { getEDOList } from "../../actions/edoActions";
class IndexPage extends React.Component
{
@ -52,6 +53,17 @@ class IndexPage extends React.Component
componentDidMount()
{
const { dispatch } = this.props;
getEDOList({ dispatch })
.then(() =>
{
})
.catch(() =>
{
});
}
_handle_onFormSubmit = (event) =>

46
reducers/edoReducer.js Normal file
View File

@ -0,0 +1,46 @@
import { HYDRATE } from 'next-redux-wrapper';
import * as actionTypes from '../constants/actionTypes';
import initialState from "./initialState";
const edoReducer = (state = initialState.edo, action) =>
{
switch (action.type)
{
case actionTypes.EDO_LOADED:
{
return {
...state,
loaded: action.data.loaded,
};
}
case actionTypes.EDO_LIST:
{
console.log("actionTypes.EDO_LIST", actionTypes.EDO_LIST, { action });
console.log({
...state,
list: action.data.list,
});
return {
...state,
list: action.data.list,
};
}
case actionTypes.EDO_RESET:
{
return {
loaded: false,
list: null,
};
}
default: {
return state;
}
}
};
export default edoReducer;

View File

@ -252,6 +252,11 @@ export const defaultState = {
},
*/
},
edo:
{
loaded: false,
list: null,
}
};
export default JSON.parse(JSON.stringify({ ...defaultState, ...{ questionnaire: questionnaire_template } }));

View File

@ -16,6 +16,7 @@ import contractEventsReducer from '../reducers/contractEventsReducer';
import contractFinesReducer from '../reducers/contractFinesReducer';
import questionnaireReducer from '../reducers/questionnaireReducer';
import dealsReducer from '../reducers/dealsReducer';
import edoReducer from '../reducers/edoReducer';
const combinedReducer = combineReducers({
auth: authReducer,
@ -33,6 +34,7 @@ const combinedReducer = combineReducers({
contract_fines: contractFinesReducer,
questionnaire: questionnaireReducer,
deals: dealsReducer,
edo: edoReducer,
});
const makeStore = (context) =>