'use client'; import React, { useEffect } from 'react'; import { SkillsAll, SkillRow } from '../types'; import { green } from '../colors'; const slugify = (name: string) => String(name || '') .toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/^-+|-+$/g, ''); const SkillsAppendixTable = ({ skillsAll }: { skillsAll?: SkillsAll }) => { const rows = (skillsAll?.skills || []).filter((row: SkillRow) => row.observed?.present || row.self_reported?.present || row.certified?.present); useEffect(() => { const flash = () => { const hash = typeof window !== 'undefined' ? window.location.hash : ''; if (!hash) return; // Support skill rows and category headers const id = hash.startsWith('#') ? hash.slice(1) : hash; const el = document.getElementById(id) as HTMLElement | null; if (!el) return; const originalBg = el.style.backgroundColor; el.style.transition = 'background-color 300ms ease'; el.style.backgroundColor = 'rgba(2, 163, 137, 0.14)'; setTimeout(() => { el.style.backgroundColor = originalBg || ''; }, 1200); }; flash(); window.addEventListener('hashchange', flash); return () => window.removeEventListener('hashchange', flash); }, []); if (!rows.length) return null; // Group rows by category; skills can be in multiple categories const groupMap: Record = {}; const UNCATEGORIZED = 'Uncategorized'; for (const r of rows) { const cats = Array.isArray((r as any).categories) && (r as any).categories.length > 0 ? (r as any).categories as string[] : [UNCATEGORIZED]; for (const c of cats) { const key = c || UNCATEGORIZED; if (!groupMap[key]) groupMap[key] = []; groupMap[key].push(r); } } const orderedCategories = Object.keys(groupMap).sort((a, b) => { if (a === UNCATEGORIZED) return 1; if (b === UNCATEGORIZED) return -1; return a.localeCompare(b); }); return (
{orderedCategories.map((cat) => (
{cat}
{groupMap[cat].map((row, idx: number) => ( {(['observed','self_reported','certified'] as const).map((b) => { const bucket = row[b]; const present = !!bucket.present; const dot = present ? green : 'var(--icon-button-secondary)'; const ev = bucket.evidence; const sources = (bucket.sources || []).slice(0,4); return ( ); })} ))}
Skill Observed Self-reported Certified
{row.name}
{(ev || (sources && sources.length > 0)) && (
{ev ?
{ev}
: null}
)}
))}
); }; export default SkillsAppendixTable;