import React from 'react' import PropTypes from 'prop-types' export default class UploadForm extends React.Component { constructor () { super() this.form = React.createRef() this.onSubmit = this.onSubmit.bind(this) this.state = { error: false, success: false, } } onSubmit (e) { e.preventDefault() const data = new FormData(this.form.current) fetch('/api/source-maps', { method: 'POST', headers: { accepts: 'application/json', }, body: data, }) .then((res) => res.json()) .then((res) => { this.setState({ success: true, error: false, }) }) .catch((res) => { this.setState({ success: false, error: true, }) }) } render () { // const { error, success } = this.state const error = true const success = true return (
{success &&
Source Map Uploaded
} {error &&
Error Uploading Source Map
}
) } }