Improve the look of the contact page.

master
Tom Hacohen 7 years ago
parent 1987ea126d
commit 7067824ccd

@ -19,39 +19,59 @@ class Contact extends React.Component {
} }
const contact = this.props.contact; const contact = this.props.contact;
const uid = contact.comp.getFirstPropertyValue('uid'); const name = contact.fn;
const name = contact.comp.getFirstPropertyValue('fn');
const phoneNumbers = contact.comp.getAllProperties('tel').map((prop, idx) => { let lists = [];
function getAllType(
propName: string,
props: any,
valueToHref?: (value: string) => string,
primaryTransform?: (value: string) => string,
secondaryTransform?: (value: string) => string) {
return contact.comp.getAllProperties(propName).map((prop, idx) => {
const json = prop.toJSON(); const json = prop.toJSON();
const values = prop.getValues().map((val) => ( const values = prop.getValues().map((val) => (
<ListItem <ListItem
key={idx} key={idx}
leftIcon={<CommunicationCall />} href={valueToHref ? valueToHref(val) : undefined}
rightIcon={<CommunicationChatBubble />} primaryText={primaryTransform ? primaryTransform(val) : val}
href={'tel:' + val}
primaryText={val}
secondaryText={json[1].type} secondaryText={json[1].type}
{...props}
/> />
)); ));
return values; return values;
}); });
}
const emails = contact.comp.getAllProperties('email').map((prop, idx) => { lists.push(getAllType(
const json = prop.toJSON(); 'tel',
const values = prop.getValues().map((val) => ( {
<ListItem leftIcon: <CommunicationCall />,
key={idx} rightIcon: <CommunicationChatBubble />
leftIcon={<CommunicationEmail color={indigo500} />} },
href={'mailto:' + val} (x) => ('tel:' + x),
primaryText={val}
secondaryText={json[1].type}
/>
)); ));
return values;
});
const skips = ['tel', 'email', 'prodid', 'uid', 'fn', 'n', 'version', 'photo']; lists.push(getAllType(
'email',
{
leftIcon: <CommunicationEmail color={indigo500} />,
},
(x) => ('mailto:' + x),
));
lists.push(getAllType(
'impp',
{
insetChildren: true,
},
(x) => x,
(x) => (x.substring(x.indexOf(':') + 1)),
));
const skips = ['tel', 'email', 'impp', 'prodid', 'uid', 'fn', 'n', 'version', 'photo'];
const theRest = contact.comp.getAllProperties().filter((prop) => ( const theRest = contact.comp.getAllProperties().filter((prop) => (
skips.indexOf(prop.name) === -1 skips.indexOf(prop.name) === -1
)).map((prop, idx) => { )).map((prop, idx) => {
@ -87,9 +107,11 @@ class Contact extends React.Component {
return ( return (
<div> <div>
<h3>{name}</h3> <h3>{name}</h3>
<span>{uid}</span> {lists.map((list, idx) => (
{listIfNotEmpty(phoneNumbers)} <React.Fragment key={idx}>
{listIfNotEmpty(emails)} {listIfNotEmpty(list)}
</React.Fragment>
))}
<List> <List>
{theRest} {theRest}
</List> </List>

Loading…
Cancel
Save