import { formatDuration } from '@ringcentral-integration/commons/lib/formatDuration';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import dynamicsFont from '../../assets/DynamicsFont/DynamicsFont.scss';
import Spinner from '../Spinner';
import i18n from './i18n';
import styles from './styles.scss';
function getCurrentStatus({ direction, result }: any, currentLocale: any) {
if (direction === 'Inbound') {
if (result === 'Missed') {
return {
status: i18n.getString('missed', currentLocale),
icon: dynamicsFont.missed,
isMissedCall: true,
};
}
return {
status: i18n.getString('inBound', currentLocale),
icon: dynamicsFont.inbound,
};
}
return {
status: i18n.getString('outBound', currentLocale),
icon: dynamicsFont.outbound,
};
}
const CallItem = ({ call, dateTimeFormatter, currentLocale }: any) => {
let { duration, startTime } = call;
const { status, icon, isMissedCall } = getCurrentStatus(call, currentLocale);
startTime = dateTimeFormatter({
utcTimestamp: new Date(startTime).getTime(),
});
duration = formatDuration(duration);
return (
-
{status}
{duration}
-
{startTime}
);
};
CallItem.propTypes = {
call: PropTypes.object.isRequired,
dateTimeFormatter: PropTypes.func.isRequired,
currentLocale: PropTypes.string.isRequired,
};
class RecentActivityCalls extends Component {
// @ts-expect-error TS(4114): This member must have an 'override' modifier becau... Remove this comment to see the full error message
shouldComponentUpdate(nextProps: any) {
return (
// @ts-expect-error TS(2339): Property 'currentLocale' does not exist on type 'R... Remove this comment to see the full error message
nextProps.currentLocale !== this.props.currentLocale ||
// @ts-expect-error TS(2339): Property 'calls' does not exist on type 'Readonly<... Remove this comment to see the full error message
nextProps.calls !== this.props.calls ||
// @ts-expect-error TS(2339): Property 'isCallsLoaded' does not exist on type 'R... Remove this comment to see the full error message
nextProps.isCallsLoaded !== this.props.isCallsLoaded
);
}
// @ts-expect-error TS(4114): This member must have an 'override' modifier becau... Remove this comment to see the full error message
render() {
// @ts-expect-error TS(2339): Property 'currentLocale' does not exist on type 'R... Remove this comment to see the full error message
const { currentLocale, calls, isCallsLoaded, dateTimeFormatter } =
this.props;
let callListView = null;
if (!isCallsLoaded) {
callListView = ;
} else if (calls.length > 0) {
callListView = calls.map((call: any) => (
));
} else {
callListView = (
{i18n.getString('noRecords', currentLocale)}
);
}
return {callListView}
;
}
}
// @ts-expect-error TS(2339): Property 'propTypes' does not exist on type 'typeo... Remove this comment to see the full error message
RecentActivityCalls.propTypes = {
currentLocale: PropTypes.string.isRequired,
calls: PropTypes.array.isRequired,
isCallsLoaded: PropTypes.bool.isRequired,
dateTimeFormatter: PropTypes.func.isRequired,
};
export default RecentActivityCalls;