Email.js
2.45 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import React, { Component } from 'react';
import cx from 'classnames';
import {
Breadcrumb,
BreadcrumbItem,
Alert,
} from 'reactstrap';
import Filters from './components/Filters/Filters';
import MessageTable from './components/MessageTable/MessageTable';
import s from './Email.module.scss';
class Email extends Component {
state = {
isNotificationOpen: true,
filter: null,
openedMessage: null,
compose: false,
composeData: null,
alertAfter: false,
}
componentDidMount() {
setTimeout(() => { this.fixAlert(); }, 0);
}
fixAlert() {
this.setState({ alertAfter: true });
}
filter = (filter) => {
this.setState({ filter, compose: false, composeData: null });
}
closeNotification() {
this.setState({ isNotificationOpen: false });
}
openMessage = (id) => {
this.setState(pvState => ({
openedMessage: id,
compose: id === null ? false : pvState.compose,
composeData: id === null ? null : pvState.composeData,
}));
}
changeCompose = (compose, data) => {
this.setState({ compose });
if (data) {
this.setState({ composeData: data });
}
}
render() {
const {
isNotificationOpen,
filter,
openedMessage,
alertAfter,
compose,
composeData,
} = this.state;
return (
<div>
<Breadcrumb>
<BreadcrumbItem>YOU ARE HERE</BreadcrumbItem>
<BreadcrumbItem active>Email</BreadcrumbItem>
</Breadcrumb>
<div className="page-top-line">
<h1 className="page-title">Email - <span className="fw-semi-bold">Inbox</span></h1>
<Alert
isOpen={isNotificationOpen}
color="success"
toggle={() => this.closeNotification()}
className={cx(s.alert, { [s.alertAfter]: alertAfter })}
>
Hey! This is a <span className="fw-semi-bold">real app</span> with CRUD and Search functions. Have fun!
</Alert>
</div>
<div className={s.view}>
<Filters
filter={this.filter}
openMessage={this.openMessage}
compose={this.changeCompose}
/>
<MessageTable
filter={filter}
openedMessage={openedMessage}
openMessage={this.openMessage}
compose={compose}
changeCompose={this.changeCompose}
composeData={composeData}
/>
</div>
</div>
);
}
}
export default Email;