forked from ddrilling/asb_cloud_front
Добавлен компонент ссылки на файл
This commit is contained in:
parent
a95df07ac1
commit
081df563b2
22
src/components/DownloadLink.tsx
Normal file
22
src/components/DownloadLink.tsx
Normal file
@ -0,0 +1,22 @@
|
||||
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
|
Loading…
Reference in New Issue
Block a user