import { Link } from "@inertiajs/react"; import { useEffect, useState } from "react"; export default function PartnershipSourceLinks({ type, id, }: { type: string; id: string | number; }) { const [data, setData] = useState<{ available: boolean; items: { id: number; title: string }[]; } | null>(null); useEffect(() => { const controller = new AbortController(); fetch( `/api/v1/partnerships/source/${encodeURIComponent(type)}/${encodeURIComponent(String(id))}`, { signal: controller.signal, headers: { Accept: "application/json" }, }, ) .then((r) => (r.ok ? r.json() : null)) .then(setData) .catch(() => {}); return () => controller.abort(); }, [type, id]); if (!data?.available) return null; return (

Parcerias ligadas a este registo

{data.items.map((item) => (

{item.title}

))} {!data.items.length && (

Ainda não há parcerias publicadas com esta origem.

)} Propor parceria a partir deste registo
); }