feat(contacts/nui | calling/client|server): getName | close modal on add | show dail history

This commit is contained in:
Christopher committed 2021-01-29 19:53:14 +01:00
1 parent 0f10eac796
commit 89ea248d32
9 files changed
+72 -43

No files matched your search

@@ -4,19 +4,36 @@ import PhoneCallbackIcon from '@material-ui/icons/PhoneCallback';
import PhoneForwardedIcon from '@material-ui/icons/PhoneForwarded';
import { List } from '../../../../ui/components/List';
import { ListItem } from '../../../../ui/components/ListItem';
import Nui from '../../../../os/nui-events/utils/Nui'
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
import { useContacts } from '../../../contacts/hooks/useContacts';
const CallTypeIcon = {
incoming: <PhoneCallbackIcon />,
outgoing: <PhoneForwardedIcon />,
};
export const DialerHistory = ({ calls }) => {
const { number } = useSimcard();
const { getDisplayByNumber } = useContacts();
const handleCall = (phoneNumber) => {
Nui.send('phone:beginCall', {
number: phoneNumber
})
}
if (!calls) {
return <p>Things are loading or arent here at all</p>
}
return (
<List disablePadding>
{calls.map((call) => (
<ListItem key={call.id} divider button>
<ListItemText primary={call.caller} secondary={call.phoneNumber} />
{CallTypeIcon[call.type]}
{calls.map((call) => call.transmitter === number ? (
<ListItem key={call.id} divider button onClick={() => handleCall(call.receiver)}>
<ListItemText primary={getDisplayByNumber(call.receiver)} />
{<PhoneForwardedIcon />}
</ListItem>
): (
<ListItem key={call.id} divider button onClick={() => handleCall(call.transmitter)}>
<ListItemText primary={getDisplayByNumber(call.transmitter)} />
{<PhoneCallbackIcon />}
</ListItem>
))}
</List>