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
193
194
195
|
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import classNames from 'classnames';
import Edit from '@material-ui/icons/Edit';
import Star from '@material-ui/icons/Star';
import StarBorder from '@material-ui/icons/StarBorder';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import LocalPhone from '@material-ui/icons/LocalPhone';
import Email from '@material-ui/icons/Email';
import Smartphone from '@material-ui/icons/Smartphone';
import LocationOn from '@material-ui/icons/LocationOn';
import Work from '@material-ui/icons/Work';
import Language from '@material-ui/icons/Language';
import {
List,
ListItem,
ListItemText,
ListItemAvatar,
Avatar,
Menu,
MenuItem,
IconButton,
Typography,
Divider,
} from '@material-ui/core';
import styles from './contact-jss';
const optionsOpt = [
'Block Contact',
'Delete Contact',
'Option 1',
'Option 2',
'Option 3',
];
const ITEM_HEIGHT = 48;
class ContactDetail extends React.Component {
state = {
anchorElOpt: null,
};
handleClickOpt = event => {
this.setState({ anchorElOpt: event.currentTarget });
};
handleCloseOpt = () => {
this.setState({ anchorElOpt: null });
};
deleteContact = (item) => {
this.props.remove(item);
this.setState({ anchorElOpt: null });
}
render() {
const {
classes,
dataContact,
itemSelected,
edit,
favorite,
showMobileDetail
} = this.props;
const { anchorElOpt } = this.state;
return (
<main className={classNames(classes.content, showMobileDetail ? classes.detailPopup : '')}>
<section className={classes.cover}>
<div className={classes.opt}>
<IconButton className={classes.favorite} aria-label="Favorite" onClick={() => favorite(dataContact.get(itemSelected))}>
{dataContact.getIn([itemSelected, 'favorited']) ? (<Star />) : <StarBorder />}
</IconButton>
<IconButton aria-label="Edit" onClick={() => edit(dataContact.get(itemSelected))}>
<Edit />
</IconButton>
<IconButton
aria-label="More"
aria-owns={anchorElOpt ? 'long-menu' : null}
aria-haspopup="true"
className={classes.button}
onClick={this.handleClickOpt}
>
<MoreVertIcon />
</IconButton>
<Menu
id="long-menu"
anchorEl={anchorElOpt}
open={Boolean(anchorElOpt)}
onClose={this.handleCloseOpt}
PaperProps={{
style: {
maxHeight: ITEM_HEIGHT * 4.5,
width: 200,
},
}}
>
{optionsOpt.map(option => {
if (option === 'Delete Contact') {
return (
<MenuItem key={option} selected={option === 'Edit Profile'} onClick={() => this.deleteContact(dataContact.get(itemSelected))}>
{option}
</MenuItem>
);
}
return (
<MenuItem key={option} selected={option === 'Edit Profile'} onClick={this.handleCloseOpt}>
{option}
</MenuItem>
);
})}
</Menu>
</div>
<Avatar alt={dataContact.getIn([itemSelected, 'name'])} src={dataContact.getIn([itemSelected, 'avatar'])} className={classes.avatar} />
<Typography className={classes.userName} variant="h4">
{dataContact.getIn([itemSelected, 'name'])}
<Typography variant="caption" display="block">
{dataContact.getIn([itemSelected, 'title'])}
</Typography>
</Typography>
</section>
<div>
<List>
<ListItem>
<ListItemAvatar>
<Avatar className={classes.blueIcon}>
<LocalPhone />
</Avatar>
</ListItemAvatar>
<ListItemText primary={dataContact.getIn([itemSelected, 'phone'])} secondary="Phone" />
</ListItem>
<Divider variant="inset" />
<ListItem>
<ListItemAvatar>
<Avatar className={classes.amberIcon}>
<Smartphone />
</Avatar>
</ListItemAvatar>
<ListItemText primary={dataContact.getIn([itemSelected, 'secondaryPhone'])} secondary="Secondary Phone" />
</ListItem>
<Divider variant="inset" />
<ListItem>
<ListItemAvatar>
<Avatar className={classes.tealIcon}>
<Email />
</Avatar>
</ListItemAvatar>
<ListItemText primary={dataContact.getIn([itemSelected, 'personalEmail'])} secondary="Personal Email" />
</ListItem>
<Divider variant="inset" />
<ListItem>
<ListItemAvatar>
<Avatar className={classes.brownIcon}>
<Work />
</Avatar>
</ListItemAvatar>
<ListItemText primary={dataContact.getIn([itemSelected, 'companyEmail'])} secondary="Company Email" />
</ListItem>
<Divider variant="inset" />
<ListItem>
<ListItemAvatar>
<Avatar className={classes.redIcon}>
<LocationOn />
</Avatar>
</ListItemAvatar>
<ListItemText primary={dataContact.getIn([itemSelected, 'address'])} secondary="Address" />
</ListItem>
<Divider variant="inset" />
<ListItem>
<ListItemAvatar>
<Avatar className={classes.purpleIcon}>
<Language />
</Avatar>
</ListItemAvatar>
<ListItemText primary={dataContact.getIn([itemSelected, 'website'])} secondary="Website" />
</ListItem>
</List>
</div>
</main>
);
}
}
ContactDetail.propTypes = {
classes: PropTypes.object.isRequired,
showMobileDetail: PropTypes.bool.isRequired,
dataContact: PropTypes.object.isRequired,
itemSelected: PropTypes.number.isRequired,
edit: PropTypes.func.isRequired,
remove: PropTypes.func.isRequired,
favorite: PropTypes.func.isRequired,
};
export default withStyles(styles)(ContactDetail);
|