Skip to content

Commit

Permalink
fix: Fix print button (still downloads, does not print)
Browse files Browse the repository at this point in the history
PrintButton was using `this.url` instead of `this.props.url`.
However also removed some unnecessary code in this component
  • Loading branch information
gmaclennan authored and okdistribute committed Sep 14, 2020
1 parent 11aad53 commit 05b276b
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions src/renderer/components/MapFilter/ReportView/PrintButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,18 @@ type Props = {
url: string
}

class PrintButton extends React.Component<Props, State> {

download () {
var anchor = document.createElement('a')
anchor.href = this.url
anchor.download = 'report.pdf'
anchor.click()
}

render () {
const { disabled } = this.props

return (
<React.Fragment>
<ToolbarButton onClick={this.download.bind(this)} disabled={disabled}>
<PrintIcon />
<FormattedMessage {...messages.print} />
</ToolbarButton>
</React.Fragment>
)
}
}
const PrintButton = ({ url, disabled }: Props) => (
<React.Fragment>
<ToolbarButton
component='a'
href={url}
download='report.pdf'
disabled={disabled}
>
<PrintIcon />
<FormattedMessage {...messages.print} />
</ToolbarButton>
</React.Fragment>
)

export default PrintButton

0 comments on commit 05b276b

Please sign in to comment.