// KAR-782 / R36: detect the global system-dummy consultant.
//
// When a project lead is deleted and no other consultant exists, the project
// is auto-reassigned to the seeded dummy ('(System) Nicht zugewiesen',
// is_system_dummy = true) so the RESTRICT FK does not break (see
// lib/employees/reassign-lead.ts). Wherever that dummy shows up AS a project
// lead, the UI must flag it as a placeholder so it is clear the project needs
// a real reassignment.
//
// Detection prefers the is_system_dummy flag; it falls back to the seeded
// display name for projections that don't select the flag.

export const SYSTEM_DUMMY_DISPLAY_NAME = '(System) Nicht zugewiesen'
export const SYSTEM_PLACEHOLDER_BADGE_LABEL = 'System-Platzhalter'

export function isSystemDummyConsultant(
  c: { is_system_dummy?: boolean | null; display_name?: string | null } | null | undefined,
): boolean {
  if (!c) return false
  if (c.is_system_dummy === true) return true
  return (c.display_name ?? '').trim() === SYSTEM_DUMMY_DISPLAY_NAME
}
