/
Confirmation.js
65 lines (59 loc) · 2.02 KB
/
Confirmation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React from "react";
import _ from "lodash";
import { createComponent, i18n } from "webiny-app";
import { ModalConfirmationComponent } from "webiny-app-ui";
import Dialog from "./Dialog";
import Content from "./Content";
import Body from "./Body";
import Footer from "./Footer";
const t = i18n.namespace("Webiny.Ui.Modal.Confirmation");
class Confirmation extends React.Component {
render() {
const { modules: { Loader, Button }, styles, title, render } = this.props;
if (render) {
return render.call(this);
}
let content = this.props.message || this.props.children;
if (_.isFunction(content)) {
content = content({ data: this.props.data });
}
return (
<Dialog
modalContainerTag="confirmation-modal"
className={styles.alertModal}
onCancel={this.props.onCancel}
closeOnClick={this.props.closeOnClick}
>
{this.props.loading && <Loader />}
<Content>
<Body>
<div className="text-center">
<h4>{title}</h4>
<p>{content}</p>
</div>
</Body>
<Footer>
<Button
type="default"
label={this.props.cancel}
onClick={this.props.onCancel}
/>
<Button
type="primary"
label={this.props.confirm}
onClick={this.props.onConfirm}
/>
</Footer>
</Content>
</Dialog>
);
}
}
Confirmation.defaultProps = {
title: t`Confirmation dialog`,
confirm: t`Yes`,
cancel: t`No`
};
export default createComponent([Confirmation, ModalConfirmationComponent], {
modules: ["Button", "Loader"]
});