-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPROVE] Added identification on calls to/from existing contacts (#2…
…6334) Co-authored-by: Kevin Aleman <11577696+KevLehman@users.noreply.github.com> Co-authored-by: Murtaza Patrawala <34130764+murtaza98@users.noreply.github.com> Co-authored-by: Guilherme Gazzo <5263975+ggazzo@users.noreply.github.com>
- Loading branch information
1 parent
68bc2ae
commit 10932a5
Showing
20 changed files
with
153 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
apps/meteor/client/sidebar/footer/voip/hooks/useOmnichannelContactLabel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ICallerInfo } from '@rocket.chat/core-typings'; | ||
import { useEndpoint } from '@rocket.chat/ui-contexts'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { parseOutboundPhoneNumber } from '../../../../../ee/client/lib/voip/parseOutboundPhoneNumber'; | ||
|
||
export const useOmnichannelContactLabel = (caller: ICallerInfo): string => { | ||
const getContactBy = useEndpoint('GET', '/v1/omnichannel/contact.search'); | ||
const phone = parseOutboundPhoneNumber(caller.callerId); | ||
|
||
const { data } = useQuery(['getContactsByPhone', phone], async () => getContactBy({ phone }).then(({ contact }) => contact), { | ||
enabled: !!phone, | ||
}); | ||
|
||
return data?.name || caller.callerName || phone; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
apps/meteor/client/views/omnichannel/directory/calls/CallTableRow.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { IVoipRoom } from '@rocket.chat/core-typings'; | ||
import { Table } from '@rocket.chat/fuselage'; | ||
import { useTranslation } from '@rocket.chat/ui-contexts'; | ||
import moment from 'moment'; | ||
import React, { ReactElement, useCallback } from 'react'; | ||
|
||
import { parseOutboundPhoneNumber } from '../../../../../ee/client/lib/voip/parseOutboundPhoneNumber'; | ||
import { useIsCallReady } from '../../../../contexts/CallContext'; | ||
import { CallDialpadButton } from '../CallDialpadButton'; | ||
|
||
type CallTableRowProps = { | ||
room: IVoipRoom; | ||
onRowClick(_id: string, token?: string): void; | ||
}; | ||
|
||
export const CallTableRow = ({ room, onRowClick }: CallTableRowProps): ReactElement => { | ||
const t = useTranslation(); | ||
const isCallReady = useIsCallReady(); | ||
|
||
const { _id, fname, callStarted, queue, callDuration = 0, v, direction } = room; | ||
const duration = moment.duration(callDuration / 1000, 'seconds'); | ||
const phoneNumber = Array.isArray(v?.phone) ? v?.phone[0]?.phoneNumber : v?.phone; | ||
|
||
const resolveDirectionLabel = useCallback( | ||
(direction: IVoipRoom['direction']) => { | ||
const labels = { | ||
inbound: 'Incoming', | ||
outbound: 'Outgoing', | ||
} as const; | ||
return t(labels[direction] || 'Not_Available'); | ||
}, | ||
[t], | ||
); | ||
|
||
return ( | ||
<Table.Row | ||
key={_id} | ||
rcx-show-call-button-on-hover | ||
tabIndex={0} | ||
role='link' | ||
onClick={(): void => onRowClick(_id, v?.token)} | ||
action | ||
qa-user-id={_id} | ||
height='40px' | ||
> | ||
<Table.Cell withTruncatedText>{parseOutboundPhoneNumber(fname)}</Table.Cell> | ||
<Table.Cell withTruncatedText>{parseOutboundPhoneNumber(phoneNumber)}</Table.Cell> | ||
<Table.Cell withTruncatedText>{queue}</Table.Cell> | ||
<Table.Cell withTruncatedText>{moment(callStarted).format('L LTS')}</Table.Cell> | ||
<Table.Cell withTruncatedText>{duration.isValid() && duration.humanize()}</Table.Cell> | ||
<Table.Cell withTruncatedText>{resolveDirectionLabel(direction)}</Table.Cell> | ||
<Table.Cell>{isCallReady && <CallDialpadButton phoneNumber={phoneNumber} />}</Table.Cell> | ||
</Table.Row> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.