From 37d70b1c4608316247eba717931014879e1bba40 Mon Sep 17 00:00:00 2001 From: Chika Date: Tue, 6 Oct 2020 17:30:03 +0300 Subject: [PATCH] prelast payments table effect --- .../CalculationStore/Effects/reaction.ts | 40 +++++++++++++ .../config/initialTables/tablePayments.ts | 59 ++++++++++++++++++- 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/src/client/stores/CalculationStore/Effects/reaction.ts b/src/client/stores/CalculationStore/Effects/reaction.ts index 791307d..a4a3cc9 100644 --- a/src/client/stores/CalculationStore/Effects/reaction.ts +++ b/src/client/stores/CalculationStore/Effects/reaction.ts @@ -2319,6 +2319,46 @@ const reactionEffects: IReactionEffect[] = [ break; } + case 100000004: { + calculationStore.setTableRows( + 'tablePayments', + 1, + )([ + { + paymentRelation: { + value: 25, + status: Status.Default, + }, + }, + { + paymentRelation: { + value: 50, + status: Status.Default, + }, + }, + { + paymentRelation: { + value: 75, + status: Status.Default, + }, + }, + ]); + + calculationStore.setTableRows( + 'tablePayments', + 4, + )( + Array.from({ length: leasingPeriod - 5 }, () => ({ + paymentRelation: { + value: 100, + status: Status.Disabled, + }, + })), + ); + + break; + } + default: { break; } diff --git a/src/core/config/initialTables/tablePayments.ts b/src/core/config/initialTables/tablePayments.ts index 02511b7..aae997c 100644 --- a/src/core/config/initialTables/tablePayments.ts +++ b/src/core/config/initialTables/tablePayments.ts @@ -62,7 +62,6 @@ const tablePayments: ITable = { } } const middleRows = toJS(calculationStore.tables[tableName].rows); - console.log('middleRows', middleRows); middleRows.splice(0, 1); middleRows.splice(-1, 1); @@ -86,6 +85,64 @@ const tablePayments: ITable = { } } } + if (graphType === 100000004) { + if (rowIndex > 0 && rowIndex < 4) { + for (let i in calculationStore.tables[tableName].rows) { + const currRow = + calculationStore.tables[tableName].rows[parseInt(i)]; + const prevRow = + calculationStore.tables[tableName].rows[parseInt(i) - 1]; + if ( + parseInt(i) > 0 && + parseInt(i) < 4 && + currRow && + prevRow && + currRow.paymentRelation?.value < prevRow.paymentRelation?.value + ) { + calculationStore.setTableRow( + tableName, + parseInt(i), + )({ + paymentRelation: { + validation: false, + }, + }); + } else { + calculationStore.setTableRow( + tableName, + parseInt(i), + )({ + paymentRelation: { + validation: true, + }, + }); + } + } + + const middleRows = toJS(calculationStore.tables[tableName].rows); + middleRows.splice(0, 1); + middleRows.length = 3; + + if ( + middleRows.every( + x => + x.paymentRelation?.value === + middleRows[0].paymentRelation?.value, + ) + ) { + calculationStore.setTableRows( + tableName, + 1, + )( + Array.from({ length: middleRows.length }, (v, i) => ({ + paymentRelation: { + validation: false, + }, + })), + ); + } + } + } }, }, };