import React from 'react'; import { Redirect } from 'react-router'; import { Share } from '../model/'; import { notify, basename, filetype, findParams } from '../helpers/'; import { Loader, Input, Button, Container, ErrorPage, Icon, NgIf } from '../components/'; import { t } from '../locales/'; import './error.scss'; import './sharepage.scss'; @ErrorPage export class SharePage extends React.Component { constructor(props){ super(props); this.state = { path: null, key: null, error: null, loading: false, isUploader: false, }; } componentDidMount(){ this._proofQuery(this.props.match.params.id).then(() => { if(this.refs.$input) { this.refs.$input.ref.focus(); } }); } submitProof(e, type, value){ e.preventDefault(); this.setState({loading: true}); this._proofQuery(this.props.match.params.id, {type: type, value:value}); } _proofQuery(id, data = {}){ this.setState({loading: true}); return Share.proof(id, data).then((res) => { if(this.refs.$input) { this.refs.$input.ref.value = ""; } let st = { key: res.key, path: res.path || null, share: res.id, loading: false, isUploader: res.can_read === false && res.can_write === false && res.can_upload === true, }; if(res.message){ notify.send(res.message, "info"); }else if(res.error){ st.error = res.error; window.setTimeout(() => this.setState({error: null}), 500); } return new Promise((done) => { this.setState(st, () => done()); }); }).catch((err) => this.props.error(err)); } render() { const marginTop = () => { return { marginTop: parseInt(window.innerHeight / 3)+'px' }; }; let className = this.state.error ? "error rand-"+Math.random().toString() : ""; if(this.state.path !== null){ if(!!findParams("next")){ const url = findParams("next"); if(url[0] === "/"){ requestAnimationFrame(() => { window.location.pathname = url; }); return (