import { Link } from '@mui/material'; import { useNotify } from 'react-admin'; import { downloadEquipmentAttachmentFile } from './attachmentDownload'; type Props = { equipmentId: string; /** Текст ссылки и имя при сохранении в браузере */ fileName: string; }; export function EquipmentAttachmentLink({ equipmentId, fileName }: Props) { const notify = useNotify(); const label = fileName.trim() || 'Скачать'; return ( { e.preventDefault(); e.stopPropagation(); void downloadEquipmentAttachmentFile(equipmentId, label).catch(() => notify('Не удалось скачать файл', { type: 'warning' }), ); }} sx={{ cursor: 'pointer', textAlign: 'left', verticalAlign: 'inherit' }} > {label} ); }