import React, { Component } from 'react'
import { Link } from 'react-router-dom'
import { connect } from 'react-redux'
import actions from '../../../actions'
import { formatDate, formatTime, formatAge, uploadUri } from '../../../util'
import { history } from '../../../store'
import { Loader, MenuButton } from '../../../common'
class UploadShow extends Component {
componentDidMount() {
actions.upload.show(this.props.match.params.id)
}
componentDidUpdate(prevProps) {
if (prevProps.match.params.id !== this.props.match.params.id) {
actions.upload.show(this.props.match.params.id)
}
}
handleDestroy() {
const { res: data } = this.props.upload.show
if (confirm("Really delete this upload?")) {
actions.upload.destroy(data).then(() => {
history.push('/upload/')
})
}
}
render() {
const { show, destroy } = this.props.upload
if (show.loading || destroy.loading) {
return