"use client"; import { useTranslations } from "next-intl"; import Link from "next/link"; import type { ApiDataInterface } from "../../../../../core"; import { ModuleRegistry } from "../../../../../core/registry/ModuleRegistry"; import { usePageUrlGenerator } from "../../../../../hooks"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../../../../../shadcnui/ui/table"; import { useEntityLabel } from "./useEntityLabel"; interface Props { references: ApiDataInterface[]; } export function ReferencesTab({ references }: Props) { const t = useTranslations(); const generate = usePageUrlGenerator(); const entityLabel = useEntityLabel(); if (references.length === 0) return null; return ( {t("features.assistant.message.sources.source")} {t("features.assistant.message.sources.type")} {references.map((ref) => { let module; try { module = ModuleRegistry.findByName(ref.type); } catch { return null; } const howToType = (ref as any).howToType as string | undefined; const slug = (ref as any).slug as string | undefined; const href = howToType && slug ? `/help/${howToType}/${slug}` : generate({ page: module, id: ref.id }); return ( {ref.identifier} {entityLabel(module.name)} ); })}
); }