Let the employee list be sorted A-Z or Z-A
Some checks failed
CI / Lint, Typen, Tests, Build (push) Failing after 6m12s
CI / Integrationstests (echtes Postgres) (push) Failing after 5m29s

Sorting lives in the URL, not the browser. The list is built on the
server and fetched a page at a time, so a client-side sort would only
reorder the fifteen rows on screen — with 867 people that promises an
alphabetical list and delivers something else on page 2.

The sort key is the surname, because that is how the column reads:
"Aigner, Manuel", and whoever looks for someone looks under A. Postgres
runs with the Austrian collation, so Ö sorts with O rather than at the
end of the alphabet.

Only the surname reverses. The id stays ascending: it decides nothing
except ties, and it exists to keep the order total across page
boundaries. Reversing it too would still be deterministic but would flip
the fourteen Winklers relative to each other for no reason anyone asked
for.

The select sits in the filter bar rather than in a clickable column
header — a header would suggest it sorts what is on screen.

Verified: compiled SQL is `order by last_name desc, id` for Z-A; the
parse and direction rules are covered by tests that were mutation-checked
(breaking each rule turns them red). Not verified in the browser — the
login goes through the company account, and the Supabase instance no
longer resolves.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-07 10:02:15 +02:00
parent af947f094d
commit 5c310c3a58
4 changed files with 112 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import { FILTER_SELECT_CLASS } from "@/components/ui/Field";
import { SearchInput } from "@/components/ui/SearchInput";
import { SORTIERUNGEN, STANDARD_SORTIERUNG } from "@/lib/employee-sort";
type EmployeeFiltersProps = {
/** Der ganze Baum, in Tiefensuche-Reihenfolge. */
@@ -104,6 +105,23 @@ export function EmployeeFilters({ units, depthOf, locations }: EmployeeFiltersPr
</option>
))}
</select>
{/* Die Sortierung steht bewusst neben den Filtern und nicht in der
Tabellenüberschrift: sortiert wird über den ganzen Bestand, nicht
über die fünfzehn Zeilen dieser Seite. Ein anklickbarer Spaltenkopf
verspräche das Gegenteil. Anders als die Filter hat sie keinen
leeren Eintrag — irgendeine Reihenfolge hat die Liste immer. */}
<select
aria-label="Liste sortieren"
defaultValue={searchParams.get("sort") ?? STANDARD_SORTIERUNG}
onChange={(e) => updateParam("sort", e.target.value)}
className={FILTER_SELECT_CLASS}
>
{SORTIERUNGEN.map((s) => (
<option key={s.value} value={s.value}>
{s.label}
</option>
))}
</select>
{/* Der Dienstwagen stand hier einmal als eigenes Auswahlfeld. Er ist
jetzt eines von rund zwanzig Kriterien unter Berichte, zusammen mit
Vertragsart, Kollektivvertrag, Eintrittszeitraum und dem Rest —