The bell is a shared pile: every active HR person sees every open note, regardless of who wrote it. That was agreed and it stays the default — this narrows it, it never widens it. You can now untick colleagues whose notes you do not want to see. What gets stored is the *exceptions*, not the selection. The difference shows the day someone new joins HR: had the selection been stored, she would be invisible to everyone until each person ticked her, and nobody would notice her follow-ups piling up. This way she is visible from day one and hiding her is a deliberate act. Same reasoning that made notes a shared inbox in the first place — the silent gap is worse than a row too many. Own notes always come through: `note_mutes` rejects a self-reference, and the predicate says so again rather than depending on a check constraint staying put. Notes with no author come through too — hiding one because nobody knows who wrote it is exactly the loss this list exists to prevent. The rule lives in lib/notes.ts as one SQL expression because two places need it: the bell in the header and the "Anstehend" card on the dashboard. Two copies drift, and then the card counts something the bell does not show. No SQL function and no audit row, unlike anything that touches employee data — this is a personal display preference, and an audit trail recording every tick would make finding real changes harder. Same pattern as saved reports and hire drafts, and the owner policy on note_mutes means a row for someone else cannot be written even with invented values. The checkbox flips immediately and flips back if saving fails; the list gets clicked through several at a time and a round trip per tick feels like hesitation. Verified: 19 tests, five mutation-checked (or→and, dropping the own-notes clause, inverting `not exists`, inverting the default, and losing the email fallback each turn them red). Typecheck, lint, schema drift, 477 tests and the build are clean. Not seen in a browser: login goes through the company account and the database is unreachable — the migration is reviewed but has not been run. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
67 lines
2.5 KiB
TypeScript
67 lines
2.5 KiB
TypeScript
"use client";
|
|
|
|
import { LogOut, Menu } from "lucide-react";
|
|
import { usePathname } from "next/navigation";
|
|
import { logout } from "@/actions/auth";
|
|
import type { OpenNote } from "@/lib/notes";
|
|
import { NewHireButton } from "./NewHireButton";
|
|
import { NotesBell } from "./NotesBell";
|
|
|
|
const TITLES: Record<string, string> = {
|
|
"/": "Übersicht",
|
|
"/employees": "Mitarbeiter:innen",
|
|
"/orgchart": "Organigramm",
|
|
"/positions": "Positionen",
|
|
"/reports": "Berichte",
|
|
"/audit": "Audit-Log",
|
|
};
|
|
|
|
function titleFor(pathname: string): string {
|
|
if (TITLES[pathname]) return TITLES[pathname];
|
|
const match = Object.keys(TITLES).find((key) => key !== "/" && pathname.startsWith(key));
|
|
return match ? TITLES[match] : "Alpenwerk HR";
|
|
}
|
|
|
|
type TopbarProps = {
|
|
userLabel: string;
|
|
openNotes: OpenNote[];
|
|
kollegen: { id: string; name: string; sichtbar: boolean }[];
|
|
onOpenNav: () => void;
|
|
};
|
|
|
|
export function Topbar({ userLabel, openNotes, kollegen, onOpenNav }: TopbarProps) {
|
|
const pathname = usePathname();
|
|
|
|
return (
|
|
// Sticky, with the notch inset added to its top padding: on an iPhone in
|
|
// landscape the bar would otherwise sit under the rounded corner.
|
|
<header className="sticky top-0 z-20 flex h-14 shrink-0 items-center justify-between border-b border-border bg-white px-3 pt-[env(safe-area-inset-top)] sm:px-6">
|
|
<div className="flex min-w-0 items-center gap-2">
|
|
<button
|
|
type="button"
|
|
onClick={onOpenNav}
|
|
aria-label="Navigation öffnen"
|
|
className="-ml-1 rounded p-2 text-ink-body hover:bg-surface lg:hidden"
|
|
>
|
|
<Menu className="h-5 w-5" />
|
|
</button>
|
|
<h1 className="truncate text-base font-bold text-ink">{titleFor(pathname)}</h1>
|
|
</div>
|
|
<div className="flex shrink-0 items-center gap-1 sm:gap-4">
|
|
<NotesBell notes={openNotes} kollegen={kollegen} />
|
|
<NewHireButton />
|
|
<div className="flex items-center gap-2 text-sm sm:border-l sm:border-border sm:pl-4">
|
|
{/* The name is the first thing worth dropping on a narrow screen —
|
|
the account is still reachable via the sign-out control. */}
|
|
<span className="hidden font-semibold text-ink md:inline">{userLabel}</span>
|
|
<form action={logout}>
|
|
<button type="submit" aria-label="Abmelden" className="rounded p-2 text-ink-muted hover:bg-surface">
|
|
<LogOut className="h-4 w-4" />
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|