diff --git a/client/components/Omnichannel/Tags.js b/client/components/Omnichannel/Tags.js index 7372776a4832f..c66a8d77ebcfa 100644 --- a/client/components/Omnichannel/Tags.js +++ b/client/components/Omnichannel/Tags.js @@ -10,7 +10,7 @@ import { useEndpointData } from '../../hooks/useEndpointData'; import { formsSubscription } from '../../views/omnichannel/additionalForms'; import { FormSkeleton } from './Skeleton'; -const Tags = ({ tags = [], handler = () => {}, error = '' }) => { +const Tags = ({ tags = [], handler = () => {}, error = '', tagRequired = false }) => { const { value: tagsResult = [], phase: stateTags } = useEndpointData('livechat/tags.list'); const t = useTranslation(); const forms = useSubscription(formsSubscription); @@ -49,7 +49,9 @@ const Tags = ({ tags = [], handler = () => {}, error = '' }) => { return ( <> - {t('Tags')} + + {t('Tags')} + {Tags && tagsList && tagsList.length > 0 ? ( diff --git a/client/components/Omnichannel/modals/CloseChatModal.js b/client/components/Omnichannel/modals/CloseChatModal.js index 6543414603bba..0c63646b831b0 100644 --- a/client/components/Omnichannel/modals/CloseChatModal.js +++ b/client/components/Omnichannel/modals/CloseChatModal.js @@ -6,6 +6,7 @@ import { useSetting } from '../../../contexts/SettingsContext'; import { useTranslation } from '../../../contexts/TranslationContext'; import { useComponentDidUpdate } from '../../../hooks/useComponentDidUpdate'; import { useForm } from '../../../hooks/useForm'; +import GenericModal from '../../GenericModal'; import Tags from '../Tags'; const CloseChatModal = ({ department = {}, onCancel, onConfirm }) => { @@ -46,6 +47,19 @@ const CloseChatModal = ({ department = {}, onCancel, onConfirm }) => { ); }, [department, tagRequired, t, tags]); + if (!commentRequired && !tagRequired) { + return ( + + ); + } + return ( @@ -71,7 +85,7 @@ const CloseChatModal = ({ department = {}, onCancel, onConfirm }) => { {Tags && ( - + {tagError} )} diff --git a/client/views/omnichannel/directory/chats/contextualBar/ChatInfo.js b/client/views/omnichannel/directory/chats/contextualBar/ChatInfo.js index 31bb595340084..7f0bbd2e447c6 100644 --- a/client/views/omnichannel/directory/chats/contextualBar/ChatInfo.js +++ b/client/views/omnichannel/directory/chats/contextualBar/ChatInfo.js @@ -40,7 +40,7 @@ function ChatInfo({ id, route }) { ts, tags, closedAt, - department, + departmentId, v, servedBy, metrics, @@ -103,7 +103,7 @@ function ChatInfo({ id, route }) { {room && v && } {visitorId && } {servedBy && } - {department && } + {departmentId && } {tags && tags.length > 0 && ( diff --git a/client/views/room/Header/Header.js b/client/views/room/Header/Header.js index eab16b7743203..671651dc99943 100644 --- a/client/views/room/Header/Header.js +++ b/client/views/room/Header/Header.js @@ -28,7 +28,7 @@ const Header = ({ room }) => { } if (room.t === 'l') { - return ; + return ; } return ; diff --git a/client/views/room/Header/Omnichannel/OmnichannelRoomHeader.tsx b/client/views/room/Header/Omnichannel/OmnichannelRoomHeader.tsx index b978878841dc7..a40ba036957db 100644 --- a/client/views/room/Header/Omnichannel/OmnichannelRoomHeader.tsx +++ b/client/views/room/Header/Omnichannel/OmnichannelRoomHeader.tsx @@ -3,14 +3,16 @@ import React, { FC, useMemo } from 'react'; import TemplateHeader from '../../../../components/Header'; import { useLayout } from '../../../../contexts/LayoutContext'; import { useCurrentRoute } from '../../../../contexts/RouterContext'; +import { useOmnichannelRoom } from '../../contexts/RoomContext'; import Burger from '../Burger'; import RoomHeader, { RoomHeaderProps } from '../RoomHeader'; import BackButton from './BackButton'; import QuickActions from './QuickActions'; -const OmnichannelRoomHeader: FC = ({ room, slots: parentSlot }) => { +const OmnichannelRoomHeader: FC = ({ slots: parentSlot }) => { const [name] = useCurrentRoute(); const { isMobile } = useLayout(); + const room = useOmnichannelRoom(); const slots = useMemo( () => ({ ...parentSlot, diff --git a/client/views/room/contexts/RoomContext.ts b/client/views/room/contexts/RoomContext.ts index a58569fccf771..b9bc056cc7029 100644 --- a/client/views/room/contexts/RoomContext.ts +++ b/client/views/room/contexts/RoomContext.ts @@ -1,15 +1,24 @@ import { createContext, useContext } from 'react'; import { IRoom, IOmnichannelRoom, isOmnichannelRoom } from '../../../../definition/IRoom'; +import { IOmnichannelSubscription } from '../../../../definition/ISubscription'; export type RoomContextValue = { rid: IRoom['_id']; - room: IRoom; - // tabBar: TabBar; + room: IOmnichannelRoom & IOmnichannelSubscription; }; export const RoomContext = createContext(null); +const normalizeRoomSubscription = ( + room: IOmnichannelRoom & IOmnichannelSubscription, +): IOmnichannelRoom => { + if (room.department) { + room.departmentId = room.department; + } + return room; +}; + export const useRoom = (): IRoom => { const { room } = useContext(RoomContext) || {}; if (!room) { @@ -20,11 +29,13 @@ export const useRoom = (): IRoom => { export const useOmnichannelRoom = (): IOmnichannelRoom => { const { room } = useContext(RoomContext) || {}; + if (!room) { throw new Error('use useRoom only inside opened rooms'); } if (!isOmnichannelRoom(room)) { throw new Error('invalid room type'); } - return room; + + return normalizeRoomSubscription(room); }; diff --git a/client/views/room/providers/RoomProvider.tsx b/client/views/room/providers/RoomProvider.tsx index ada05e29c237a..d294608ff699b 100644 --- a/client/views/room/providers/RoomProvider.tsx +++ b/client/views/room/providers/RoomProvider.tsx @@ -1,7 +1,8 @@ import React, { ReactNode, useMemo, memo, useEffect } from 'react'; import { roomTypes } from '../../../../app/utils/client'; -import { IRoom } from '../../../../definition/IRoom'; +import { IRoom, IOmnichannelRoom } from '../../../../definition/IRoom'; +import { IOmnichannelSubscription } from '../../../../definition/ISubscription'; import { RoomManager, useHandleRoom } from '../../../lib/RoomManager'; import { AsyncStatePhase } from '../../../lib/asyncState'; import Skeleton from '../Room/Skeleton'; @@ -22,7 +23,8 @@ const RoomProvider = ({ rid, children }: Props): JSX.Element => { room._id = rid; return { rid, - room: { ...room, name: roomTypes.getRoomName(room.t, room) }, + room: { ...room, name: roomTypes.getRoomName(room.t, room) } as IOmnichannelRoom & + IOmnichannelSubscription, }; }, [room, rid]); diff --git a/definition/ISubscription.ts b/definition/ISubscription.ts index 019f22bcd433b..97100f7b5cbad 100644 --- a/definition/ISubscription.ts +++ b/definition/ISubscription.ts @@ -40,6 +40,10 @@ export interface ISubscription extends IRocketChatRecord { unreadAlert?: 'default' | 'all' | 'mentions' | 'nothing'; } +export interface IOmnichannelSubscription extends ISubscription { + department?: string; +} + export interface ISubscriptionDirectMessage extends Omit { t: 'd'; } diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 7be324f91653c..558998c09e6e5 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -523,6 +523,7 @@ "are_also_typing": "are also typing", "are_typing": "are typing", "Are_you_sure": "Are you sure?", + "Are_you_sure_you_want_to_close_this_chat": "Are you sure you want to close this chat?", "Are_you_sure_you_want_to_delete_this_record": "Are you sure you want to delete this record?", "Are_you_sure_you_want_to_delete_your_account": "Are you sure you want to delete your account?", "Are_you_sure_you_want_to_disable_Facebook_integration": "Are you sure you want to disable Facebook integration?", diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index 25ab6dc439d91..3066af01507c9 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -457,6 +457,7 @@ "are_also_typing": "também estão digitando", "are_typing": "estão digitando", "Are_you_sure": "Você tem certeza?", + "Are_you_sure_you_want_to_close_this_chat": "Tem certeza de que deseja fechar esta conversa?", "Are_you_sure_you_want_to_delete_this_record": "Tem certeza de que deseja remover este registro?", "Are_you_sure_you_want_to_delete_your_account": "Tem certeza de que deseja excluir a sua conta?", "Are_you_sure_you_want_to_disable_Facebook_integration": "Tem certeza de que deseja desabilitar a integração do Facebook?",