feat: Show project pills on initiative cards in list view

Add projects to the listInitiatives tRPC response and render them as
outline badge pills between the initiative name and activity row.
This commit is contained in:
Lukas May
2026-03-06 13:06:33 +01:00
parent 243f24a397
commit b6218584ee
2 changed files with 29 additions and 1 deletions

View File

@@ -140,16 +140,31 @@ export function initiativeProcedures(publicProcedure: ProcedureBuilder) {
)
.map(a => ({ initiativeId: a.initiativeId ?? '', mode: a.mode ?? '', status: a.status }));
// Batch-fetch projects for all initiatives
const projectRepo = ctx.projectRepository;
const projectsByInitiativeId = new Map<string, Array<{ id: string; name: string }>>();
if (projectRepo) {
await Promise.all(initiatives.map(async (init) => {
const projects = await projectRepo.findProjectsByInitiativeId(init.id);
projectsByInitiativeId.set(init.id, projects.map(p => ({ id: p.id, name: p.name })));
}));
}
const addProjects = (init: typeof initiatives[0]) => ({
projects: projectsByInitiativeId.get(init.id) ?? [],
});
if (ctx.phaseRepository) {
const phaseRepo = ctx.phaseRepository;
return Promise.all(initiatives.map(async (init) => {
const phases = await phaseRepo.findByInitiativeId(init.id);
return { ...init, activity: deriveInitiativeActivity(init, phases, activeArchitectAgents) };
return { ...init, ...addProjects(init), activity: deriveInitiativeActivity(init, phases, activeArchitectAgents) };
}));
}
return initiatives.map(init => ({
...init,
...addProjects(init),
activity: deriveInitiativeActivity(init, [], activeArchitectAgents),
}));
}),