process/payments(degression): fix reaction error

This commit is contained in:
Chika 2022-10-04 20:11:26 +03:00
parent 2b6960de45
commit c8afffe5b2

View File

@ -214,10 +214,9 @@ export default function paymentsReactions(
/** /**
* Дегрессия * Дегрессия
*/ */
const mapGraphTypeToSeasonTypes: { [key: number]: Array<number> } = { const degressionSeasonTypes = new Set([
100_000_001: [100_000_003, 100_000_004, 100_000_005, 100_000_006, 100_000_007], 100_000_003, 100_000_004, 100_000_005, 100_000_006, 100_000_007,
100_000_003: [100_000_000, 100_000_001, 100_000_002], ]);
};
reaction( reaction(
() => { () => {
@ -226,15 +225,14 @@ export default function paymentsReactions(
return graphType; return graphType;
}, },
(graphType) => { (graphType) => {
if (!graphType) { if (!graphType || graphType !== 100_000_001) {
$calculation.setElementOptions('selectSeasonType', []); $calculation.setElementOptions('selectSeasonType', []);
return; return;
} }
const allowedSeasonTypes = mapGraphTypeToSeasonTypes[graphType];
const selectSeasonTypeOptions = selectSeasonType.filter((option) => const selectSeasonTypeOptions = selectSeasonType.filter((option) =>
allowedSeasonTypes.includes(option.value) degressionSeasonTypes.has(option.value)
); );
$calculation.setElementOptions('selectSeasonType', selectSeasonTypeOptions); $calculation.setElementOptions('selectSeasonType', selectSeasonTypeOptions);
} }