asb_cloud_front/src/components/DownloadLink.tsx

23 lines
595 B
TypeScript
Raw Normal View History

import { memo } from 'react'
import { Button, ButtonProps } from 'antd'
import { FileWordOutlined } from '@ant-design/icons'
import { FileInfoDto } from '@api'
import { downloadFile } from './factory'
export type DownloadLinkProps = ButtonProps & {
file?: FileInfoDto
name?: string
}
export const DownloadLink = memo<DownloadLinkProps>(({ file, name, ...other }) => (
<Button
type={'link'}
icon={<FileWordOutlined />}
onClick={file && (() => downloadFile(file))}
{...other}
>{name ?? file?.name ?? '-'}</Button>
))
export default DownloadLink