From 679a628f751f3dd0437f2767e619ab138787a07d Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Tue, 8 Mar 2022 12:04:41 -0300 Subject: [PATCH] Chore: Migrate REST API - getAgentDepartments to Typescript (#3855) --- app/definitions/rest/v1/omnichannel.ts | 4 ++++ app/ee/omnichannel/lib/subscriptions/inquiry.ts | 3 +-- app/lib/rocketchat/services/restApi.ts | 4 +--- app/views/LivechatEditView.tsx | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/definitions/rest/v1/omnichannel.ts b/app/definitions/rest/v1/omnichannel.ts index c34963a5d..028b76d92 100644 --- a/app/definitions/rest/v1/omnichannel.ts +++ b/app/definitions/rest/v1/omnichannel.ts @@ -194,6 +194,10 @@ export type OmnichannelEndpoints = { }; }; + 'livechat/agents/:uid/departments?enabledDepartmentsOnly=true': { + GET: () => { departments: ILivechatDepartment[] }; + }; + 'canned-responses': { GET: (params: PaginatedRequest<{ scope?: string; departmentId?: string; text?: string }>) => PaginatedResult<{ cannedResponses: ICannedResponse[]; diff --git a/app/ee/omnichannel/lib/subscriptions/inquiry.ts b/app/ee/omnichannel/lib/subscriptions/inquiry.ts index 4201fb2a9..69953e378 100644 --- a/app/ee/omnichannel/lib/subscriptions/inquiry.ts +++ b/app/ee/omnichannel/lib/subscriptions/inquiry.ts @@ -3,7 +3,6 @@ import { store } from '../../../../lib/auxStore'; import RocketChat from '../../../../lib/rocketchat'; import { inquiryQueueAdd, inquiryQueueRemove, inquiryQueueUpdate, inquiryRequest } from '../../actions/inquiry'; import sdk from '../../../../lib/rocketchat/services/sdk'; -import { ILivechatDepartment } from '../../../../definitions/ILivechatDepartment'; import { IOmnichannelRoom } from '../../../../definitions'; interface IArgsQueueOmnichannel extends IOmnichannelRoom { @@ -82,7 +81,7 @@ export default function subscribeInquiry() { throw new Error('inquiry: @subscribeInquiry user.id not found'); } - RocketChat.getAgentDepartments(user.id).then((result: { success: boolean; departments: ILivechatDepartment[] }) => { + RocketChat.getAgentDepartments(user.id).then(result => { if (result.success) { const { departments } = result; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 825abed0d..e5a795b03 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -395,10 +395,8 @@ export const getTagsList = (): Promise< // RC 2.0.0 sdk.methodCallWrapper('livechat:getTagsList'); -export const getAgentDepartments = (uid: string): any => +export const getAgentDepartments = (uid: string) => // RC 2.4.0 - // TODO: missing definitions from server - // @ts-ignore sdk.get(`livechat/agents/${uid}/departments?enabledDepartmentsOnly=true`); export const getCustomFields = () => diff --git a/app/views/LivechatEditView.tsx b/app/views/LivechatEditView.tsx index 39e893e76..22dcada29 100644 --- a/app/views/LivechatEditView.tsx +++ b/app/views/LivechatEditView.tsx @@ -146,7 +146,7 @@ const LivechatEditView = ({ const getAgentDepartments = async () => { const result = await RocketChat.getAgentDepartments(visitor?._id); if (result.success) { - const agentDepartments = result.departments.map((dept: { departmentId: string }) => dept.departmentId); + const agentDepartments = result.departments.map(dept => dept.departmentId); getTagsList(agentDepartments); } };