/* Dailies · Shared surface nav
   ---------------------------------------------------------------------------
   One cross-surface nav, loaded as a <script type="text/babel"> BEFORE each
   surface's app (same global-scope sharing the project already uses for
   TweaksPanel). Renders links to every product surface EXCEPT the current one.
   The launcher ("Home") is intentionally never listed — the wordmark/logo on
   each surface is the route home.

   Usage:  <SurfaceNav current="ic-home" role="ic" />
     current — key of the page you're on (its own link is omitted)
     role    — 'ic' | 'reviewer'; sets the Past Approvals ?as= landing scope
   ============================================================ */

const SURFACES = [
  { key: 'feed',       label: 'Feed',            href: 'Dailies Feed.html' },
  { key: 'ic-home',    label: 'IC home',         href: 'IC Home.html' },
  { key: 'ic-request', label: 'IC request',      href: 'IC Request.html' },
  { key: 'thread',     label: 'Feedback thread', href: 'Feedback Thread.html' },
  { key: 'approvals',  label: 'Past approvals',  href: 'Past Approvals.html' },
];

function SurfaceNav({ current, role, className }) {
  const approvalsAs = role === 'ic' ? 'maya' : 'brian';
  return (
    <nav className={'surface-nav' + (className ? ' ' + className : '')} aria-label="Other surfaces">
      {SURFACES.filter(s => s.key !== current).map(s => {
        const href = s.key === 'approvals' ? s.href + '?as=' + approvalsAs : s.href;
        return (
          <a
            key={s.key}
            className={'surface-navlink' + (s.key === 'approvals' ? ' is-archive' : '')}
            href={href}
          >{s.label}</a>
        );
      })}
    </nav>
  );
}
