Skip to content

Commit 1458060

Browse files
committed
Add VerifyEmailForm into User#ShowPage
1 parent 3d2992c commit 1458060

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

src/common/components/pages/user/ShowPage.js

+43-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
22
import { connect } from 'react-redux';
33
import { Link } from 'react-router';
44
import PageHeader from 'react-bootstrap/lib/PageHeader';
5+
import Modal from 'react-bootstrap/lib/Modal';
56
import Row from 'react-bootstrap/lib/Row';
67
import Col from 'react-bootstrap/lib/Col';
78
import Button from 'react-bootstrap/lib/Button';
@@ -11,13 +12,17 @@ import Head from '../../widgets/Head';
1112
import PageLayout from '../../layouts/PageLayout';
1213
import Time from '../../widgets/Time';
1314
import RefreshImage from '../../utils/RefreshImage';
15+
import VerifyEmailForm from '../../forms/user/VerifyEmailForm';
1416

1517
class ShowPage extends Component {
1618
constructor(props) {
1719
super(props);
1820
this.state = {
1921
user: props.initialUser,
22+
isShowVerifyEmailModal: false,
2023
};
24+
this.openModal = this._openModal.bind(this);
25+
this.closeModal = this._closeModal.bind(this);
2126
}
2227

2328
componentDidMount() {
@@ -36,6 +41,35 @@ class ShowPage extends Component {
3641
});
3742
}
3843

44+
_openModal() {
45+
this.setState({ isShowVerifyEmailModal: true });
46+
}
47+
48+
_closeModal() {
49+
this.setState({ isShowVerifyEmailModal: false });
50+
}
51+
52+
renderModal() {
53+
let { isShowVerifyEmailModal, user } = this.state;
54+
55+
return (
56+
<Modal
57+
show={isShowVerifyEmailModal}
58+
onHide={this.closeModal}
59+
>
60+
<Modal.Header closeButton>
61+
<Modal.Title>Send Verification Mail</Modal.Title>
62+
</Modal.Header>
63+
<Modal.Body>
64+
<VerifyEmailForm
65+
email={user.email && user.email.value}
66+
onCancel={this.closeModal}
67+
/>
68+
</Modal.Body>
69+
</Modal>
70+
);
71+
}
72+
3973
render() {
4074
const { user } = this.state;
4175
return (
@@ -45,6 +79,7 @@ class ShowPage extends Component {
4579
'https://www.gstatic.com/firebasejs/live/3.0/firebase.js',
4680
]}
4781
/>
82+
{this.renderModal()}
4883
<Row>
4984
<Col md={12}>
5085
<Link to="/user/me/edit">
@@ -64,7 +99,14 @@ class ShowPage extends Component {
6499
<dt>name</dt>
65100
<dd>{user.name}</dd>
66101
<dt>email</dt>
67-
<dd>{user.email && user.email.value}</dd>
102+
<dd>
103+
{user.email && user.email.value}
104+
{user.email && !user.email.isVerified && (
105+
<Button onClick={this.openModal}>
106+
Verify Now
107+
</Button>
108+
)}
109+
</dd>
68110
<dt>updatedAt</dt>
69111
<dd>
70112
<Time value={user.updatedAt} format="YYYY-MM-DD" />

0 commit comments

Comments
 (0)