import React from 'react'; import PhoneCallbackIcon from '@material-ui/icons/PhoneCallback'; import PhoneForwardedIcon from '@material-ui/icons/PhoneForwarded'; import PhoneIcon from '@material-ui/icons/Phone'; import PersonAddIcon from '@material-ui/icons/PersonAdd'; import { List } from '../../../../ui/components/List'; import { ListItem } from '../../../../ui/components/ListItem'; import { useContactActions } from '../../../contacts/hooks/useContactActions'; import { CallEvents, CallHistoryItem } from '../../../../../../typings/call'; import { useTranslation } from 'react-i18next'; import { Box, IconButton, ListItemIcon, ListItemText } from '@material-ui/core'; import { useHistory } from 'react-router-dom'; import { makeStyles, Theme } from '@material-ui/core/styles'; import dayjs from 'dayjs'; import { fetchNui } from '../../../../utils/fetchNui'; import { ServerPromiseResp } from '../../../../../../typings/common'; import { useSnackbar } from '../../../../ui/hooks/useSnackbar'; import { useMyPhoneNumber } from '../../../../os/simcard/hooks/useMyPhoneNumber'; const useStyles = makeStyles((theme: Theme) => ({ callForward: { color: theme.palette.success.main, }, callBack: { color: theme.palette.error.main, }, })); export const DialerHistory = ({ calls }) => { const { addAlert } = useSnackbar(); const myNumber = useMyPhoneNumber(); const { getDisplayByNumber } = useContactActions(); const classes = useStyles(); const history = useHistory(); const { t } = useTranslation(); const handleCall = (phoneNumber) => { fetchNui(CallEvents.INITIALIZE_CALL, { receiverNumber: phoneNumber, }).then((resp) => { if (resp.status === 'error') { addAlert({ message: t('CALLS.FEEDBACK.ERROR'), type: 'error' }); console.error(resp.errorMsg); } }); }; if (!calls?.length) { return (

{t('APPS_DIALER_NO_HISTORY')} 😞

); } return ( {calls.map((call: CallHistoryItem) => call.transmitter === myNumber ? ( handleCall(call.receiver)}>{} {getDisplayByNumber(call.receiver) === call.receiver && ( history.push(`/contacts/-1?addNumber=${call.receiver}&referal=/phone/contacts`) } > )} ) : ( handleCall(call.transmitter)}> {getDisplayByNumber(call.transmitter) === call.transmitter && ( history.push(`/contacts/-1?addNumber=${call.transmitter}&referal=/phone/contacts`) } > )} ), )} ); };