From fdf795b47d8d6e8326815e75d83a965db1c5ac9f Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Sun, 7 May 2023 14:34:24 +0300 Subject: [PATCH] pass elt error to rows --- .../Calculation/Form/ELT/Components/PolicyTable.tsx | 2 +- apps/web/Components/Calculation/Form/ELT/Osago.tsx | 4 ++-- .../Components/Calculation/Form/ELT/lib/config.tsx | 11 ++++++++--- apps/web/config/schema/elt.ts | 2 +- apps/web/process/elt/lib/helper.ts | 4 ++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/apps/web/Components/Calculation/Form/ELT/Components/PolicyTable.tsx b/apps/web/Components/Calculation/Form/ELT/Components/PolicyTable.tsx index f0a180d..ce1076e 100644 --- a/apps/web/Components/Calculation/Form/ELT/Components/PolicyTable.tsx +++ b/apps/web/Components/Calculation/Form/ELT/Components/PolicyTable.tsx @@ -18,7 +18,7 @@ export const PolicyTable = observer( x: true, }} rowSelection={{ - getCheckboxProps: (record) => ({ disabled: !record.sum || record.isFetching }), + getCheckboxProps: (record) => ({ disabled: !record.sum || record.status }), hideSelectAll: true, onSelect: (record) => { if (record.sum > 0) setSelectedKey(record.key); diff --git a/apps/web/Components/Calculation/Form/ELT/Osago.tsx b/apps/web/Components/Calculation/Form/ELT/Osago.tsx index 5b3103d..096efac 100644 --- a/apps/web/Components/Calculation/Form/ELT/Osago.tsx +++ b/apps/web/Components/Calculation/Form/ELT/Osago.tsx @@ -37,7 +37,7 @@ export function Osago() { }); async function handleOnClick() { - const fetchingRows = rows.map((x) => ({ ...x, isFetching: true })); + const fetchingRows = rows.map((x) => ({ ...x, status: 'fetching', sum: 0 })); $tables.elt.osago.setRows(fetchingRows); queries.forEach(({ refetch }) => { @@ -45,11 +45,11 @@ export function Osago() { if (res.data) { const { key, numCalc, premiumSum, message, skCalcId, error } = res.data; $tables.elt.osago.setRow({ - isFetching: false, key, message: message || error, numCalc, skCalcId, + status: error ? 'error' : null, sum: premiumSum, }); } diff --git a/apps/web/Components/Calculation/Form/ELT/lib/config.tsx b/apps/web/Components/Calculation/Form/ELT/lib/config.tsx index e1745fb..d7ca3c6 100644 --- a/apps/web/Components/Calculation/Form/ELT/lib/config.tsx +++ b/apps/web/Components/Calculation/Form/ELT/lib/config.tsx @@ -1,5 +1,5 @@ import type { RowSchema } from '@/config/schema/elt'; -import { LoadingOutlined } from 'ui/elements/icons'; +import { CloseOutlined, LoadingOutlined } from 'ui/elements/icons'; import type { ColumnsType } from 'ui/elements/table'; import type { z } from 'zod'; @@ -28,8 +28,13 @@ export const columns: ColumnsType = [ title: 'Франшиза', }, { - dataIndex: 'isFetching', - render: (value) => value && , + dataIndex: 'status', + render: (value) => { + if (value === 'fetching') return ; + if (value === 'error') return ; + + return false; + }, title: undefined, }, ]; diff --git a/apps/web/config/schema/elt.ts b/apps/web/config/schema/elt.ts index 1c61fa2..b9369cf 100644 --- a/apps/web/config/schema/elt.ts +++ b/apps/web/config/schema/elt.ts @@ -267,13 +267,13 @@ export const ResultEltOsagoSchema = z.record( export const RowSchema = z.object({ id: z.string(), - isFetching: z.boolean(), key: z.string(), message: z.string().nullable(), name: z.string(), numCalc: z.number(), requestId: z.string(), skCalcId: z.string(), + status: z.string().nullable(), sum: z.number(), totalFranchise: z.number(), }); diff --git a/apps/web/process/elt/lib/helper.ts b/apps/web/process/elt/lib/helper.ts index d76d090..8cc0cb4 100644 --- a/apps/web/process/elt/lib/helper.ts +++ b/apps/web/process/elt/lib/helper.ts @@ -41,13 +41,13 @@ export default function helper({ apolloClient, store }: ProcessContext) { ['6', '9', '10'].includes(evo_leasingobject_type?.evo_id) ? x?.evo_id_elt_smr : x?.evo_id_elt, - isFetching: false, key: x?.value, message: null, name: x?.label, numCalc: 0, requestId: '', skCalcId: '', + status: null, sum: 0, totalFranchise: 0, })) || []) as Row[], @@ -55,13 +55,13 @@ export default function helper({ apolloClient, store }: ProcessContext) { ?.filter((x) => x?.evo_type_ins_policy?.includes(100_000_001) && x?.evo_id_elt_osago) .map((x) => ({ id: x?.evo_id_elt_osago, - isFetching: false, key: x?.value, message: null, name: x?.label, numCalc: 0, requestId: '', skCalcId: '', + status: null, sum: 0, totalFranchise: 0, })) || []) as Row[],