fix: show ITTO rows by process

This commit is contained in:
ittoview
2026-05-18 17:54:09 +01:00
parent 48dd37554e
commit 93b9a031b4

View File

@@ -4,7 +4,6 @@ import { FileOutput, FileText, Wrench } from 'lucide-react'
import { import {
artifactMap, artifactMap,
knowledgeAreas, knowledgeAreas,
processGroups,
processes, processes,
toolMap, toolMap,
normalizeProcessRef, normalizeProcessRef,
@@ -14,9 +13,10 @@ import type { Process, ProcessRef } from '@/types/itto'
type ViewKey = 'inputs' | 'tools' | 'outputs' type ViewKey = 'inputs' | 'tools' | 'outputs'
type CollectionRow = { type CollectionRow = {
processGroupId: string processId: string
processGroupName: string processCode: string
color: string processName: string
processNameEn: string
items: string[] items: string[]
} }
@@ -67,22 +67,16 @@ function uniqueItems(items: string[]) {
function buildCollection(viewKey: ViewKey): CollectionArea[] { function buildCollection(viewKey: ViewKey): CollectionArea[] {
return knowledgeAreas.map((area) => { return knowledgeAreas.map((area) => {
const areaProcesses = processes.filter((process) => process.knowledgeAreaId === area.id) const rows = processes
const rows = processGroups.map((group) => { .filter((process) => process.knowledgeAreaId === area.id)
const groupProcesses = areaProcesses.filter((process) => process.processGroupId === group.id) .sort((a, b) => a.order - b.order)
const items = uniqueItems( .map((process) => ({
groupProcesses.flatMap((process) => processId: process.id,
getRefsByView(process, viewKey).map((ref) => formatRef(ref, viewKey)) processCode: process.code,
) processName: process.name,
) processNameEn: process.nameEn,
items: uniqueItems(getRefsByView(process, viewKey).map((ref) => formatRef(ref, viewKey))),
return { }))
processGroupId: group.id,
processGroupName: group.name,
color: group.color,
items,
}
}).filter((row) => row.items.length > 0)
return { return {
id: area.id, id: area.id,
@@ -98,13 +92,14 @@ function buildCollection(viewKey: ViewKey): CollectionArea[] {
export function IttoCollectionsPage() { export function IttoCollectionsPage() {
const [activeTab, setActiveTab] = useState<ViewKey>('inputs') const [activeTab, setActiveTab] = useState<ViewKey>('inputs')
const collection = useMemo(() => buildCollection(activeTab), [activeTab]) const collection = useMemo(() => buildCollection(activeTab), [activeTab])
const activeLabel = tabs.find((tab) => tab.key === activeTab)?.label
return ( return (
<div className="space-y-4"> <div className="space-y-4">
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"> <div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
<div> <div>
<h1 className="text-xl font-bold text-gray-900 dark:text-white"> · · </h1> <h1 className="text-xl font-bold text-gray-900 dark:text-white"> · · </h1>
<p className="text-sm text-gray-500 dark:text-gray-400"></p> <p className="text-sm text-gray-500 dark:text-gray-400"></p>
</div> </div>
<div className="inline-flex rounded-xl bg-white p-1 shadow-sm ring-1 ring-gray-100 dark:bg-gray-800 dark:ring-gray-700"> <div className="inline-flex rounded-xl bg-white p-1 shadow-sm ring-1 ring-gray-100 dark:bg-gray-800 dark:ring-gray-700">
{tabs.map((tab) => { {tabs.map((tab) => {
@@ -162,24 +157,30 @@ export function IttoCollectionsPage() {
<table className="min-w-full divide-y divide-gray-100 dark:divide-gray-700"> <table className="min-w-full divide-y divide-gray-100 dark:divide-gray-700">
<thead className="bg-gray-50 dark:bg-gray-900/40"> <thead className="bg-gray-50 dark:bg-gray-900/40">
<tr> <tr>
<th className="w-36 px-4 py-3 text-left text-xs font-semibold text-gray-500 dark:text-gray-400"> <th className="w-52 px-4 py-3 text-left text-xs font-semibold text-gray-500 dark:text-gray-400">
</th> </th>
<th className="px-4 py-3 text-left text-xs font-semibold text-gray-500 dark:text-gray-400"> <th className="px-4 py-3 text-left text-xs font-semibold text-gray-500 dark:text-gray-400">
{tabs.find((tab) => tab.key === activeTab)?.label} {activeLabel}
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody className="divide-y divide-gray-100 dark:divide-gray-700"> <tbody className="divide-y divide-gray-100 dark:divide-gray-700">
{area.rows.map((row) => ( {area.rows.map((row) => (
<tr key={row.processGroupId} className="align-top"> <tr key={row.processId} className="align-top">
<td className="px-4 py-3"> <td className="px-4 py-3">
<span <div className="flex items-start gap-2">
className="inline-flex rounded-full px-2.5 py-1 text-xs font-medium text-white" <span
style={{ backgroundColor: row.color }} className="mt-0.5 inline-flex shrink-0 rounded-md px-2 py-0.5 text-xs font-semibold text-white"
> style={{ backgroundColor: area.color }}
{row.processGroupName} >
</span> {row.processCode}
</span>
<div className="min-w-0">
<div className="text-sm font-medium text-gray-900 dark:text-white">{row.processName}</div>
<div className="text-xs text-gray-500 dark:text-gray-400">{row.processNameEn}</div>
</div>
</div>
</td> </td>
<td className="px-4 py-3 text-sm leading-6 text-gray-700 dark:text-gray-300"> <td className="px-4 py-3 text-sm leading-6 text-gray-700 dark:text-gray-300">
{row.items.join('')} {row.items.join('')}