1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/** @format */
import React from 'react';
import Block from './style';
import { useTranslator } from '@eo-locale/react';
import { intervalToDuration } from 'date-fns';
import { useState } from 'react';
import { useEffect } from 'react';
import MicIcon from '@mui/icons-material/Mic';
import MicOffIcon from '@mui/icons-material/MicOff';
import PlayArrowIcon from '@mui/icons-material/PlayArrow';
import PauseIcon from '@mui/icons-material/Pause';
// import { contextModalEventProperty } from '../../context/modalEventProperty';
import { useContext } from 'react';
import {useConfigHoldMute} from "../../storage"
const InnerCaller = ({ hidden, type, from, innerTimer }) => {
const boxDialer = window.BoxDialer;
const configHoldMute = useConfigHoldMute((state) => state)
const translator = useTranslator();
// // context
// const [callEvents, setCallEvents] = useContext(contextModalEventProperty);
const dataFormatter = (secund) => {
let ts = intervalToDuration({
start: 0,
end: secund * 1000,
});
return secund > 3599
? `${ts.hours}:${ts.minutes}:${ts.seconds}`
: `${ts.minutes}:${ts.seconds}`;
};
const selectModalType = (type) => {
switch (type) {
case 'connected':
return (
<>
<div className='button timer'>
<div>{dataFormatter(innerTimer)}</div>
<div onClick={() => boxDialer.holdButtonClick()}>
{configHoldMute?.state?.callHold ? (
<PlayArrowIcon style={{ color: '#fff' }} />
) : (
<PauseIcon style={{ color: '#fff' }} />
)}
</div>
<div onClick={() => boxDialer.muteButtonClick()}>
{configHoldMute?.state?.callMute ? (
<MicOffIcon style={{ color: '#fff' }} />
) : (
<MicIcon style={{ color: '#fff' }} />
)}
</div>
</div>
<button
className='button red nocopy'
onClick={() => boxDialer.hangupButtonClick()}>
{translator.translate('REJECT')}
</button>
</>
);
case 'connectingOutgoing':
return (
<button
className='button red nocopy'
onClick={() => boxDialer.hangupButtonClick()}>
{translator.translate('REJECT')}
</button>
);
case 'connectingIncoming':
return (
<>
<button
className='button light_blue nocopy'
onClick={() => boxDialer.answerButtonClick()}>
{translator.translate('ANSWER')}
</button>
<button
className='button red nocopy'
onClick={() => boxDialer.hangupButtonClick()}>
{translator.translate('REJECT')}
</button>
</>
);
}
};
if (typeof from !== 'undefined' && from.length > 6) return;
return (
<Block hidden={hidden}>
<div className='top'>
<p className='call_text nocopy'>
{(type == 'connectingIncoming' || type == 'connected') && (
<>
{translator.translate('CALL_FROM')}{' '}
<span className='phone_text'>{from}</span>
</>
)}
{type == 'connectingOutgoing' && (
<>
{translator.translate('CALL_TO')}{' '}
<span className='phone_text'>{from}</span>
</>
)}
</p>
</div>
<div className='bottom'>{selectModalType(type)}</div>
</Block>
);
};
export default InnerCaller;