"use client"; import Link from "next/link"; import { useTranslations } from "next-intl"; import { useEffect, useState } from "react"; import { LifeBuoyIcon, ArrowUpRightIcon } from "lucide-react"; import { CommandItem } from "../../../shadcnui"; import { usePageUrlGenerator } from "../../../client"; import { HowToService } from "../../how-to/data/HowToService"; import type { HowToInterface } from "../../how-to/data/HowToInterface"; export interface HelpSearchResultRowProps { result: { id: string; name: string; entityType: string }; onSelect?: () => void; } export function HelpSearchResultRow({ result, onSelect }: HelpSearchResultRowProps) { const t = useTranslations(); const generateUrl = usePageUrlGenerator(); const [article, setArticle] = useState(null); useEffect(() => { let active = true; HowToService.findOne({ id: result.id }) .then((a) => active && setArticle(a)) .catch(() => active && setArticle(null)); return () => { active = false; }; }, [result.id]); if (!article) { return ( {t("help.search.removed")} ); } return (
{article.name} {t(`help.modes.${article.howToType}`)} ยท {article.summary}
); }