-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Expand file tree
/
Copy pathCallHistoryRowExternalUser.tsx
More file actions
51 lines (45 loc) · 1.54 KB
/
CallHistoryRowExternalUser.tsx
File metadata and controls
51 lines (45 loc) · 1.54 KB
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
import { GenericMenu } from '@rocket.chat/ui-client';
import type { CallHistoryTableExternalContact, CallHistoryTableRowProps } from '@rocket.chat/ui-voip';
import { CallHistoryTableRow, usePeekMediaSessionState, useWidgetExternalControls } from '@rocket.chat/ui-voip';
import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
type CallHistoryRowExternalUserProps = Omit<CallHistoryTableRowProps<CallHistoryTableExternalContact>, 'onClick' | 'menu'> & {
onClick: (historyId: string) => void;
};
const CallHistoryRowExternalUser = ({ _id, contact, type, status, duration, timestamp, onClick }: CallHistoryRowExternalUserProps) => {
const { t } = useTranslation();
const state = usePeekMediaSessionState();
const { toggleWidget } = useWidgetExternalControls();
const handleClick = useCallback(() => {
onClick(_id);
}, [onClick, _id]);
const actions = useMemo(() => {
if (state === 'unavailable') {
return [];
}
const disabled = state !== 'available';
return [
{
id: 'voiceCall',
icon: 'phone',
content: t('Voice_call'),
disabled,
tooltip: disabled ? t('Call_in_progress') : undefined,
onClick: () => toggleWidget({ number: contact.number }),
} as const,
];
}, [contact, toggleWidget, t, state]);
return (
<CallHistoryTableRow
_id={_id}
contact={contact}
type={type}
status={status}
duration={duration}
timestamp={timestamp}
onClick={handleClick}
menu={<GenericMenu title={t('Options')} items={actions} />}
/>
);
};
export default CallHistoryRowExternalUser;