import { openNotification } from 'client/Elements/Notification'; import { Status } from 'core/types/statuses'; import { ITable } from 'core/types/tables'; const tableInsurance: ITable = { rows: [ { policyType: { value: 'ОСАГО', }, insuranceCompany: { value: null, }, insured: { value: null, }, insCost: { value: 0, }, insTerm: { value: null, status: Status.Disabled, }, }, { policyType: { value: 'КАСКО', }, insuranceCompany: { value: null, }, insured: { value: null, }, insCost: { value: 0, }, insTerm: { value: null, status: Status.Disabled, }, }, { policyType: { value: 'ДГО', }, insuranceCompany: { value: null, status: Status.Disabled, }, insured: { value: null, status: Status.Disabled, }, insCost: { value: 0, }, insTerm: { value: null, status: Status.Disabled, }, }, { policyType: { value: 'НС', }, insuranceCompany: { value: null, status: Status.Disabled, }, insured: { value: null, status: Status.Disabled, }, insCost: { value: 0, }, insTerm: { value: null, status: Status.Disabled, }, }, ], options: { insured: [ { name: 'Лизингополучатель', value: 100000000, }, { name: 'Лизингодатель', value: 100000001, }, ], insTerm: [ { name: '12 месяцев', value: 100000000, }, { name: 'Срок ДЛ', value: 100000001, }, ], }, callbacks: { insCost: (calculationStore, tableName, rowIndex) => { if ( calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value && calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value > 0 && !calculationStore.tables[tableName]?.rows[rowIndex]['insuranceCompany'] ?.value ) { openNotification({ type: 'error', title: 'Ошибка', description: 'Не указана страховая компания по полису', })(); } if ( calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value && calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value > 0 && !calculationStore.tables[tableName]?.rows[rowIndex]['insTerm']?.value ) { openNotification({ type: 'error', title: 'Ошибка', description: 'Не указан срок страхования', })(); } if ( calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value && calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value > 0 && !calculationStore.tables[tableName]?.rows[rowIndex]['insured']?.value ) { openNotification({ type: 'error', title: 'Ошибка', description: 'Не указан плательщик', })(); } }, insured: (calculationStore, tableName, rowIndex) => { if ( calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value && calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value > 0 && !calculationStore.tables[tableName]?.rows[rowIndex]['insured']?.value ) { openNotification({ type: 'error', title: 'Ошибка', description: 'Не указан плательщик', })(); } }, insTerm: (calculationStore, tableName, rowIndex) => { if ( calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value && calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value > 0 && !calculationStore.tables[tableName]?.rows[rowIndex]['insTerm']?.value ) { openNotification({ type: 'error', title: 'Ошибка', description: 'Не указан срок страхования', })(); } }, insuranceCompany: (calculationStore, tableName, rowIndex) => { if ( calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value && calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value > 0 && !calculationStore.tables[tableName]?.rows[rowIndex]['insuranceCompany'] ?.value ) { openNotification({ type: 'error', title: 'Ошибка', description: 'Не указана страховая компания по полису', })(); } }, }, }; export default tableInsurance;