elt/osago: add results validation
This commit is contained in:
parent
539ddf52b9
commit
cf2b3af0ee
@ -1,9 +1,11 @@
|
||||
/* eslint-disable sonarjs/cognitive-complexity */
|
||||
import { PolicyTable, ReloadButton, Validation } from './Components';
|
||||
import { columns } from './lib/config';
|
||||
import { makeEltOsagoRequest } from './lib/make-request';
|
||||
import type { Row, StoreSelector } from './types';
|
||||
import { getEltOsago } from '@/api/elt/query';
|
||||
import { STALE_TIME } from '@/constants/request';
|
||||
import { MAX_INSURANCE, MIN_INSURANCE } from '@/constants/values';
|
||||
import { useStore } from '@/stores/hooks';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import type { QueryFunctionContext } from '@tanstack/react-query';
|
||||
@ -43,10 +45,32 @@ export function Osago() {
|
||||
queries.forEach(({ refetch }) => {
|
||||
refetch().then((res) => {
|
||||
if (res.data) {
|
||||
const { key, numCalc, premiumSum, message, skCalcId, error } = res.data;
|
||||
const { key, numCalc, premiumSum, message, skCalcId } = res.data;
|
||||
let { error } = res.data;
|
||||
|
||||
if (premiumSum > MAX_INSURANCE) {
|
||||
error ||= `Сумма по страховке превышает максимально допустимое значение по стоимости ОСАГО: ${Intl.NumberFormat(
|
||||
'ru',
|
||||
{
|
||||
currency: 'RUB',
|
||||
style: 'currency',
|
||||
}
|
||||
).format(MAX_INSURANCE)}`;
|
||||
}
|
||||
|
||||
if (premiumSum < MIN_INSURANCE) {
|
||||
error ||= `Сумма по страховке не должна быть меньше допустимого значения по стоимости ОСАГО: ${Intl.NumberFormat(
|
||||
'ru',
|
||||
{
|
||||
currency: 'RUB',
|
||||
style: 'currency',
|
||||
}
|
||||
).format(MIN_INSURANCE)}`;
|
||||
}
|
||||
|
||||
$tables.elt.osago.setRow({
|
||||
key,
|
||||
message: message || error,
|
||||
message: error || message,
|
||||
numCalc,
|
||||
skCalcId,
|
||||
status: error ? 'error' : null,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user