From 387295b357d7f159a74b7b46fb3ceeb71d2404fc Mon Sep 17 00:00:00 2001 From: merelendor Date: Fri, 3 Nov 2023 17:14:01 +0300 Subject: [PATCH] update for contract invoices --- actions/dealsActions.js | 21 +++--- actions/invoicesActions.js | 54 ++++++++------- .../DealsStatus/components/DocumentsForm.js | 9 ++- components/DealsStatus/index.js | 15 ++++- css/main/style.css | 11 ++-- css/main/style.less | 16 +++-- pages/contract/index.js | 65 +++++++++++++++++-- reducers/dealsReducer.js | 5 +- reducers/initialState.js | 1 + 9 files changed, 136 insertions(+), 61 deletions(-) diff --git a/actions/dealsActions.js b/actions/dealsActions.js index bd4eee3..f421145 100644 --- a/actions/dealsActions.js +++ b/actions/dealsActions.js @@ -33,6 +33,8 @@ export const getDeals = ({ dispatch, update = false }) => return new Promise((resolve, reject) => { + let last = 0; + axios.post(url, {}, { withCredentials: true, }) @@ -40,23 +42,21 @@ export const getDeals = ({ dispatch, update = false }) => { console.log("ACTION", "deals", "getDeals()", "response", response.data); - /* - if(update) + for(let i in response.data) { - for(let i in response.data) + const n = parseInt(response.data[i].opp_number, 10); + + if(n > last) { - if(response.data[i].opp_number == "20325") - { - response.data[i].statuscode_id = 101; - } + last = n; } } - */ dispatch({ type: actionTypes.DEALS_LIST, data: { - list: response.data + list: response.data, + last, } }); @@ -73,7 +73,8 @@ export const getDeals = ({ dispatch, update = false }) => dispatch({ type: actionTypes.DEALS_LIST, data: { - list: [] + list: [], + last, } }); diff --git a/actions/invoicesActions.js b/actions/invoicesActions.js index e4022c8..98efaf5 100644 --- a/actions/invoicesActions.js +++ b/actions/invoicesActions.js @@ -71,36 +71,42 @@ export const downloadInvoiceFile = ({ payload, filename }) => export const getInvoiceKASKO = ({ number }) => { - axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/invoice/kasko`, { number }, + return new Promise((resolve, reject) => { - withCredentials: true, - }) - .then(async (response) => - { - console.log("getInvoiceKASKO", { response: response.data }); - resolve(); - }) - .catch((error) => - { - console.error(error); - reject(); + axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/invoice/kasko`, { number }, + { + withCredentials: true, + }) + .then(async (response) => + { + console.log("getInvoiceKASKO", { response: response.data }); + resolve(response.data); + }) + .catch((error) => + { + console.error(error); + reject(); + }); }); } export const getInvoiceFinGap = ({ number }) => { - axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/invoice/fingap`, { number }, + return new Promise((resolve, reject) => { - withCredentials: true, - }) - .then(async (response) => - { - console.log("getInvoiceFinGap", { response: response.data }); - resolve(); - }) - .catch((error) => - { - console.error(error); - reject(); + axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/invoice/fingap`, { number }, + { + withCredentials: true, + }) + .then(async (response) => + { + console.log("getInvoiceFinGap", { response: response.data }); + resolve(response.data); + }) + .catch((error) => + { + console.error(error); + reject(); + }); }); } \ No newline at end of file diff --git a/components/DealsStatus/components/DocumentsForm.js b/components/DealsStatus/components/DocumentsForm.js index ece5c82..782b11c 100644 --- a/components/DealsStatus/components/DocumentsForm.js +++ b/components/DealsStatus/components/DocumentsForm.js @@ -30,11 +30,11 @@ class QuestionnaireForm extends React.Component _handle_onCreateQuestionnaire = (event) => { event.preventDefault(); - const { onQuestionnaire, deal_id } = this.props; + const { onQuestionnaire, deal_id, last_deal_id } = this.props; this.setState({ loading: true, }, () => { - createQuestionnaire(deal_id) + createQuestionnaire(last_deal_id) .then(() => { onQuestionnaire(); @@ -315,6 +315,8 @@ export default class DocumentsForm extends Step const { index, statuscode_id, dealSelected, documents, questionnaire_status, onQuestionnaire, } = this.props; const { open, uploaded, uploading, loading, completed } = this.state; + console.log("DocumentsForm", "render", { props: this.props }); + return (
this.status ? "done" : "" }`}>

№ { dealSelected }

@@ -333,10 +335,11 @@ export default class DocumentsForm extends Step

Анкета клиента:

-
diff --git a/components/DealsStatus/index.js b/components/DealsStatus/index.js index fda915c..7b29fea 100644 --- a/components/DealsStatus/index.js +++ b/components/DealsStatus/index.js @@ -16,6 +16,7 @@ class DealsStatus extends React.Component currentSelected: null, dealSelected: undefined, deals: undefined, + lastDealNumber: 0, } } @@ -32,7 +33,17 @@ class DealsStatus extends React.Component getDeals({ dispatch }); } - componentDidUpdate(prevProps, prevState) { } + componentDidUpdate(prevProps, prevState) + { + if(prevState.deals.list === null && this.state.deals.list !== null) + { + let lastDealNumber = 0; + for(let i in this.state.deals.list) + { + console.log("DealsStatus", this.state.deals.list[i]); + } + } + } _onDealsUpdate = () => { @@ -102,6 +113,8 @@ class DealsStatus extends React.Component const { currentContractModalOpened, allContractModalOpened, currentSelected, dealSelected, deals, status, } = this.state const { questionnaire_status, onQuestionnaire, } = this.props; + console.log("render", { deals }); + return ( <> { deals.list !== undefined && deals.list !== null && deals.list.length > 0 && ( diff --git a/css/main/style.css b/css/main/style.css index b02ef87..e4eaacb 100644 --- a/css/main/style.css +++ b/css/main/style.css @@ -7155,14 +7155,11 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_ display: flex; gap: 40px 20px; flex-wrap: wrap; - padding-bottom: 40px; } .contract_invoices_list .invoice { max-width: 23%; width: 23%; - min-height: 90px; - border-bottom: solid 1px var(--gray-light); - border-left: solid 1px var(--gray-light); + min-height: 85px; padding-bottom: 10px; align-items: flex-start; justify-content: space-between; @@ -7189,7 +7186,7 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_ } .contract_invoices_list .invoice p { line-height: 15px; - color: var(--text_not_active); + color: var(--gray); } @media all and (max-width: 1280px) { .contract_invoices_list .invoice p { @@ -7202,7 +7199,6 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_ align-items: flex-start; justify-content: flex-start; width: 100%; - padding-left: 10px; } .contract_invoices_list .invoice .actions .icon { margin-top: 5px; @@ -7219,6 +7215,9 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_ padding: 0; zoom: 0.65; } +.contract_invoices_list .invoice .actions .icon.formal { + background-image: url("data:image/svg+xml,%3Csvg width='26' height='28' viewBox='0 0 26 28' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 3.5C2 1.84315 3.34315 0.5 5 0.5H18.3701L20.7774 4L23.1848 7.06354V24.5C23.1848 26.1569 21.8417 27.5 20.1848 27.5H5C3.34314 27.5 2 26.1569 2 24.5V3.5Z' fill='%231C01A9'/%3E%3Cpath opacity='0.4' d='M23.1858 11.5V7L19.334 6.5L23.1858 11.5Z' fill='%230C0C0C'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 7.50098)' stroke='%23F0F0F0'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 12.501)' stroke='%23F0F0F0'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 17.501)' stroke='%23F0F0F0'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 22.501)' stroke='%23F0F0F0'/%3E%3Cpath d='M23.1858 7H19.3711C18.8188 7 18.3711 6.55228 18.3711 6V3.5V0.5L23.1858 7Z' fill='%232F80ED'/%3E%3C/svg%3E"); +} .contract_invoices_list .invoice .actions .icon .extension { font-weight: 600; font-size: 12px; diff --git a/css/main/style.less b/css/main/style.less index b3d957e..417aaaa 100644 --- a/css/main/style.less +++ b/css/main/style.less @@ -8189,14 +8189,14 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block { display: flex; gap: 40px 20px; flex-wrap: wrap; - padding-bottom: 40px; +// padding-bottom: 40px; .invoice { max-width: 23%; width: 23%; - min-height: 90px; - border-bottom: solid 1px var(--gray-light); - border-left: solid 1px var(--gray-light); + min-height: 85px; + //border-bottom: solid 1px var(--gray-light); + //border-left: solid 1px var(--gray-light); padding-bottom: 10px; align-items: flex-start; @@ -8221,7 +8221,7 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block { p { line-height: 15px; - color: var(--text_not_active); + color: var(--gray); @media all and (max-width: 1280px) { font-size: 13px; @@ -8234,7 +8234,7 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block { align-items: flex-start; justify-content: flex-start; width: 100%; - padding-left: 10px; + //padding-left: 10px; .icon { margin-top: 5px; @@ -8251,6 +8251,10 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block { padding: 0; zoom: 0.65; + &.formal { + background-image: url("data:image/svg+xml,%3Csvg width='26' height='28' viewBox='0 0 26 28' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 3.5C2 1.84315 3.34315 0.5 5 0.5H18.3701L20.7774 4L23.1848 7.06354V24.5C23.1848 26.1569 21.8417 27.5 20.1848 27.5H5C3.34314 27.5 2 26.1569 2 24.5V3.5Z' fill='%231C01A9'/%3E%3Cpath opacity='0.4' d='M23.1858 11.5V7L19.334 6.5L23.1858 11.5Z' fill='%230C0C0C'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 7.50098)' stroke='%23F0F0F0'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 12.501)' stroke='%23F0F0F0'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 17.501)' stroke='%23F0F0F0'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 22.501)' stroke='%23F0F0F0'/%3E%3Cpath d='M23.1858 7H19.3711C18.8188 7 18.3711 6.55228 18.3711 6V3.5V0.5L23.1858 7Z' fill='%232F80ED'/%3E%3C/svg%3E"); + } + .extension { font-weight: 600; font-size: 12px; diff --git a/pages/contract/index.js b/pages/contract/index.js index 16d009a..9789085 100644 --- a/pages/contract/index.js +++ b/pages/contract/index.js @@ -14,7 +14,7 @@ import Footer from '../components/Footer'; import Company from "../components/Company"; import InnerMenu from "./components/InnerMenu"; -import { downloadInvoiceFile, getContract, getContractDebtInvoiceFile, getContractInfo, getContractInvoices, getContractPenaltyInvoiceFile, signGetGUIDEntity, signGetWMDoc } from './../../actions'; +import { downloadInvoiceFile, getContract, getContractDebtInvoiceFile, getContractInfo, getContractInvoices, getContractPenaltyInvoiceFile, getFile, getInvoiceFinGap, getInvoiceKASKO, signGetGUIDEntity, signGetWMDoc } from './../../actions'; import AccountLayout from "../components/Layout/Account"; import ContractHeader from "./components/ContractHeader"; @@ -38,12 +38,64 @@ class Invoice extends React.Component { case "kaskoProlong": { + getInvoiceKASKO({ number: contract_number }) + .then(async (document_result) => + { + let document = undefined; + console.log({ document_result }); + + for(let i in document_result) + { + if(document_result[i].period_type === "prolong") + { + document = document_result[i]; + break; + } + } + + if(document !== undefined) + { + await getFile({ id: document.invoice_url, filename: `ЛК ЭВОЛЮЦИЯ - договор ${ contract_number } - ${ group.title }.${ document.invoice_extension }` }); + } + this.setState({ loading: false }); + }) + .catch((document_result_error) => + { + console.error({ document_result_error }); + this.setState({ loading: false }); + }); } break; case "fingapProlong": { - + getInvoiceFinGap({ number: contract_number }) + .then(async (document_result) => + { + let document = undefined; + console.log({ document_result }); + + for(let i in document_result) + { + if(document_result[i].period_type === "prolong") + { + document = document_result[i]; + break; + } + } + + console.log({ document }); + if(document !== undefined) + { + await getFile({ id: document.invoice_url, filename: `ЛК ЭВОЛЮЦИЯ - договор ${ contract_number } - ${ group.title }.${ document.invoice_extension }` }); + } + this.setState({ loading: false }); + }) + .catch((document_result_error) => + { + console.error({ document_result_error }); + this.setState({ loading: false }); + }); } break; @@ -51,12 +103,12 @@ class Invoice extends React.Component { const guid_result = await signGetGUIDEntity({ contract_number }); console.log({ guid_result, code: group.code }); - await downloadInvoiceFile({ payload: { entity_id: guid_result.entityid, code: group.code }, filename: `ЛК Эволюция - договор ${ contract_number } - ${ group.title }.pdf` }); + await downloadInvoiceFile({ payload: { entity_id: guid_result.entityid, code: group.code }, filename: `ЛК ЭВОЛЮЦИЯ - договор ${ contract_number } - ${ group.title }.pdf` }); + + this.setState({ loading: false }); } break; } - - this.setState({ loading: false }); }); } @@ -73,8 +125,7 @@ class Invoice extends React.Component

{ group.title }

-
- PDF +
{ loading ? ( diff --git a/reducers/dealsReducer.js b/reducers/dealsReducer.js index 3598124..7aa0c4d 100644 --- a/reducers/dealsReducer.js +++ b/reducers/dealsReducer.js @@ -18,14 +18,11 @@ const dealsReducer = (state = initialState.deals, action) => case actionTypes.DEALS_LIST: { console.log("actionTypes.DEALS_LIST", actionTypes.DEALS_LIST, { action }); - console.log({ - ...state, - list: action.data.list, - }); return { ...state, list: action.data.list, + last: action.data.last, }; } diff --git a/reducers/initialState.js b/reducers/initialState.js index 4fa6554..81cca2c 100644 --- a/reducers/initialState.js +++ b/reducers/initialState.js @@ -239,6 +239,7 @@ export const defaultState = { { loaded: false, list: null, + last: 0, details: {}, /*{ loaded: false,