Ein (i) an jeder Kachel der Uebersicht
Beim Darueberfahren, per Tastatur oder Antippen erklaert ein Hinweis, was die Zahl bedeutet und wie sie sich zusammensetzt. Bei den Langzeitabwesenden steht ausdruecklich: exklusive Krankenstand -- gewoehnliche Krankenstaende werden nicht erfasst; die eigens erfasste Art "Langer Krankenstand" ist enthalten. Das (i) steht neben dem Link der Kachel, nicht darin: sonst oeffnete ein Klick die Liste, und das overflow-hidden der Kachel schnitte den Hinweis ab. Ein Test haelt die Texte gegen die Kachelbeschriftungen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,12 +2,21 @@ import { ChevronRight } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { Fragment, Suspense } from "react";
|
||||
import { AnstehendFilter } from "@/components/dashboard/AnstehendFilter";
|
||||
import { AnstehendListe, type AnstehendEintrag } from "@/components/dashboard/AnstehendListe";
|
||||
import {
|
||||
AnstehendListe,
|
||||
type AnstehendEintrag,
|
||||
} from "@/components/dashboard/AnstehendListe";
|
||||
import { DraftsCard } from "@/components/dashboard/DraftsCard";
|
||||
import { Card, CARD_CLASS, CardTitle } from "@/components/ui/Card";
|
||||
import { InfoHinweis } from "@/components/ui/InfoHinweis";
|
||||
import { eventBadgeStyle, eventDotStyle } from "@/lib/colors";
|
||||
import { istEingeschraenkt, parseArten, parseZeitraum } from "@/lib/dashboard-filter";
|
||||
import {
|
||||
istEingeschraenkt,
|
||||
parseArten,
|
||||
parseZeitraum,
|
||||
} from "@/lib/dashboard-filter";
|
||||
import { loadDashboardData } from "@/lib/dashboard-data";
|
||||
import { KPI_ERKLAERUNGEN } from "@/lib/kpi-erklaerungen";
|
||||
import { addDaysIso, fmtName, todayIso } from "@/lib/format";
|
||||
import { divisionOf } from "@/lib/org";
|
||||
import { deriveStatusAsOf } from "@/lib/reports";
|
||||
@@ -29,7 +38,12 @@ const TONE: Record<string, { text: string; bar: string }> = {
|
||||
};
|
||||
|
||||
/** Eine Kennzahl auf der Übersicht. */
|
||||
type Kachel = { label: string; value: string | number; tone: keyof typeof TONE; href: string };
|
||||
type Kachel = {
|
||||
label: string;
|
||||
value: string | number;
|
||||
tone: keyof typeof TONE;
|
||||
href: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Wie viele Spalten die Überschrift einer Gruppe überspannt — nach der Zahl
|
||||
@@ -106,7 +120,9 @@ export default async function DashboardPage({
|
||||
upcomingReturns,
|
||||
upcomingNotes,
|
||||
history,
|
||||
} = await withUser(userId, (tx) => loadDashboardData(tx, { userId, today, yearStart, ytdBis, bisIso, arten }));
|
||||
} = await withUser(userId, (tx) =>
|
||||
loadDashboardData(tx, { userId, today, yearStart, ytdBis, bisIso, arten }),
|
||||
);
|
||||
// "Aktiv" means status Aktiv — somebody on Karenz is employed but not
|
||||
// active, and is counted by its own tile instead. FTE follows the same
|
||||
// set: Karenz contributes no capacity, so including it would overstate
|
||||
@@ -115,11 +131,15 @@ export default async function DashboardPage({
|
||||
// Note this is narrower than DEFAULT_STATUSES in lib/reports (Aktiv +
|
||||
// Karenz), which still governs what the Berichte page shows when no
|
||||
// status filter is chosen.
|
||||
const statusOf = (row: (typeof staffRows)[number]) => deriveStatusAsOf(row, today);
|
||||
const statusOf = (row: (typeof staffRows)[number]) =>
|
||||
deriveStatusAsOf(row, today);
|
||||
const activeStaff = staffRows.filter((row) => statusOf(row) === "Aktiv");
|
||||
const activeCount = activeStaff.length;
|
||||
const karenzCount = staffRows.filter((row) => statusOf(row) === "Karenz").length;
|
||||
const fte = activeStaff.reduce((sum, row) => sum + Number(row.weekly_hours), 0) / 38.5;
|
||||
const karenzCount = staffRows.filter(
|
||||
(row) => statusOf(row) === "Karenz",
|
||||
).length;
|
||||
const fte =
|
||||
activeStaff.reduce((sum, row) => sum + Number(row.weekly_hours), 0) / 38.5;
|
||||
|
||||
// Der Bereich einer Person steht nicht mehr auf ihr; er ergibt sich aus der
|
||||
// Einheit ihrer Planstelle und deren Vorfahren. Die Bereichsleitung selbst
|
||||
@@ -129,7 +149,10 @@ export default async function DashboardPage({
|
||||
for (const row of activeStaff) {
|
||||
const division = divisionOf(orgMaps, placements.get(row.id)?.orgUnitId);
|
||||
if (!division) continue;
|
||||
headcountByDivision.set(division.id, (headcountByDivision.get(division.id) ?? 0) + 1);
|
||||
headcountByDivision.set(
|
||||
division.id,
|
||||
(headcountByDivision.get(division.id) ?? 0) + 1,
|
||||
);
|
||||
}
|
||||
const divisionBars = orgMaps.unitList
|
||||
.filter((u) => u.unit_type === "Bereich")
|
||||
@@ -138,28 +161,28 @@ export default async function DashboardPage({
|
||||
const maxDivisionCount = Math.max(1, ...divisionBars.map((d) => d.count));
|
||||
|
||||
const upcomingAlle: AnstehendEintrag[] = [
|
||||
...(upcomingHires).map((e) => ({
|
||||
...upcomingHires.map((e) => ({
|
||||
id: e.id,
|
||||
employeeId: e.id,
|
||||
label: fmtName(e.first_name, e.last_name),
|
||||
date: e.entry_date,
|
||||
kind: "hire" as const,
|
||||
})),
|
||||
...(upcomingExits).map((e) => ({
|
||||
...upcomingExits.map((e) => ({
|
||||
id: e.id,
|
||||
employeeId: e.id,
|
||||
label: fmtName(e.first_name, e.last_name),
|
||||
date: e.exit_date!,
|
||||
kind: "exit" as const,
|
||||
})),
|
||||
...(upcomingReturns).map((e) => ({
|
||||
...upcomingReturns.map((e) => ({
|
||||
id: e.id,
|
||||
employeeId: e.id,
|
||||
label: fmtName(e.first_name, e.last_name),
|
||||
date: e.karenz_return_date!,
|
||||
kind: "return" as const,
|
||||
})),
|
||||
...(upcomingNotes).map((n) => ({
|
||||
...upcomingNotes.map((n) => ({
|
||||
id: n.id,
|
||||
employeeId: n.employee_id!,
|
||||
label: fmtName(n.first_name, n.last_name),
|
||||
@@ -212,8 +235,18 @@ export default async function DashboardPage({
|
||||
// Next daraus ein Array, und die Seite scheiterte an `.split(",")`.
|
||||
href: "/employees?status=Aktiv,Karenz",
|
||||
},
|
||||
{ label: "Headcount Aktiv", value: activeCount, tone: "default", href: "/employees?status=Aktiv" },
|
||||
{ label: "Langzeitabwesende", value: karenzCount, tone: "warning", href: "/employees?status=Karenz" },
|
||||
{
|
||||
label: "Headcount Aktiv",
|
||||
value: activeCount,
|
||||
tone: "default",
|
||||
href: "/employees?status=Aktiv",
|
||||
},
|
||||
{
|
||||
label: "Langzeitabwesende",
|
||||
value: karenzCount,
|
||||
tone: "warning",
|
||||
href: "/employees?status=Karenz",
|
||||
},
|
||||
// Ohne Zeitgrenze — anders als die Karte „Anstehend" darunter, die nur
|
||||
// den eingestellten Vorschauzeitraum zeigt. Ein Eintritt in vier
|
||||
// Monaten ist vereinbart und zählt, auch wenn er dort nicht auftaucht.
|
||||
@@ -223,7 +256,12 @@ export default async function DashboardPage({
|
||||
tone: "info",
|
||||
href: "/employees?status=Geplant",
|
||||
},
|
||||
{ label: "Aktive FTE", value: fte.toFixed(1), tone: "default", href: "/reports?mode=snapshot&measure=fte&status=Aktiv" },
|
||||
{
|
||||
label: "Aktive FTE",
|
||||
value: fte.toFixed(1),
|
||||
tone: "default",
|
||||
href: "/reports?mode=snapshot&measure=fte&status=Aktiv",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -248,7 +286,14 @@ export default async function DashboardPage({
|
||||
},
|
||||
{
|
||||
titel: "Recruiting & Vakanzen",
|
||||
kacheln: [{ label: "Offene Positionen", value: openPositions.length, tone: "brand", href: "/positions" }],
|
||||
kacheln: [
|
||||
{
|
||||
label: "Offene Positionen",
|
||||
value: openPositions.length,
|
||||
tone: "brand",
|
||||
href: "/positions",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -290,13 +335,20 @@ export default async function DashboardPage({
|
||||
{gruppe.titel}
|
||||
</h2>
|
||||
{gruppe.kacheln.map((kpi) => (
|
||||
<Link
|
||||
key={kpi.label}
|
||||
href={kpi.href}
|
||||
className={`${CARD_CLASS} group relative overflow-hidden p-4 pl-5 transition-shadow xl:[grid-row:2] hover:shadow-[var(--shadow-card-hover)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-500`}
|
||||
>
|
||||
<span className={`absolute inset-y-0 left-0 w-1 ${TONE[kpi.tone].bar}`} aria-hidden />
|
||||
{/* Number first in the visual order: it is what the eye is
|
||||
// Die Zelle trägt Kachel und (i) nebeneinander: das (i) liegt
|
||||
// über der Kachel, gehört aber nicht zum Link — sonst öffnete
|
||||
// ein Klick darauf die Liste, und der Tooltip würde vom
|
||||
// overflow-hidden der Kachel abgeschnitten.
|
||||
<div key={kpi.label} className="relative xl:[grid-row:2]">
|
||||
<Link
|
||||
href={kpi.href}
|
||||
className={`${CARD_CLASS} group relative flex h-full flex-col overflow-hidden p-4 pl-5 pr-7 transition-shadow hover:shadow-[var(--shadow-card-hover)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-500`}
|
||||
>
|
||||
<span
|
||||
className={`absolute inset-y-0 left-0 w-1 ${TONE[kpi.tone].bar}`}
|
||||
aria-hidden
|
||||
/>
|
||||
{/* Number first in the visual order: it is what the eye is
|
||||
looking for, and the label only qualifies it.
|
||||
|
||||
Kleiner, sobald alle acht in einer Reihe stehen: dort
|
||||
@@ -305,14 +357,27 @@ export default async function DashboardPage({
|
||||
ist. Die Kachel hat `overflow-hidden` — die Zahl wäre also
|
||||
nicht zu breit, sondern abgeschnitten, und eine
|
||||
abgeschnittene Kennzahl ist schlimmer als eine kleine. */}
|
||||
<div className={`text-3xl font-extrabold leading-none tabular-nums xl:text-2xl ${TONE[kpi.tone].text}`}>
|
||||
{kpi.value}
|
||||
</div>
|
||||
<div className="mt-1.5 flex items-center gap-1 text-xs font-semibold leading-tight text-ink-muted">
|
||||
{kpi.label}
|
||||
<ChevronRight className="h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover:opacity-100" aria-hidden />
|
||||
</div>
|
||||
</Link>
|
||||
<div
|
||||
className={`text-3xl font-extrabold leading-none tabular-nums xl:text-2xl ${TONE[kpi.tone].text}`}
|
||||
>
|
||||
{kpi.value}
|
||||
</div>
|
||||
<div className="mt-1.5 flex items-center gap-1 text-xs font-semibold leading-tight text-ink-muted">
|
||||
{kpi.label}
|
||||
<ChevronRight
|
||||
className="h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover:opacity-100"
|
||||
aria-hidden
|
||||
/>
|
||||
</div>
|
||||
</Link>
|
||||
{KPI_ERKLAERUNGEN[kpi.label] && (
|
||||
<InfoHinweis
|
||||
label={kpi.label}
|
||||
text={KPI_ERKLAERUNGEN[kpi.label]}
|
||||
className="absolute right-1.5 top-1.5"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</Fragment>
|
||||
))}
|
||||
@@ -328,19 +393,25 @@ export default async function DashboardPage({
|
||||
<div key={d.name}>
|
||||
<div className="mb-1 flex justify-between text-xs">
|
||||
<span className="text-ink-body">{d.name}</span>
|
||||
<span className="font-semibold tabular-nums text-ink">{d.count}</span>
|
||||
<span className="font-semibold tabular-nums text-ink">
|
||||
{d.count}
|
||||
</span>
|
||||
</div>
|
||||
{/* Rounded ends and a minimum width so the smallest division
|
||||
still reads as a bar rather than a stray pixel. */}
|
||||
<div className="h-1.5 overflow-hidden rounded-full bg-surface">
|
||||
<div
|
||||
className="h-full rounded-full bg-brand-500"
|
||||
style={{ width: `${Math.max(2, (d.count / maxDivisionCount) * 100)}%` }}
|
||||
style={{
|
||||
width: `${Math.max(2, (d.count / maxDivisionCount) * 100)}%`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{divisionBars.length === 0 && <p className="text-sm text-ink-muted">Keine Daten vorhanden.</p>}
|
||||
{divisionBars.length === 0 && (
|
||||
<p className="text-sm text-ink-muted">Keine Daten vorhanden.</p>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -365,11 +436,14 @@ export default async function DashboardPage({
|
||||
<Card>
|
||||
<CardTitle className="mb-1">Letzte Aktivitäten</CardTitle>
|
||||
<ul className="flex flex-col divide-y divide-border-subtle">
|
||||
{(history).map((h) => (
|
||||
{history.map((h) => (
|
||||
<li key={h.id} className="flex gap-2.5 py-2.5">
|
||||
{/* Dot aligned to the first line of text, not centred on the
|
||||
whole row, so it stays put as descriptions wrap. */}
|
||||
<span className={`mt-1.5 h-2 w-2 shrink-0 rounded-full ${eventDotStyle(h.event_type)}`} aria-hidden />
|
||||
<span
|
||||
className={`mt-1.5 h-2 w-2 shrink-0 rounded-full ${eventDotStyle(h.event_type)}`}
|
||||
aria-hidden
|
||||
/>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
|
||||
{/* Der Name führt in die Akte. Ohne den Link war die Karte
|
||||
@@ -384,17 +458,27 @@ export default async function DashboardPage({
|
||||
{fmtName(h.first_name, h.last_name)}
|
||||
</Link>
|
||||
) : (
|
||||
<span className="text-sm font-semibold text-ink">Unbekannt</span>
|
||||
<span className="text-sm font-semibold text-ink">
|
||||
Unbekannt
|
||||
</span>
|
||||
)}
|
||||
<span className={`rounded-full px-2 py-0.5 text-[11px] font-semibold ${eventBadgeStyle(h.event_type)}`}>
|
||||
<span
|
||||
className={`rounded-full px-2 py-0.5 text-[11px] font-semibold ${eventBadgeStyle(h.event_type)}`}
|
||||
>
|
||||
{h.event_type}
|
||||
</span>
|
||||
</div>
|
||||
<p className="mt-0.5 text-xs leading-relaxed text-ink-muted">{h.description}</p>
|
||||
<p className="mt-0.5 text-xs leading-relaxed text-ink-muted">
|
||||
{h.description}
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
{(history).length === 0 && <p className="py-2 text-sm text-ink-muted">Keine Aktivitäten vorhanden.</p>}
|
||||
{history.length === 0 && (
|
||||
<p className="py-2 text-sm text-ink-muted">
|
||||
Keine Aktivitäten vorhanden.
|
||||
</p>
|
||||
)}
|
||||
</ul>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user