diff --git a/apps/meteor/app/livechat/imports/server/rest/rooms.ts b/apps/meteor/app/livechat/imports/server/rest/rooms.ts index f7d5ddb314c9..8d2a80c92a02 100644 --- a/apps/meteor/app/livechat/imports/server/rest/rooms.ts +++ b/apps/meteor/app/livechat/imports/server/rest/rooms.ts @@ -30,7 +30,7 @@ API.v1.addRoute( async get() { const { offset, count } = await getPaginationItems(this.queryParams); const { sort, fields } = await this.parseJsonQuery(); - const { agents, departmentId, open, tags, roomName, onhold } = this.queryParams; + const { agents, departmentId, open, tags, roomName, onhold, verificationStatus } = this.queryParams; const { createdAt, customFields, closedAt } = this.queryParams; const createdAtParam = validateDateParams('createdAt', createdAt); @@ -63,6 +63,7 @@ API.v1.addRoute( agents, roomName, departmentId, + verificationStatus, ...(isBoolean(open) && { open: open === 'true' }), createdAt: createdAtParam, closedAt: closedAtParam, diff --git a/apps/meteor/app/livechat/server/api/lib/rooms.ts b/apps/meteor/app/livechat/server/api/lib/rooms.ts index b130e5c2c73a..bb4bb7783ca6 100644 --- a/apps/meteor/app/livechat/server/api/lib/rooms.ts +++ b/apps/meteor/app/livechat/server/api/lib/rooms.ts @@ -8,6 +8,7 @@ export async function findRooms({ agents, roomName, departmentId, + verificationStatus, open, createdAt, closedAt, @@ -19,6 +20,7 @@ export async function findRooms({ agents?: Array; roomName?: string; departmentId?: string; + verificationStatus?: IOmnichannelRoom['verificationStatus']; open?: boolean; createdAt?: { start?: string | undefined; @@ -42,6 +44,7 @@ export async function findRooms({ createdAt, closedAt, tags, + verificationStatus, customFields, onhold: ['t', 'true', '1'].includes(`${onhold}`), options: { diff --git a/apps/meteor/client/views/omnichannel/currentChats/CurrentChatsRoute.tsx b/apps/meteor/client/views/omnichannel/currentChats/CurrentChatsRoute.tsx index a8694fca5c35..ec801ce21ed3 100644 --- a/apps/meteor/client/views/omnichannel/currentChats/CurrentChatsRoute.tsx +++ b/apps/meteor/client/views/omnichannel/currentChats/CurrentChatsRoute.tsx @@ -1,3 +1,4 @@ +import { RoomVerificationState } from '@rocket.chat/core-typings'; import { Pagination } from '@rocket.chat/fuselage'; import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; import type { GETLivechatRoomsParams } from '@rocket.chat/rest-typings'; @@ -37,6 +38,7 @@ type DebouncedParams = { department: string; status: string; from: string; + verificationStatus: RoomVerificationState; to: string; tags: any[]; }; @@ -47,6 +49,7 @@ type CurrentChatQuery = { roomName?: string; departmentId?: string; open?: boolean; + verificationStatus?: RoomVerificationState; createdAt?: string; closedAt?: string; tags?: string[]; @@ -67,7 +70,7 @@ type useQueryType = ( const sortDir = (sortDir: 'asc' | 'desc'): 1 | -1 => (sortDir === 'asc' ? 1 : -1); const currentChatQuery: useQueryType = ( - { guest, servedBy, department, status, from, to, tags }, + { guest, servedBy, department, status, from, to, tags, verificationStatus }, customFields, [column, direction], current, @@ -93,6 +96,9 @@ const currentChatQuery: useQueryType = ( }), }); } + if (verificationStatus !== RoomVerificationState.all) { + query.verificationStatus = verificationStatus; + } if (status !== 'all') { query.open = status === 'opened' || status === 'onhold'; @@ -120,10 +126,9 @@ const currentChatQuery: useQueryType = ( }; const CurrentChatsRoute = (): ReactElement => { - const { sortBy, sortDirection, setSort } = useSort<'fname' | 'departmentId' | 'servedBy' | 'priorityWeight' | 'ts' | 'lm' | 'open'>( - 'ts', - 'desc', - ); + const { sortBy, sortDirection, setSort } = useSort< + 'fname' | 'departmentId' | 'servedBy' | 'priorityWeight' | 'ts' | 'lm' | 'open' | 'verifcationStatus' + >('ts', 'desc'); const [customFields, setCustomFields] = useState<{ [key: string]: string }>(); const t = useTranslation(); @@ -142,6 +147,7 @@ const CurrentChatsRoute = (): ReactElement => { guest: '', fname: '', servedBy: '', + verificationStatus: RoomVerificationState.all, status: 'all', department: '', from: '', diff --git a/apps/meteor/client/views/omnichannel/currentChats/FilterByText.tsx b/apps/meteor/client/views/omnichannel/currentChats/FilterByText.tsx index 0991b424b06b..da0416d33c8d 100644 --- a/apps/meteor/client/views/omnichannel/currentChats/FilterByText.tsx +++ b/apps/meteor/client/views/omnichannel/currentChats/FilterByText.tsx @@ -1,3 +1,4 @@ +import { RoomVerificationState } from '@rocket.chat/core-typings'; import { TextInput, Box, Select, InputBox } from '@rocket.chat/fuselage'; import { useMutableCallback, useLocalStorage } from '@rocket.chat/fuselage-hooks'; import { useSetModal, useToastMessageDispatch, useMethod, useTranslation } from '@rocket.chat/ui-contexts'; @@ -32,8 +33,15 @@ const FilterByText: FilterByTextType = ({ setFilter, reload, customFields, setCu ['onhold', t('On_Hold_Chats')], ]; + const verificationStatusOptions: [RoomVerificationState, string][] = [ + [RoomVerificationState.all, t('All')], + [RoomVerificationState.verified, t('Verified')], + [RoomVerificationState.unVerified, t('Unverified')], + ]; + const [guest, setGuest] = useLocalStorage('guest', ''); const [servedBy, setServedBy] = useLocalStorage('servedBy', 'all'); + const [verificationStatus, setVerificationStatus] = useLocalStorage('verificationStatus', 'all'); const [status, setStatus] = useLocalStorage('status', 'all'); const [department, setDepartment] = useLocalStorage('department', 'all'); const [from, setFrom] = useLocalStorage('from', ''); @@ -47,10 +55,12 @@ const FilterByText: FilterByTextType = ({ setFilter, reload, customFields, setCu const handleFrom = useMutableCallback((e) => setFrom(e.target.value)); const handleTo = useMutableCallback((e) => setTo(e.target.value)); const handleTags = useMutableCallback((e) => setTags(e)); + const handleVerificationStatus = useMutableCallback((e) => setVerificationStatus(e)); const reset = useMutableCallback(() => { setGuest(''); setServedBy('all'); + setVerificationStatus(RoomVerificationState.all); setStatus('all'); setDepartment('all'); setFrom(''); @@ -76,12 +86,13 @@ const FilterByText: FilterByTextType = ({ setFilter, reload, customFields, setCu servedBy, status, department: department && department !== 'all' ? department : '', + verificationStatus, from: from && moment(new Date(from)).utc().format('YYYY-MM-DDTHH:mm:ss'), to: to && moment(new Date(to)).utc().format('YYYY-MM-DDTHH:mm:ss'), tags: tags.map((tag) => tag.label), customFields, })); - }, [setFilter, guest, servedBy, status, department, from, to, tags, customFields]); + }, [setFilter, guest, servedBy, status, department, from, to, tags, customFields, verificationStatus]); const handleClearFilters = useMutableCallback(() => { reset(); @@ -140,11 +151,21 @@ const FilterByText: FilterByTextType = ({ setFilter, reload, customFields, setCu hasCustomFields={hasCustomFields} /> - + + + +