Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 68x 164x 68x 42x 64x 42x 68x | // depcruiser:ignore l3-not-lower — Custom view: repository FK resolution (wireframes/pipeline-detail.md)
import { useEntityList } from '@/layers/L1/entityResolver'
import { useMemo } from 'react'
eIxport interface RepositoryOption {
value: string
label: string
}
function resolveRepoLabel(
repos: Array<Record<string, unknown>>,
id: unknown,
): string {
if (!id) return '\u2014'
const found = repos.find((r) => r.id === id)
return found ? String(found.name ?? id) : String(id)
}
export function useRepositoryOptions() {
const list = useEntityList('repositories', {})
const options = useMemo<RepositoryOption[]>(
() =>
((list.data ?? []) as Array<Record<string, unknown>>).map((r) => ({
value: String(r.id ?? ''),
label: String(r.name ?? r.id ?? ''),
})),
[list.data],
)
return {
options,
isLoading: list.isLoading,
error: list.error,
byIdFallback: (id: unknown) =>
resolveRepoLabel((list.data ?? []) as Array<Record<string, unknown>>, id),
}
}
|