Новые условия #15

Merged
gorbenko.pavel merged 4 commits from new-ifs into main 2026-08-24 12:27:25 +00:00
2 changed files with 8 additions and 3 deletions
Showing only changes of commit 4c3d119db8 - Show all commits
@@ -9,7 +9,10 @@ import {
slaHoursToInput,
triStateToBool
} from './sla';
import { APPROVAL_PHASE } from '../models';
import { APPROVAL_PHASE, ManagedApprovalRow } from '../models';
/** Ровно те поля строки, которые читает activatedAt (см. его сигнатуру). */
type ActivationRow = Pick<ManagedApprovalRow, 'order' | 'phase' | 'dateIso'>;
// Смысл всех этих проверок один: «не задано» и «ноль/нет» — РАЗНЫЕ состояния.
// Если они где-то схлопнутся, шаг с настройкой «напоминать сразу» станет
@@ -110,7 +113,7 @@ describe('effectiveSlaHours', () => {
// Повторяет ReminderService.ActivatedAt на бэкенде — та же формула, поэтому и
// проверяется на тех же случаях (параллельные шаги, переход между фазами).
describe('activatedAt', () => {
const row = (order: number, phase: string, dateIso: string) => ({ order, phase, dateIso });
const row = (order: number, phase: string, dateIso: string): ActivationRow => ({ order, phase, dateIso });
it('первый шаг согласования — от создания заявки', () => {
const rows = [row(1, APPROVAL_PHASE.approval, '')];
@@ -76,10 +76,11 @@ export function formatSlaHours(value: number | null | undefined): string {
* здесь его нужно повторить, чтобы посчитать просрочку и показать реальное число
* часов, а не только «от типа заявки» без цифры.
*/
// eslint-disable-next-line @rushstack/no-new-null -- зеркалит nullable-контракт бэкенда
export function effectiveSlaHours(
row: Pick<ManagedApprovalRow, 'slaHours'>,
// eslint-disable-next-line @rushstack/no-new-null -- зеркалит nullable-контракт бэкенда
requestTypeSlaHours: number | null | undefined
// eslint-disable-next-line @rushstack/no-new-null -- null = «SLA не задан нигде», это не 0
): number | null {
if (row.slaHours !== null) return row.slaHours;
return requestTypeSlaHours ?? null;
@@ -140,6 +141,7 @@ export function isRowOverdue(
row: Pick<ManagedApprovalRow, 'order' | 'phase' | 'dateIso' | 'slaHours'>,
allRows: readonly Pick<ManagedApprovalRow, 'order' | 'phase' | 'dateIso'>[],
requestCreatedIso: string,
// eslint-disable-next-line @rushstack/no-new-null -- зеркалит nullable-контракт бэкенда
requestTypeSlaHours: number | null | undefined,
now: Date
): boolean {