чистка кода

This commit is contained in:
gorbenko.pavel
2026-08-07 14:02:56 +05:00
parent 419aaac60a
commit 03391d7669
19 changed files with 67 additions and 37 deletions
@@ -6,7 +6,7 @@ export function toEmployeeOption(employee: Employee): ISearchableOption {
return { value: employee.email, label: employee.fio, sublabel: employee.email };
}
export function findEmployeeByEmail(employees: Employee[], email: string | null): Employee | undefined {
export function findEmployeeByEmail(employees: Employee[], email: string | undefined): Employee | undefined {
if (!email) return undefined;
const target = email.toLowerCase();
return employees.find(e => e.email.toLowerCase() === target);
@@ -3,12 +3,14 @@ import { comparisonOperatorSymbols, headTypeLabels, projectRoleLabels, texts } f
import { findEmployeeByEmail } from './employee';
/** Каким из четырёх взаимоисключающих способов у шага задан исполнитель. */
/* eslint-disable @rushstack/no-new-null -- форма зеркалит TemplateRouteStep (nullable JSON-контракт бэкенда) */
export function detectExecutorKind(step: {
executorEmail?: string | null;
position?: string | null;
projectRole?: ProjectRole | null;
headType?: HeadType | null;
}): StepExecutorKind {
/* eslint-enable @rushstack/no-new-null */
if (step.executorEmail) return 'email';
if (step.position) return 'position';
if (step.projectRole && step.projectRole !== ProjectRole.None) return 'projectRole';
@@ -24,7 +26,7 @@ export interface StepExecutorDisplay {
/** Колонка «Исполнитель» в таблице шагов шаблона маршрута. */
export function describeStepExecutor(step: TemplateRouteStep, employees: Employee[]): StepExecutorDisplay {
if (step.executorEmail) {
const employee = findEmployeeByEmail(employees, step.executorEmail);
const employee = findEmployeeByEmail(employees, step.executorEmail ?? undefined);
return employee ? { primary: employee.fio, secondary: employee.email } : { primary: step.executorEmail };
}
if (step.position) return { primary: step.position };