All files / src/components Layout.tsx

100% Statements 42/42
100% Branches 10/10
100% Functions 4/4
100% Lines 42/42

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 551x   1x   1x   1x 22x 22x 22x 22x 22x         22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x   22x 22x 22x 22x 22x   22x 22x   22x 22x   22x 22x 22x 22x 22x 22x 22x 22x   22x  
import { Link, NavLink } from "react-router-dom";
import type { ReactNode } from "react";
import { ServiceHealthPill } from "./ServiceHealthPill";
import type { HealthSummary } from "../lib/health";
import { roleLabel, type Session } from "../auth/session";
 
export function Layout({
  health,
  session,
  onLogout,
  children,
}: {
  health: HealthSummary;
  session: Session;
  onLogout: () => void;
  children: ReactNode;
}) {
  return (
    <div className="shell">
      <header className="shell__header">
        <Link to="/" className="brand">
          <span className="brand__mark">RD</span>
          <span>
            <strong>Robot Dispatch</strong>
            <small>консоль флота</small>
          </span>
        </Link>
        <div className="shell__session">
          <span className={`role-chip role-chip--${session.role}`}>{roleLabel(session.role)}</span>
          <ServiceHealthPill health={health} />
          <button type="button" className="button button--ghost" onClick={onLogout}>
            Выйти
          </button>
        </div>
      </header>
      <nav className="tabs" aria-label="Разделы">
        <NavLink to="/" end className={({ isActive }) => (isActive ? "tabs__link tabs__link--active" : "tabs__link")}>
          Обзор
        </NavLink>
        <NavLink to="/tasks" className={({ isActive }) => (isActive ? "tabs__link tabs__link--active" : "tabs__link")}>
          Задачи
        </NavLink>
        <NavLink to="/robots" className={({ isActive }) => (isActive ? "tabs__link tabs__link--active" : "tabs__link")}>
          Роботы
        </NavLink>
      </nav>
      <main className="shell__main">{children}</main>
      <footer className="shell__footer">
        <span>FastAPI · PostgreSQL · RabbitMQ</span>
        <span>данные обновляются каждые 3 секунды</span>
      </footer>
    </div>
  );
}