import { ContextualbarHeader, ContextualbarIcon, ContextualbarTitle, ContextualbarClose, ContextualbarEmptyContent, ContextualbarDialog, ContextualbarSkeleton, } from '@rocket.chat/ui-client'; import { useEndpoint } from '@rocket.chat/ui-contexts'; import { useQuery } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; import MediaCallHistoryExternal, { isExternalCallHistoryItem } from './MediaCallHistoryExternal'; import MediaCallHistoryInternal, { isInternalCallHistoryItem } from './MediaCallHistoryInternal'; import { callHistoryQueryKeys } from '../../lib/queryKeys'; export type MediaCallHistoryContextualbarProps = { openRoomId?: string; messageRoomId?: string; openUserInfo?: (userId: string, rid: string) => void; onClose: () => void; callId?: string; historyId?: string; }; const MediaCallHistoryContextualbar = ({ openRoomId, messageRoomId, openUserInfo, callId, historyId, onClose, }: MediaCallHistoryContextualbarProps) => { const { t } = useTranslation(); const getCallHistory = useEndpoint('GET', '/v1/call-history.info'); const { data, isPending, isSuccess } = useQuery({ queryKey: callHistoryQueryKeys.info(callId || historyId), queryFn: async () => { if (callId) { return getCallHistory({ callId }); } if (historyId) { return getCallHistory({ historyId }); } throw new Error('Call ID or history ID is required'); }, staleTime: Infinity, // Call history should never change... enabled: !!callId || !!historyId, }); if (isPending) { return ; } if (isSuccess && isInternalCallHistoryItem(data)) { return ( ); } if (isSuccess && isExternalCallHistoryItem(data)) { return ; } return ( {t('Call_info')} ); }; export default MediaCallHistoryContextualbar;