@groceristar/pdf-export
Version:
module to use pdf-export feature between projects
52 lines (40 loc) • 1.39 kB
JavaScript
import React, { Component } from 'react'
import {
PDFDownloadLink
} from '@react-pdf/renderer'
import { Button } from 'antd'
import { DocumentLayouts } from './../DocumentLayouts'
// @TODO rename this component name.
// because it's quite similar to component from @react-pdf - see above
// Maybe WrapperPDFDownloadLink is a long, but self exlpanatory name?
// @TODO create a method that will generate a name - in order to keep it better - maybe????
// @TODO right now color of text Download now is blue on blue background
// we also didn't see a text - loading now.....
// @TODO should be have so long component name here?
// @TODO this structure works like shit. it's not a good animations there.
// i think we can use ant-d animations
// {({ blob, url, loading, error }) => (
// loading ? 'Loading document...' : 'Download now!'
// )}
class DownloadPDFLink extends Component {
render () {
const { type, name, data } = this.props
return (
<Button
type='primary'
icon='download'
size='large'
>
<PDFDownloadLink
document={DocumentLayouts(type, name, data)}
fileName={name + '.pdf'}
>
{({ blob, url, loading, error }) => (
loading ? 'Loading document...' : 'Download now!'
)}
</PDFDownloadLink>
</Button>
)
}
}
export default DownloadPDFLink