// Copyright 2024 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import classNames from 'classnames'; import type { CallStatus } from '../../../types/CallDisposition'; import { CallDirection, CallType, DirectCallStatus, GroupCallStatus, type CallHistoryGroup, } from '../../../types/CallDisposition'; import type { LocalizerType } from '../../../types/I18N'; import { formatDate, formatTime } from '../../../util/timestamp'; import { PanelSection } from './PanelSection'; function describeCallHistory( i18n: LocalizerType, type: CallType, direction: CallDirection, status: CallStatus ): string { if (type === CallType.Adhoc) { return i18n('icu:CallHistory__Description--Adhoc'); } if (status === DirectCallStatus.Missed || status === GroupCallStatus.Missed) { if (direction === CallDirection.Incoming) { return i18n('icu:CallHistory__Description--Missed', { type }); } return i18n('icu:CallHistory__Description--Unanswered', { type }); } if ( status === DirectCallStatus.Declined || status === GroupCallStatus.Declined ) { return i18n('icu:CallHistory__Description--Declined', { type }); } return i18n('icu:CallHistory__Description--Default', { type, direction }); } export type CallHistoryPanelSectionProps = Readonly<{ callHistoryGroup: CallHistoryGroup; i18n: LocalizerType; }>; export function CallHistoryGroupPanelSection({ callHistoryGroup, i18n, }: CallHistoryPanelSectionProps): JSX.Element { return (
    {callHistoryGroup.children.map(child => { return (
  1. {describeCallHistory( i18n, callHistoryGroup.type, callHistoryGroup.direction, callHistoryGroup.status )} {formatTime(i18n, child.timestamp, Date.now(), false)}
  2. ); })}
); }