Improve hooks

This commit is contained in:
J Francisco Rader committed 2020-08-22 15:49:22 -03:00
1 parent d8f756b309
commit 34bfab2448
8 files changed
+61 -57

No files matched your search

+38 -36
View File
@@ -1,40 +1,42 @@
import React from 'react'
import { makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import { useContacts } from "../hooks/useContacts";
import { Button } from '@material-ui/core';
import PhoneIcon from '@material-ui/icons/Phone';
import ChatIcon from '@material-ui/icons/Chat';
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import ListItemText from "@material-ui/core/ListItemText";
import { Button } from "@material-ui/core";
import PhoneIcon from "@material-ui/icons/Phone";
import ChatIcon from "@material-ui/icons/Chat";
const useStyles = makeStyles((theme) => ({
root: {
width: '100%',
maxWidth: 360,
color: '#fff'
},
listItem: {
color: '#fff'
}
}));
root: {
width: "100%",
maxWidth: 360,
color: "#fff",
},
listItem: {
color: "#fff",
},
}));
export const ContactList = ({ children, onCall, onMessage }) => {
const classes = useStyles();
const [contacts] = useContacts();
return (
<>
<List component='nav' className={classes.root} >
{contacts.map((contact) => (
<ListItem divider className={classes.listItem}>
<ListItemText primary={contact.display} secondary={contact.phoneNumber}/>
<Button className={classes.listItem} onClick={onCall}><PhoneIcon/></Button>
<Button className={classes.listItem} onClick={onMessage}><ChatIcon/></Button>
</ListItem>
))}
</List>
</>
)
}
export const ContactList = ({ contacts, onCall, onMessage }) => {
const classes = useStyles();
return (
<List component="nav" className={classes.root}>
{contacts.map((contact) => (
<ListItem divider className={classes.listItem}>
<ListItemText
primary={contact.display}
secondary={contact.phoneNumber}
/>
<Button className={classes.listItem} onClick={onCall}>
<PhoneIcon />
</Button>
<Button className={classes.listItem} onClick={onMessage}>
<ChatIcon />
</Button>
</ListItem>
))}
</List>
);
};