From f8dd1e45248dd91f92ccdf35f1c94bfb0533c5d7 Mon Sep 17 00:00:00 2001 From: yuqei Date: Mon, 1 Jun 2026 18:24:48 +0800 Subject: [PATCH] fix: resolve TypeScript errors in redesigned pages - knowledge-bases: add missing fields to KnowledgeBaseFormValues type - knowledge-bases: fix null safety for tags array - knowledge-bases/legal-articles: fix renderStatusTag param types - legal-articles: add non-null assertion for source_id Co-Authored-By: Claude Opus 4.7 --- frontend/src/app/knowledge-bases/page.tsx | 15 +++++++++++---- frontend/src/app/legal-articles/page.tsx | 7 ++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/knowledge-bases/page.tsx b/frontend/src/app/knowledge-bases/page.tsx index 2e88e992..9b346f48 100644 --- a/frontend/src/app/knowledge-bases/page.tsx +++ b/frontend/src/app/knowledge-bases/page.tsx @@ -58,6 +58,12 @@ const { Title, Text, Paragraph } = Typography; type KnowledgeBaseFormValues = { name: string; description?: string; + note?: string; + source_type?: string; + authority?: string; + effective_date?: string; + region?: string; + tags?: string; }; type KnowledgeBaseRollbackFormValues = { @@ -843,9 +849,9 @@ export default function KnowledgeBasesPage() { ) : document.failure_reason ? ( {document.failure_reason} ) : null} - {document.tags?.length > 0 && ( + {(document.tags?.length ?? 0) > 0 && ( - {document.tags.slice(0, 5).map((tag) => {tag})} + {(document.tags ?? []).slice(0, 5).map((tag) => {tag})} )} @@ -1035,7 +1041,8 @@ export default function KnowledgeBasesPage() { } // Helper function for rendering status tags inline -function renderStatusTag(value: string, metaMap: Record) { - const meta = metaMap[value] ?? { color: "default", label: value || "未知" }; +function renderStatusTag(value: string | null | undefined, metaMap: Record) { + if (!value) return 未知; + const meta = metaMap[value] ?? { color: "default", label: value }; return {meta.label}; } diff --git a/frontend/src/app/legal-articles/page.tsx b/frontend/src/app/legal-articles/page.tsx index 11564957..d636efd0 100644 --- a/frontend/src/app/legal-articles/page.tsx +++ b/frontend/src/app/legal-articles/page.tsx @@ -92,8 +92,9 @@ function formatHash(value: string | null | undefined) { return value ? `${value.slice(0, 12)}...` : "-"; } -function renderStatusTag(value: string, metaMap: Record) { - const meta = metaMap[value] ?? { color: "default", label: value || "未知" }; +function renderStatusTag(value: string | null | undefined, metaMap: Record) { + if (!value) return 未知; + const meta = metaMap[value] ?? { color: "default", label: value }; return {meta.label}; } @@ -407,7 +408,7 @@ export default function LegalArticlesPage() { description={item.content ? {item.content} : null} /> {item.source_id && ( - )}