import { LinkIcon, MilestoneIcon } from "lucide-react"; import { memo, useState } from "react"; import { Link } from "react-router-dom"; import { cn } from "@/lib/utils"; import { extractMemoIdFromName } from "@/store/common"; import { Memo, MemoRelation } from "@/types/proto/api/v1/memo_service"; import { useTranslate } from "@/utils/i18n"; interface Props { memo: Memo; relations: MemoRelation[]; parentPage?: string; } const MemoRelationListView = (props: Props) => { const t = useTranslate(); const { memo, relations: relationList, parentPage } = props; const referencingMemoList = relationList .filter((relation) => relation.memo?.name === memo.name && relation.relatedMemo?.name !== memo.name) .map((relation) => relation.relatedMemo!); const referencedMemoList = relationList .filter((relation) => relation.memo?.name !== memo.name && relation.relatedMemo?.name === memo.name) .map((relation) => relation.memo!); const [selectedTab, setSelectedTab] = useState<"referencing" | "referenced">( referencingMemoList.length === 0 ? "referenced" : "referencing", ); if (referencingMemoList.length + referencedMemoList.length === 0) { return null; } return (