forked from ddrilling/asb_cloud_front
23 lines
595 B
TypeScript
23 lines
595 B
TypeScript
|
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
|