// admin-state-3.jsx — Exceptions, integrations, payroll, audit + Provider.

// ── Exceptions queue (live operational issues) ───────────────
const EXCEPTIONS = [
  { id: 'ex-001', kind: 'training-expired',   severity: 'high',     empId: 'e-3025', detail: 'BNSF RWP expired 2025-12-18 — cannot foul track', age: '4d',   actionable: true },
  { id: 'ex-002', kind: 'training-expired',   severity: 'high',     empId: 'e-7733', detail: 'UP RWP expires in 8 days — schedule recert',     age: '2h',   actionable: true },
  { id: 'ex-003', kind: 'briefing-missing',   severity: 'critical', empId: 'e-8814', detail: 'On site at JOB-24208 — no briefing on file today', age: '32m',  actionable: true },
  { id: 'ex-004', kind: 'overtime-week',      severity: 'med',      empId: 'e-1907', detail: 'Diana Russo · 51.2 hrs this week (11.2 OT)',      age: '1h',   actionable: false },
  { id: 'ex-005', kind: 'photo-missing',      severity: 'low',      empId: 'e-2241', detail: 'Field report 05-21 had only 3 of 4 required photos', age: '1d', actionable: true },
  { id: 'ex-006', kind: 'gps-mismatch',       severity: 'med',      empId: 'e-5512', detail: 'Clock-in GPS 47.2mi from job site',               age: '6h',   actionable: true },
  { id: 'ex-007', kind: 'unsigned-timecard',  severity: 'med',      empId: 'e-4488', detail: 'Timecard 05-21 missing employee signature',       age: '18h',  actionable: true },
];
const EXCEPTION_LABELS = {
  'training-expired': 'Training expired',
  'briefing-missing': 'Briefing missing',
  'overtime-week':    'Overtime threshold',
  'photo-missing':    'Photo evidence',
  'gps-mismatch':     'GPS mismatch',
  'unsigned-timecard':'Unsigned timecard',
};

// ── Payroll runs ────────────────────────────────────────────
const PAYROLL_RUNS = [
  { id: 'pr-2026-w20', period: '2026-05-04 — 2026-05-17', payDate: '2026-05-22', gross: 76842.50, employees: 8, status: 'processing', target: 'ADP RUN',     submittedAt: null,                  hours: 824.5 },
  { id: 'pr-2026-w19', period: '2026-04-20 — 2026-05-03', payDate: '2026-05-08', gross: 71240.00, employees: 8, status: 'paid',       target: 'ADP RUN',     submittedAt: '2026-05-06T16:11:00', hours: 765.0 },
  { id: 'pr-2026-w18', period: '2026-04-06 — 2026-04-19', payDate: '2026-04-24', gross: 68910.75, employees: 8, status: 'paid',       target: 'ADP RUN',     submittedAt: '2026-04-22T15:30:00', hours: 740.0 },
  { id: 'pr-2026-w17', period: '2026-03-23 — 2026-04-05', payDate: '2026-04-10', gross: 64320.00, employees: 7, status: 'paid',       target: 'ADP RUN',     submittedAt: '2026-04-08T16:02:00', hours: 690.5 },
];

// ── Payroll integrations (mock connection status) ───────────
const INTEGRATIONS = [
  { id: 'adp-run',    name: 'ADP RUN',           kind: 'payroll', status: 'connected',  primary: true,  format: 'API',     lastSync: '2026-05-22T06:00', desc: 'Bi-weekly RWIC payroll · primary' },
  { id: 'qbo',        name: 'QuickBooks Online', kind: 'gl',      status: 'connected',  primary: false, format: 'API',     lastSync: '2026-05-22T06:00', desc: 'General ledger journal entries' },
  { id: 'qbd',        name: 'QuickBooks Desktop',kind: 'gl',      status: 'available',  primary: false, format: 'IIF',     lastSync: null,               desc: 'Export IIF files for desktop import' },
  { id: 'adp-wfn',    name: 'ADP Workforce Now', kind: 'payroll', status: 'available',  primary: false, format: 'API',     lastSync: null,               desc: 'Enterprise-tier ADP' },
  { id: 'paychex',    name: 'Paychex Flex',      kind: 'payroll', status: 'available',  primary: false, format: 'API',     lastSync: null,               desc: 'Switch from ADP RUN' },
  { id: 'gusto',      name: 'Gusto',             kind: 'payroll', status: 'available',  primary: false, format: 'API',     lastSync: null,               desc: 'Small-team payroll' },
  { id: 'sage',       name: 'Sage 50 / Intacct', kind: 'gl',      status: 'available',  primary: false, format: 'CSV',     lastSync: null,               desc: 'Sage accounting' },
  { id: 'paylocity',  name: 'Paylocity',         kind: 'payroll', status: 'available',  primary: false, format: 'API',     lastSync: null,               desc: 'HCM + payroll' },
  { id: 'peachtree',  name: 'Peachtree',         kind: 'gl',      status: 'available',  primary: false, format: 'CSV',     lastSync: null,               desc: 'Legacy GL export' },
  { id: 'miter',      name: 'Miter',             kind: 'payroll', status: 'available',  primary: false, format: 'API',     lastSync: null,               desc: 'Construction-focused payroll' },
  { id: 'intuit',     name: 'Intuit Payroll',    kind: 'payroll', status: 'available',  primary: false, format: 'API',     lastSync: null,               desc: 'Intuit standalone payroll' },
  { id: 'csv',        name: 'Generic CSV / IIF', kind: 'export',  status: 'connected',  primary: false, format: 'CSV/IIF', lastSync: 'on demand',        desc: 'Fallback download for any platform' },
  { id: 'webhook',    name: 'Webhook / API',     kind: 'export',  status: 'available',  primary: false, format: 'JSON',    lastSync: null,               desc: 'Push events to your own system' },
];

// ── Audit (sample for officer view) ─────────────────────────
const AUDIT = [
  { id:'a-001', ts:'2026-05-22T07:14', actor:'Marcus Hale',  role:'rwic',  event:'CLOCK_IN',         detail:'JOB-24179 · F10 · GPS captured (47.7128, -121.3525)' },
  { id:'a-002', ts:'2026-05-22T07:21', actor:'Marcus Hale',  role:'rwic',  event:'BRIEFING_SIGNED',  detail:'4 of 5 contractor crew signed; M. Halverson pending' },
  { id:'a-003', ts:'2026-05-22T06:58', actor:'Diana Russo',  role:'rwic',  event:'CLOCK_IN',         detail:'JOB-24179 · F10 · GPS captured (47.7140, -121.3502)' },
  { id:'a-004', ts:'2026-05-22T05:42', actor:'L. Park',      role:'ops',   event:'JOB_ASSIGN',       detail:'A. Sokolov assigned to JOB-24210 (UT)' },
  { id:'a-005', ts:'2026-05-21T17:30', actor:'Carl Whitehorse', role:'ops', event:'TIMECARD_APPROVE', detail:'Approved 6 timecards for ops queue → routed to accounting' },
  { id:'a-006', ts:'2026-05-21T16:05', actor:'Master Diagnostic', role:'master', event:'LOGIN_MASTER', detail:'Diagnostic backdoor session opened from FLG-2241' },
];

Object.assign(window, {
  EXCEPTIONS, EXCEPTION_LABELS, PAYROLL_RUNS, INTEGRATIONS, AUDIT,
});
