diff --git a/js/components/ascribe_forms/form.js b/js/components/ascribe_forms/form.js index 7e1371ed..1254fb76 100644 --- a/js/components/ascribe_forms/form.js +++ b/js/components/ascribe_forms/form.js @@ -11,10 +11,10 @@ import AlertDismissable from './alert'; import GlobalNotificationModel from '../../models/global_notification_model'; import GlobalNotificationActions from '../../actions/global_notification_actions'; -import requests from '../../utils/requests'; - import { sanitize } from '../../utils/general'; import { getLangText } from '../../utils/lang'; +import request from '../../utils/request'; + let Form = React.createClass({ @@ -95,32 +95,29 @@ let Form = React.createClass({ } }, - post() { - requests - .post(this.props.url, { body: this.getFormData() }) + request(method) { + request(this.props.url, { + method, + jsonBody: this.getFormData() + }) .then(this.handleSuccess) .catch(this.handleError); }, + post() { + this.request('POST'); + }, + put() { - requests - .put(this.props.url, { body: this.getFormData() }) - .then(this.handleSuccess) - .catch(this.handleError); + this.request('PUT'); }, patch() { - requests - .patch(this.props.url, { body: this.getFormData() }) - .then(this.handleSuccess) - .catch(this.handleError); + this.request('PATCH'); }, delete() { - requests - .delete(this.props.url, this.getFormData()) - .then(this.handleSuccess) - .catch(this.handleError); + this.request('DELETE'); }, getFormData() { diff --git a/js/components/ascribe_forms/form_delete_edition.js b/js/components/ascribe_forms/form_delete_edition.js index 113d920a..5ba8366f 100644 --- a/js/components/ascribe_forms/form_delete_edition.js +++ b/js/components/ascribe_forms/form_delete_edition.js @@ -9,6 +9,7 @@ import AclInformation from '../ascribe_buttons/acl_information'; import AscribeSpinner from '../ascribe_spinner'; import { getLangText } from '../../utils/lang'; +import { formatText } from '../../utils/text'; import { resolveUrl } from '../../utils/url_resolver'; @@ -22,25 +23,22 @@ let EditionDeleteForm = React.createClass({ }, getBitcoinIds() { - return this.props.editions.map(function(edition){ - return edition.bitcoin_id; + return this.props.editions.map((edition) => edition.bitcoin_id); + }, + + getUrl() { + return formatText(resolveUrl('edition_delete'), { + // Since this form can be used for either deleting a single edition or multiple we need + // to call getBitcoinIds to get the value of edition_id + editionId: this.getBitcoinIds().join(',') }); }, - // Since this form can be used for either deleting a single edition or multiple - // we need to call getBitcoinIds to get the value of edition_id - getFormData() { - return { - edition_id: this.getBitcoinIds().join(',') - }; - }, - - render () { + render() { return (