// Crew rank hierarchy (org chart) — captured from Crewing.excalidraw and the
// tree in wiki Crewing-Data-Model §2. A self-referential tree like the Account
// accounting-code hierarchy: `parentCode = null` is the top of the org.
//
//   grantsLogin = true  → only PM, Assistant PM, Site In-charge (the three ranks
//                         that map to a SITE_STAFF portal login). Everyone else is
//                         a crew member / data subject with no account.
//   isSeafarer  = true  → the dredging/engine/deck crew who hold seafarer documents
//                         (STCW/CDC/COC/medical). Management & shore-support do not.
//   category            → OPERATIONAL vs SUPPORT (the classDef "sup" nodes).

import type { RankCategory } from "@prisma/client";

export type RankEntry = {
  code: string;
  name: string;
  parentCode: string | null;
  category: RankCategory;
  isSeafarer: boolean;
  grantsLogin: boolean;
};

export const RANKS: RankEntry[] = [
  // ── Management (portal logins) ──────────────────────────────────────────────
  { code: "PM",   name: "Project Manager",                parentCode: null,  category: "OPERATIONAL", isSeafarer: false, grantsLogin: true  },
  { code: "APM",  name: "Assistant Project Manager",      parentCode: "PM",  category: "OPERATIONAL", isSeafarer: false, grantsLogin: true  },
  { code: "SIC",  name: "Site In-charge",    parentCode: "APM", category: "OPERATIONAL", isSeafarer: false, grantsLogin: true  },

  // ── Shore support (no login, no seafarer docs) ──────────────────────────────
  { code: "ACC",  name: "Accountant",        parentCode: "APM",  category: "SUPPORT", isSeafarer: false, grantsLogin: false },
  { code: "DRV",  name: "Driver",            parentCode: "APM",  category: "SUPPORT", isSeafarer: false, grantsLogin: false },
  { code: "COOK", name: "Cook",              parentCode: "APM",  category: "SUPPORT", isSeafarer: false, grantsLogin: false },
  { code: "CKH",  name: "Cook Helper",       parentCode: "COOK", category: "SUPPORT", isSeafarer: false, grantsLogin: false },

  // ── Operational crew (seafarers) ────────────────────────────────────────────
  { code: "DIC",  name: "Dredger In-charge",     parentCode: "SIC", category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
  { code: "SDO",  name: "Senior Dredge Operator",   parentCode: "DIC", category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
  { code: "PLS",  name: "Pipeline Supervisor",   parentCode: "SDO", category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
  { code: "PLA",  name: "Pipeline Assistant",    parentCode: "PLS", category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
  { code: "JDO",  name: "Junior Dredge Operator",   parentCode: "SDO", category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
  { code: "ERO",  name: "Engine Room Operator",  parentCode: "JDO", category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
  { code: "DH",   name: "Deck Hand",             parentCode: "ERO", category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
  { code: "TR",   name: "Trainee",               parentCode: "DH",  category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
  { code: "MB",   name: "Mess Boy",              parentCode: "DH",  category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
  { code: "ELE",  name: "Electrician",           parentCode: "SDO", category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
  { code: "SFB",  name: "Senior Fabricator",        parentCode: "SDO", category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
  { code: "FW",   name: "Fabricator / Welder",   parentCode: "SFB", category: "OPERATIONAL", isSeafarer: true, grantsLogin: false },
];
