import { ApiRouteName } from '#shared/types/index'; import { Link } from '@inertiajs/react'; import { useTuyau } from '@tuyau/inertia/react'; import { CSSProperties } from 'react'; interface InternalLinkProps { children: React.ReactNode; onClick?: (event: React.MouseEvent) => void; route?: ApiRouteName; href?: string; forceRefresh?: boolean; style?: CSSProperties; className?: string; params?: Record; } export const InternalLinkUnstyled = ({ children, onClick, route, href, forceRefresh, style, className, params, }: InternalLinkProps) => { const tuyau = useTuyau(); if ((!route && !href) || !tuyau) { throw new Error('InternalLink: route, href or tuyau is missing'); } const url = route ? tuyau.$route(route, params).path : href; if (!url) { throw new Error('InternalLink: url not found'); } if (forceRefresh) { return ( {children} ); } return ( {children} ); };