From 3cf70771cb45cc16ec33ffe44e7a1a4799d8f395 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 23 Jun 2020 23:18:07 +0200 Subject: adding web app base --- .../views/upload/components/upload.show.js | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 animism-align/frontend/views/upload/components/upload.show.js (limited to 'animism-align/frontend/views/upload/components/upload.show.js') diff --git a/animism-align/frontend/views/upload/components/upload.show.js b/animism-align/frontend/views/upload/components/upload.show.js new file mode 100644 index 0000000..6b36269 --- /dev/null +++ b/animism-align/frontend/views/upload/components/upload.show.js @@ -0,0 +1,70 @@ +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 + } + if (!show.loading && !show.res || show.not_found) { + return
Upload {this.props.match.params.id} not found
+ } + const { res: data } = show + return ( +
+
+ + +
+
+ +
+ {'Uploaded by '} + {data.username} + {' on '} + {formatDate(data.created_at)} + {' at '} + {formatTime(data.created_at)} + {'. '} +
+
+
+ ) + } +} + +const mapStateToProps = state => ({ + upload: state.upload, +}) + +const mapDispatchToProps = dispatch => ({ + // searchActions: bindActionCreators({ ...searchActions }, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(UploadShow) -- cgit v1.2.3-70-g09d2