Merge pull request #279 from jorilallo/jori/delete-redirect

Fixed redirect after document delete
This commit is contained in:
Tom Moor 2017-09-29 00:56:37 -04:00 committed by GitHub
commit bb9686b112
1 changed files with 2 additions and 3 deletions

View File

@ -3,7 +3,6 @@ import React, { Component } from 'react';
import { withRouter } from 'react-router-dom';
import { observable } from 'mobx';
import { inject, observer } from 'mobx-react';
import { homeUrl } from 'utils/routeHelpers';
import Button from 'components/Button';
import Flex from 'components/Flex';
import HelpText from 'components/HelpText';
@ -24,11 +23,11 @@ type Props = {
handleSubmit = async (ev: SyntheticEvent) => {
ev.preventDefault();
this.isDeleting = true;
const { collection } = this.props.document;
const success = await this.props.document.delete();
if (success) {
this.props.documents.remove(this.props.document.id);
this.props.history.push(homeUrl());
this.props.history.push(collection.url);
this.props.onSubmit();
}