import { ExternalLink, LayoutDashboard, ArrowUpRight } from 'lucide-react'; import { useMemo, useState } from 'react'; import { Button } from '@/components/ui/button'; import { ChevronDown, ChevronUp } from 'lucide-react'; import { useNavigate } from '@tanstack/react-router'; interface InfoItem { title: string; value: string; description: string; } interface DashCardProps { isCNB: boolean; liveData: { list?: InfoItem[] } | null; } const DEFAULT_SHOW_COUNT = 12; function isUrl(value: string): boolean { try { const url = new URL(value); return url.protocol === 'http:' || url.protocol === 'https:'; } catch { return false; } } export function DashCard({ isCNB, liveData }: DashCardProps) { const [expanded, setExpanded] = useState(false); if (!isCNB || !liveData?.list?.length) return null; const data = useMemo(() => { if (!liveData?.list) return { docs: null, list: [] }; const docs = liveData.list.find((item) => item.title === 'docs'); const list = liveData.list.filter((item) => item.title !== 'docs'); return { docs, list } }, [liveData]); const showList = expanded ? data.list : data.list.slice(0, DEFAULT_SHOW_COUNT); const hasMore = data.list.length > DEFAULT_SHOW_COUNT; return (