-
Notifications
You must be signed in to change notification settings - Fork 0
/
PeopleList.js
192 lines (185 loc) · 6.06 KB
/
PeopleList.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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import React from "react";
import * as peopleService from "../services/people.service";
class PeopleList extends React.Component {
constructor(props) {
super(props);
this.state = {
people: this.props.people,
userName: ""
};
// this.onDelete = this.onDelete.bind(this);
this.onChange = this.onChange.bind(this);
}
// componentDidMount() {
// peopleService
// .getAll()
// .then(data => {
// console.log(data);
// this.setState({
// people: data.items.map(person => {
// return person;
// })
// });
// console.log("People Displayed", data);
// })
// .catch(() => {
// console.log("Error Loading People");
// });
// }
componentWillReceiveProps(nextProps) {
this.setState({ people: nextProps.people });
}
onChange(event) {
this.setState({ [event.target.name]: event.target.value }, () =>
peopleService
.search(this.state.userName.trim())
.then(data => {
console.log(data);
this.setState({
people: data.items.map(person => {
return person;
})
});
})
.catch(err => {})
);
}
render() {
return (
<React.Fragment>
<section
style={{ display: "inline", marginLeft: "1%" }}
className="col col-3"
>
<label className="input">
{" "}
<strong> Search People</strong>{" "}
<input
type="text"
name="userName"
placeholder="By Last Name"
value={this.state.userName}
onChange={this.onChange}
/>
</label>
</section>
<div>
{this.state.people.map(person => {
return (
<div
className="flex-container col-lg-4 tab-content bg-color-white padding-2 smart-form"
key={person._id}
style={{ textAlign: "center" }}
>
<div
className="flex-item card panel panel-default"
style={{
padding: "10px 10px 10px 10px",
marginBottom: "15px"
}}
>
<h5>
<img
className="picture pull-center"
src={`${person.fileKey ||
"http://www.udayanschoolgor.edu.bd/uploads/avatar_icon.jpg"}`}
alt=""
height="65px"
style={{
borderRadius: "50%",
margin: "5px 5px 5px 0px"
}}
width="65px"
/>
<a
href={`/people/${person._id}/dashboard/editPerson`}
title={`Edit ${person.firstName} ${person.lastName} `}
>{`${person.prefixName || ""} ${
person.firstName
} ${person.middleName || ""} ${
person.lastName
} ${person.suffixName || ""}`}</a>
</h5>
<br />
<div>
<div className="publicEmail">
<i
className="fa-fw fa fa-envelope fa-sm"
style={{ color: "gray" }}
/>{" "}
{person.publicEmail}
</div>
<div
className="phoneNumber"
style={{
color: "green",
whiteSpace: "nowrap"
}}
>
{person.phoneNumber ? (
<React.Fragment>
<i className="fa-fw fa fa-phone fa-sm" />{" "}
{person.phoneNumber}
</React.Fragment>
) : null}
</div>
{/* <p className="address">{`Address: ${person.address || ""}`}</p>
<p className="loginId">{`Login ID: ${person.loginId || ""}`}</p> */}
<div>
<input
type="checkbox"
name="receiveSms"
checked={person.receiveSms}
value={true}
readOnly
/>{" "}
SMS Notifications
</div>
{/* <div style={{ margin: "24px 0" }}>
<a
href={`/people/${person._id}/dashboard/editPerson`}
title="Edit"
>
<i
className="fa-fw fa fa-pencil fa-sm pull-left"
style={{ color: "orange" }}
/>
</a>
<a href="/" title="Delete">
<i
className="fa-fw fa fa-times fa-sm"
style={{ color: "maroon" }}
onClick={e => props.onDelete(person, e)}
/>
</a>
<Link
role="button"
to={{
pathname: "/invite",
search: `?person=${person._id}`,
state: { person }
}}
disabled={
!person.firstName ||
!person.lastName ||
!person.publicEmail
}
title="Invite"
>
<i
className="fa-fw fa fa-send fa-sm"
style={{ color: "teal" }}
/>
</Link>
</div> */}
</div>
</div>
</div>
);
})}
</div>
</React.Fragment>
);
}
}
export default PeopleList;