Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -0,0 +1,58 @@
import { describe, expect, it } from "vitest";
import { buildLeadDisplayName, buildLeadListVM, leadFreigabeLabelKey, leadQuelleLabelKey, leadStatusLabelKey } from "./lead-list.vm.js";
describe("lead list view-model", () => {
it("derives i18n keys and display names", () => {
expect(leadQuelleLabelKey("form")).toBe("leads.quelle.form");
expect(leadStatusLabelKey("qualified")).toBe("leads.status.qualified");
expect(leadFreigabeLabelKey("ja")).toBe("leads.freigabe.ja");
expect(buildLeadDisplayName({ vorname: "Anna", nachname: "Muster", email: null, telefon: null, quelle: "manual" })).toBe("Anna Muster");
expect(buildLeadDisplayName({ vorname: null, nachname: null, email: "a@example.test", telefon: null, quelle: "form" })).toBe("a@example.test");
});
it("maps rows, markers, permissions and cursor state", () => {
const vm = buildLeadListVM({
tenantSlug: "acme",
createHref: "/acme/leads/new",
statisticsHref: "/acme/leads/statistics",
userLabels: new Map([["u1", "Raffael"]]),
duplicateLeadIds: new Set(["l1"]),
total: 2,
nextCursor: "l2",
perms: { canWrite: true, canDelete: false, canReadAll: true },
rows: [
{
id: "l1",
quelle: "form",
status: "new",
weiterverarbeitungFreigabe: "unklar",
vorname: "Anna",
nachname: "Muster",
email: "anna@example.test",
telefon: null,
message: "Bitte melden.",
zustaendigerUserId: "u1",
spamScore: 55,
spamReason: "fast_submit",
isQuarantined: true,
konvertiertProjektId: null,
verknuepfterKontaktId: null,
createdAt: new Date("2026-07-01T08:00:00.000Z"),
},
],
});
expect(vm.status).toBe("ready");
if (vm.status !== "ready") throw new Error("expected ready");
expect(vm.data.rows[0]).toMatchObject({
displayName: "Anna Muster",
quelleLabelKey: "leads.quelle.form",
statusLabelKey: "leads.status.new",
zustaendigerLabel: "Raffael",
markers: ["duplicate", "spam"],
detailHref: "/acme/leads/l1",
createdAtIso: "2026-07-01T08:00:00.000Z",
});
expect(vm.data.nextCursor).toBe("l2");
expect(vm.data.canReadAll).toBe(true);
});
});
@@ -0,0 +1,130 @@
import type { VMState } from "../index.js";
export type LeadQuelle = "form" | "email" | "aircall" | "manual" | "custom";
export type LeadStatus = "new" | "qualified" | "converted" | "lost" | "spam";
export type LeadWeiterverarbeitungFreigabe = "ja" | "nein" | "unklar";
export interface LeadListRowSource {
readonly id: string;
readonly quelle: LeadQuelle;
readonly status: LeadStatus;
readonly weiterverarbeitungFreigabe: LeadWeiterverarbeitungFreigabe;
readonly vorname: string | null;
readonly nachname: string | null;
readonly email: string | null;
readonly telefon: string | null;
readonly message: string | null;
readonly zustaendigerUserId: string | null;
readonly spamScore: number;
readonly spamReason: string | null;
readonly isQuarantined: boolean;
readonly konvertiertProjektId: string | null;
readonly verknuepfterKontaktId: string | null;
readonly createdAt: Date;
}
export interface LeadListRow {
readonly id: string;
readonly displayName: string;
readonly preview: string | null;
readonly quelle: LeadQuelle;
readonly quelleLabelKey: string;
readonly status: LeadStatus;
readonly statusLabelKey: string;
readonly weiterverarbeitungFreigabe: LeadWeiterverarbeitungFreigabe;
readonly freigabeLabelKey: string;
readonly email: string | null;
readonly telefon: string | null;
readonly zustaendigerLabel: string | null;
readonly spamScore: number;
readonly markers: readonly ("duplicate" | "spam" | "converted")[];
readonly detailHref: string;
readonly createdAtIso: string;
}
export interface LeadListData {
readonly rows: readonly LeadListRow[];
readonly total: number;
readonly nextCursor: string | null;
readonly canWrite: boolean;
readonly canDelete: boolean;
readonly canReadAll: boolean;
readonly createHref: string;
readonly statisticsHref: string;
readonly emptyHeadlineKey: string;
readonly emptyBodyKey: string;
}
export type LeadListVM = VMState<LeadListData>;
export interface BuildLeadListVMInput {
readonly rows: readonly LeadListRowSource[];
readonly userLabels: ReadonlyMap<string, string>;
readonly duplicateLeadIds?: ReadonlySet<string>;
readonly total: number;
readonly nextCursor: string | null;
readonly perms: { readonly canWrite: boolean; readonly canDelete: boolean; readonly canReadAll: boolean };
readonly tenantSlug: string;
readonly createHref: string;
readonly statisticsHref: string;
}
export function leadQuelleLabelKey(quelle: LeadQuelle): string {
return `leads.quelle.${quelle}`;
}
export function leadStatusLabelKey(status: LeadStatus): string {
return `leads.status.${status}`;
}
export function leadFreigabeLabelKey(value: LeadWeiterverarbeitungFreigabe): string {
return `leads.freigabe.${value}`;
}
export function buildLeadDisplayName(row: Pick<LeadListRowSource, "vorname" | "nachname" | "email" | "telefon" | "quelle">): string {
const name = `${row.vorname ?? ""} ${row.nachname ?? ""}`.trim();
return name || row.email || row.telefon || row.quelle;
}
export function buildLeadListVM(input: BuildLeadListVMInput): LeadListVM {
const rows = input.rows.map((row) => {
const markers: ("duplicate" | "spam" | "converted")[] = [];
if (input.duplicateLeadIds?.has(row.id)) markers.push("duplicate");
if (row.isQuarantined || row.status === "spam" || row.spamScore >= 50) markers.push("spam");
if (row.konvertiertProjektId || row.status === "converted") markers.push("converted");
return {
id: row.id,
displayName: buildLeadDisplayName(row),
preview: row.message ? row.message.slice(0, 80) : null,
quelle: row.quelle,
quelleLabelKey: leadQuelleLabelKey(row.quelle),
status: row.status,
statusLabelKey: leadStatusLabelKey(row.status),
weiterverarbeitungFreigabe: row.weiterverarbeitungFreigabe,
freigabeLabelKey: leadFreigabeLabelKey(row.weiterverarbeitungFreigabe),
email: row.email,
telefon: row.telefon,
zustaendigerLabel: row.zustaendigerUserId ? (input.userLabels.get(row.zustaendigerUserId) ?? null) : null,
spamScore: row.spamScore,
markers,
detailHref: `/${input.tenantSlug}/leads/${row.id}`,
createdAtIso: row.createdAt.toISOString(),
} satisfies LeadListRow;
});
return {
status: "ready",
data: {
rows,
total: input.total,
nextCursor: input.nextCursor,
canWrite: input.perms.canWrite,
canDelete: input.perms.canDelete,
canReadAll: input.perms.canReadAll,
createHref: input.createHref,
statisticsHref: input.statisticsHref,
emptyHeadlineKey: "leads.list.empty.headline",
emptyBodyKey: "leads.list.empty.body",
},
};
}