feat(tickets): affiche le créateur d'un ticket et filtre la liste par créateur
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>
This commit is contained in:
37
frontend/src/features/tickets/ticketActor.ts
Normal file
37
frontend/src/features/tickets/ticketActor.ts
Normal file
@ -0,0 +1,37 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user