createdBy était déjà présent dans le frontmatter des tickets mais ni exposé ni exploitable côté UI. Ajout du DTO (domain/ports/mock), affichage dans TicketDetail, colonne/filtre créateur dans TicketsPanel, et persistance du filtre. ticketActor.ts introduit pour porter la logique de filtrage côté frontend, sans changement backend nécessaire (lot frontend pur). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import type { TicketActor } from "@/domain";
|
|
|
|
export type TicketCreatorFilterValue = "" | "user" | `agent:${string}`;
|
|
|
|
export function ticketActorLabel(
|
|
actor: TicketActor,
|
|
nameOf: (agentId: string) => string,
|
|
): string {
|
|
switch (actor.kind) {
|
|
case "agent":
|
|
return `Agent : ${nameOf(actor.agentId)}`;
|
|
case "system":
|
|
return "Système";
|
|
case "user":
|
|
default:
|
|
return "Utilisateur";
|
|
}
|
|
}
|
|
|
|
export function creatorFilterValue(
|
|
actor: { kind: "user" } | { kind: "agent"; agentId: string } | undefined,
|
|
): TicketCreatorFilterValue {
|
|
if (!actor) return "";
|
|
if (actor.kind === "user") return "user";
|
|
return `agent:${actor.agentId}`;
|
|
}
|
|
|
|
export function creatorFilterFromValue(
|
|
value: string,
|
|
): { kind: "user" } | { kind: "agent"; agentId: string } | undefined {
|
|
if (value === "user") return { kind: "user" };
|
|
if (value.startsWith("agent:")) {
|
|
const agentId = value.slice("agent:".length);
|
|
return agentId ? { kind: "agent", agentId } : undefined;
|
|
}
|
|
return undefined;
|
|
}
|