Fix: Dialer Routing, added contacts and styling. (#77)

* Fix dialer routing and add contacts to it

* Fix styling

* Delete unused component
This commit is contained in:
J Francisco Rader authored and GitHub committed 2021-02-07 23:55:24 -05:00
1 parent 84d9b08bff
commit 2bb32c453b
8 files changed
+95 -84

No files matched your search

@@ -6,7 +6,6 @@ import { ContactList } from './List/ContactList';
import { useApp } from '../../../os/apps/hooks/useApps';
import { AddContactModal } from './ContactModal';
import { useModal } from '../hooks/useModal';
import { SearchContacts } from './List/SearchContacts';
import PersonAddIcon from '@material-ui/icons/PersonAdd';
import Fab from '@material-ui/core/Fab';
import { InfoModal } from './modal/InfoModal';
@@ -48,7 +47,6 @@ export const ContactsApp = () => {
return (
<AppWrapper id='contact-app'>
<AppTitle app={contacts} />
<SearchContacts />
<AddContactModal />
<InfoModal key={contactDetail?.id} />
<div className={showModal ? classes.backgroundModal : undefined} />
@@ -20,18 +20,18 @@ import { useContactDetail } from '../../hooks/useContactDetail';
import Nui from '../../../../os/nui-events/utils/Nui';
import '../Contact.css';
import { SearchContacts } from './SearchContacts';
export const ContactList = () => {
const { filteredContacts } = useFilteredContacts();
const { setShowContactModal } = useContactModal();
const { contactDetail, setContactDetail } = useContactDetail();
const { setContactDetail } = useContactDetail();
const contacts = useContacts();
const openContactInfo = (contact) => {
setShowContactModal(true);
setContactDetail(contact);
console.log('CONTACT', contactDetail);
};
const startCall = (number) => {
console.log(number);
@@ -40,50 +40,54 @@ export const ContactList = () => {
});
};
const filteredRegEx = new RegExp(filteredContacts, "gi")
const filteredRegEx = new RegExp(filteredContacts, 'gi');
return (
<List>
{contacts.contacts
.filter(
(contact) =>
contact.display.match(filteredRegEx) || contact.number.match(filteredRegEx)
)
.map((contact) => (
<>
<ListItem key={contact.id} divider>
<ListItemAvatar>
{contact.avatar ? (
<MuiAvatar src={contact.avatar} />
) : (
<MuiAvatar>
{contact.display.slice(0, 1).toUpperCase()}
</MuiAvatar>
)}
</ListItemAvatar>
<ListItemText
primary={contact.display}
secondary={contact.number}
/>
<Button onClick={() => startCall(contact.number)}>
<PhoneIcon />
</Button>
<Button
onClick={() =>
console.log('Message: ' + contact.display, contact.number)
}
>
<ChatIcon />
</Button>
<Button
style={{ margin: -15 }}
onClick={() => openContactInfo(contact)}
>
<MoreVertIcon />
</Button>
</ListItem>
</>
))}
</List>
<>
<SearchContacts />
<List>
{contacts.contacts
.filter(
(contact) =>
contact.display.match(filteredRegEx) ||
contact.number.match(filteredRegEx)
)
.map((contact) => (
<>
<ListItem key={contact.id} divider>
<ListItemAvatar>
{contact.avatar ? (
<MuiAvatar src={contact.avatar} />
) : (
<MuiAvatar>
{contact.display.slice(0, 1).toUpperCase()}
</MuiAvatar>
)}
</ListItemAvatar>
<ListItemText
primary={contact.display}
secondary={contact.number}
/>
<Button onClick={() => startCall(contact.number)}>
<PhoneIcon />
</Button>
<Button
onClick={() =>
console.log('Message: ' + contact.display, contact.number)
}
>
<ChatIcon />
</Button>
<Button
style={{ margin: -15 }}
onClick={() => openContactInfo(contact)}
>
<MoreVertIcon />
</Button>
</ListItem>
</>
))}
</List>
</>
);
};
@@ -3,7 +3,6 @@ import { InputBase } from '@material-ui/core';
import SearchIcon from '@material-ui/icons/Search';
import {
createStyles,
fade,
Theme,
makeStyles,
} from '@material-ui/core/styles';
@@ -15,7 +14,7 @@ import { useFilteredContacts } from '../../hooks/useFilteredContacts';
const useStyles = makeStyles((theme: Theme) =>
createStyles({
bg: {
backgroundColor: '#232323',
backgroundColor: theme.palette.background.paper,
display: 'flex',
height: 60,
justifyContent: 'center',
@@ -25,14 +24,13 @@ const useStyles = makeStyles((theme: Theme) =>
fontSize: 20,
},
inputRoot: {
color: '#fff',
fontSize: 18,
border: '1px solid',
borderColor: theme.palette.divider,
},
inputInput: {
padding: theme.spacing(1, 4, 1, 4),
transition: theme.transitions.create('width'),
width: '100%',
[theme.breakpoints.up('sm')]: {
width: '13ch',
'&:focus': {
@@ -43,10 +41,6 @@ const useStyles = makeStyles((theme: Theme) =>
search: {
position: 'relative',
borderRadius: theme.shape.borderRadius,
backgroundColor: fade(theme.palette.common.white, 0.15),
'&:hover': {
backgroundColor: fade(theme.palette.common.white, 0.25),
},
marginLeft: 0,
width: '100%',
[theme.breakpoints.up('sm')]: {
@@ -75,16 +69,17 @@ export const SearchContacts = () => {
<div className={classes.bg}>
<div className={classes.search}>
<div className={classes.searchIcon}>
<SearchIcon style={{ color: '#fff' }} />
<SearchIcon />
</div>
<InputBase
onChange={e => setFilteredContacts(e.target.value)}
fullWidth
onChange={(e) => setFilteredContacts(e.target.value)}
placeholder={t('APPS_CONTACT_PLACEHOLDER_SEARCH_CONTACTS')}
classes={{
root: classes.inputRoot,
input: classes.inputInput,
}}
inputProps={{ 'aria-label': 'search', 'autoFocus': true }}
inputProps={{ 'aria-label': 'search', autoFocus: true }}
/>
</div>
</div>