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

@@ -3,14 +3,16 @@ import { AppWrapper } from '../../../ui/components';
import { AppTitle } from '../../../ui/components/AppTitle';
import { AppContent } from '../../../ui/components/AppContent';
import { DialerHistory } from './views/DialerHistory';
import { useDialerHistory } from '../hooks/useDialerHistory';
import { useApp } from '../../../os/apps/hooks/useApps';
import { Switch, Route } from 'react-router-dom';
import DialPage from './views/DialPage';
import DialerNavBar from './DialerNavBar';
import { useDailHistory } from '../hooks/useDailHistory';
export const DialerApp = () => {
const { history } = useDialerHistory();
const history = useDailHistory()
const dialer = useApp('DIALER');
return (
<AppWrapper>
@@ -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>
@@ -1,18 +0,0 @@
import { useRecoilState, atom } from 'recoil';
const dialerHistoryState = atom({
key: 'dialerHistory',
default: [
{
id: 1,
caller: 'ROCKY',
phoneNumber: '000-1112',
type: 'outgoing',
},
],
});
export const useDialerHistory = () => {
const [history, setHistory] = useRecoilState(dialerHistoryState);
return { history, setHistory };
};