move deletion confirmation toast props to one file

Signed-off-by: Stepan Usatyuk <usaatyuk@ustk.me>
This commit is contained in:
2019-05-15 01:03:34 +03:00
parent 4887fb0731
commit 73c3f3a034
3 changed files with 15 additions and 20 deletions

View File

@@ -5,3 +5,14 @@ export const AppToaster = Toaster.create({
position: Position.TOP,
});
export function showDeletionToast(cancelFn: () => void) {
AppToaster.show({
message: "Document deleted!",
intent: "danger",
timeout: 2900,
action: {
text: "Undo",
onClick: cancelFn,
},
});
}

View File

@@ -5,7 +5,7 @@ import { connect } from "react-redux";
import { RouteComponentProps, withRouter } from "react-router";
import { Dispatch } from "redux";
import { IDocumentJSON } from "~../../src/entity/Document";
import { AppToaster } from "~AppToaster";
import { showDeletionToast } from "~AppToaster";
import { deleteDocCancel, deleteDocStart } from "~redux/docs/actions";
export interface IDocumentCardComponentProps extends RouteComponentProps {
@@ -28,15 +28,7 @@ export class DocumentCardComponent extends React.PureComponent<
}
public handleDelete() {
AppToaster.show({
message: "Document deleted!",
intent: "danger",
timeout: 2900,
action: {
text: "Undo",
onClick: () => this.props.cancelDelete(),
},
});
showDeletionToast(this.props.cancelDelete);
this.props.deleteDoc(this.props.doc.id);
}

View File

@@ -6,7 +6,7 @@ import { connect } from "react-redux";
import { RouteComponentProps, withRouter } from "react-router";
import { Dispatch } from "redux";
import { IDocumentJSON } from "~../../src/entity/Document";
import { AppToaster } from "~AppToaster";
import { showDeletionToast } from "~AppToaster";
import { LoadingStub } from "~LoadingStub";
import {
deleteDocCancel,
@@ -124,15 +124,7 @@ export class DocumentEditComponent extends React.PureComponent<
public remove() {
this.props.history.push(`/`);
this.props.deleteDoc(this.state.id);
AppToaster.show({
message: "Document deleted!",
intent: "danger",
timeout: 2900,
action: {
text: "Undo",
onClick: () => this.props.cancelDelete(),
},
});
showDeletionToast(this.props.cancelDelete);
}
public save() {