diff --git a/client/views/admin/settings/groups/voip/AssignAgentButton.tsx b/client/views/admin/settings/groups/voip/AssignAgentButton.tsx new file mode 100644 index 000000000000..da7ceadca952 --- /dev/null +++ b/client/views/admin/settings/groups/voip/AssignAgentButton.tsx @@ -0,0 +1,27 @@ +import { Table, Icon, Button } from '@rocket.chat/fuselage'; +import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; +import React, { FC } from 'react'; + +import { useSetModal } from '../../../../../contexts/ModalContext'; +import { useTranslation } from '../../../../../contexts/TranslationContext'; +import AssignAgentModal from './AssignAgentModal'; + +const AssignAgentButton: FC<{ extension: string; reload: () => void }> = ({ extension, reload }) => { + const t = useTranslation(); + const setModal = useSetModal(); + + const handleAssociation = useMutableCallback((e) => { + e.stopPropagation(); + setModal( setModal()} reload={reload} />); + }); + + return ( + + + + ); +}; + +export default AssignAgentButton; diff --git a/client/views/admin/settings/groups/voip/AssignAgentModal.tsx b/client/views/admin/settings/groups/voip/AssignAgentModal.tsx index ed83158cb6b7..d36f01f51f92 100644 --- a/client/views/admin/settings/groups/voip/AssignAgentModal.tsx +++ b/client/views/admin/settings/groups/voip/AssignAgentModal.tsx @@ -11,12 +11,13 @@ import { useEndpointData } from '../../../../../hooks/useEndpointData'; type AssignAgentModalParams = { closeModal: () => void; reload: () => void; + existingExtension?: string; }; -const AssignAgentModal: FC = ({ closeModal, reload }) => { +const AssignAgentModal: FC = ({ existingExtension, closeModal, reload }) => { const t = useTranslation(); const [agent, setAgent] = useState(''); - const [extension, setExtension] = useState(''); + const [extension, setExtension] = useState(existingExtension || ''); const query = useMemo(() => ({ type: 'available' as const, userId: agent }), [agent]); const assignAgent = useEndpoint('POST', 'omnichannel/agent/extension'); diff --git a/client/views/admin/settings/groups/voip/RemoveAgentButton.tsx b/client/views/admin/settings/groups/voip/RemoveAgentButton.tsx index 8cfbc24653a4..2aaf1aad0e4e 100644 --- a/client/views/admin/settings/groups/voip/RemoveAgentButton.tsx +++ b/client/views/admin/settings/groups/voip/RemoveAgentButton.tsx @@ -17,7 +17,7 @@ const RemoveAgentButton: FC<{ username: string; reload: () => void }> = ({ usern const handleRemoveClick = useMutableCallback(async () => { try { await removeAgent({ username }); - } catch (error) { + } catch (error: any) { dispatchToastMessage({ type: 'error', message: error }); } reload(); @@ -29,7 +29,7 @@ const RemoveAgentButton: FC<{ username: string; reload: () => void }> = ({ usern try { await handleRemoveClick(); dispatchToastMessage({ type: 'success', message: t('Agent_removed') }); - } catch (error) { + } catch (error: any) { dispatchToastMessage({ type: 'error', message: error }); } setModal(); @@ -48,7 +48,7 @@ const RemoveAgentButton: FC<{ username: string; reload: () => void }> = ({ usern return ( - diff --git a/client/views/admin/settings/groups/voip/VoipExtensionsPage.tsx b/client/views/admin/settings/groups/voip/VoipExtensionsPage.tsx index 4d785d1fd658..7937f1c93ff2 100644 --- a/client/views/admin/settings/groups/voip/VoipExtensionsPage.tsx +++ b/client/views/admin/settings/groups/voip/VoipExtensionsPage.tsx @@ -4,9 +4,11 @@ import React, { FC, useMemo, useCallback, useState } from 'react'; import GenericTable from '../../../../../components/GenericTable'; import Page from '../../../../../components/Page'; +import UserAvatar from '../../../../../components/avatar/UserAvatar'; import { useSetModal } from '../../../../../contexts/ModalContext'; import { useTranslation } from '../../../../../contexts/TranslationContext'; import { useEndpointData } from '../../../../../hooks/useEndpointData'; +import AssignAgentButton from './AssignAgentButton'; import AssignAgentModal from './AssignAgentModal'; import RemoveAgentButton from './RemoveAgentButton'; @@ -51,10 +53,25 @@ const VoipExtensionsPage: FC = () => { ); const renderRow = useCallback( - ({ _id, extension, username, state, queues }) => ( + ({ _id, extension, username, name, state, queues }) => ( {extension} - {username || t('Unassigned')} + + {username ? ( + + + + + + {name || username} + + + + + ) : ( + t('Free') + )} + {state} @@ -69,7 +86,7 @@ const VoipExtensionsPage: FC = () => { {queues?.length > 2 && `+${(queues.length - 2).toString()}`} - {username ? : null} + {username ? : } ), [reload, t], diff --git a/definition/IVoipExtension.ts b/definition/IVoipExtension.ts index 912884e52eb3..69253336dfe3 100644 --- a/definition/IVoipExtension.ts +++ b/definition/IVoipExtension.ts @@ -18,6 +18,7 @@ export interface IVoipExtensionWithAgentInfo extends IVoipExtensionBase { queues?: string[]; userId?: IUser['_id']; username?: IUser['username']; + name?: IUser['name']; } export const isIVoipExtensionBase = (obj: any): obj is IVoipExtensionBase => diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 0d66c20af5d4..09d371da645d 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -3552,6 +3552,7 @@ "Reload_Pages": "Reload Pages", "Remove": "Remove", "Remove_Admin": "Remove Admin", + "Remove_Association": "Remove Association", "Remove_as_leader": "Remove as leader", "Remove_as_moderator": "Remove as moderator", "Remove_as_owner": "Remove as owner", diff --git a/server/services/omnichannel-voip/service.ts b/server/services/omnichannel-voip/service.ts index 64eed95aee05..d298b3b2d325 100644 --- a/server/services/omnichannel-voip/service.ts +++ b/server/services/omnichannel-voip/service.ts @@ -361,6 +361,7 @@ export class OmnichannelVoipService extends ServiceClassInternal implements IOmn extension: 1, _id: 1, username: 1, + name: 1, }); return (extensions as unknown as IVoipExtensionBase[]).map((ext) => { @@ -368,6 +369,7 @@ export class OmnichannelVoipService extends ServiceClassInternal implements IOmn return { userId: user?._id, username: user?.username, + name: user?.name, queues: this.getQueuesForExt(ext.extension, summary), ...ext, };