@@ -32,40 +32,25 @@ function formatDuration(durationInMilliSeconds: number): string {
32
32
. substring ( 0 , 2 ) ;
33
33
return `${ minutes } :${ seconds } min` ;
34
34
}
35
+
35
36
export const getTextDescriptionForCallevent = (
36
37
callEvent : CallEvent ,
37
38
) : string => {
38
39
const date = new Date ( callEvent . startTime ) ;
39
40
const duration = formatDuration ( callEvent . endTime - callEvent . startTime ) ;
40
41
const directionInfo =
41
42
callEvent . direction === CallDirection . IN ? 'eingehender' : 'ausgehender' ;
42
- let callDescription : string ;
43
- if ( callEvent . direction === CallDirection . IN ) {
44
- callDescription = ` von ${
45
- callEvent . participants . find ( ( x ) => x . type == CallParticipantType . REMOTE )
46
- ?. phoneNumber
47
- } auf
48
- ${
49
- callEvent . participants . find ( ( x ) => x . type == CallParticipantType . LOCAL )
50
- ?. phoneNumber
51
- } `;
52
- } else {
53
- callDescription = ` von ${
54
- callEvent . participants . find ( ( x ) => x . type == CallParticipantType . LOCAL )
55
- ?. phoneNumber
56
- } auf
57
- ${
58
- callEvent . participants . find ( ( x ) => x . type == CallParticipantType . REMOTE )
59
- ?. phoneNumber
60
- } `;
61
- }
62
-
43
+ const { from, to } = getCallMembers ( callEvent ) ;
44
+ const fromDescription = from ? ` von ${ from } ` : '' ;
45
+ const toDescription = to ? ` auf ${ to } ` : '' ;
46
+ const callDescription = `${ fromDescription } ${ toDescription } ` ;
63
47
const callState =
64
48
callEvent . state === 'MISSED' ? 'Nicht angenommener ' : 'Angenommener' ;
65
49
const durationInfo =
66
50
callEvent . state === 'MISSED' ? '' : ` ,Dauer: ${ duration } ` ;
67
- return `${ callState } ${ directionInfo } Anruf ${ callDescription } am ${ date . toLocaleString (
51
+ const result = `${ callState } ${ directionInfo } Anruf ${ callDescription } am ${ date . toLocaleString (
68
52
'de' ,
69
53
{ timeZone : 'Europe/Berlin' } ,
70
54
) } ${ durationInfo } `;
55
+ return result ;
71
56
} ;
0 commit comments