From 9becdf564e37317c378a930648bda8ab3395f96e Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Tue, 8 Mar 2022 11:30:45 -0300 Subject: [PATCH] Chore: Migrate REST API - getListCannedResponse to Typescript (#3858) --- app/containers/MessageBox/index.tsx | 2 +- app/definitions/rest/v1/omnichannel.ts | 7 +++++++ app/lib/rocketchat/services/restApi.ts | 4 +--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/containers/MessageBox/index.tsx b/app/containers/MessageBox/index.tsx index 2143eb630..7ef49227a 100644 --- a/app/containers/MessageBox/index.tsx +++ b/app/containers/MessageBox/index.tsx @@ -609,7 +609,7 @@ class MessageBox extends Component { getCannedResponses = debounce(async (text?: string) => { const res = await RocketChat.getListCannedResponse({ text }); - this.setState({ mentions: res?.cannedResponses || [], mentionLoading: false }); + this.setState({ mentions: res.success ? res.cannedResponses : [], mentionLoading: false }); }, 500); focus = () => { diff --git a/app/definitions/rest/v1/omnichannel.ts b/app/definitions/rest/v1/omnichannel.ts index 7b5dcb64d..4d2350c92 100644 --- a/app/definitions/rest/v1/omnichannel.ts +++ b/app/definitions/rest/v1/omnichannel.ts @@ -1,3 +1,4 @@ +import { ICannedResponse } from '../../ICannedResponse'; import { ILivechatAgent } from '../../ILivechatAgent'; import { ILivechatDepartment } from '../../ILivechatDepartment'; import { ILivechatDepartmentAgents } from '../../ILivechatDepartmentAgents'; @@ -190,4 +191,10 @@ export type OmnichannelEndpoints = { total: number; }; }; + + 'canned-responses': { + GET: (params: PaginatedRequest<{ scope?: string; departmentId?: string; text?: string }>) => PaginatedResult<{ + cannedResponses: ICannedResponse[]; + }>; + }; }; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 0f66e9609..825abed0d 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -405,7 +405,7 @@ export const getCustomFields = () => // RC 2.2.0 sdk.get('livechat/custom-fields'); -export const getListCannedResponse = ({ scope = '', departmentId = '', offset = 0, count = 25, text = '' }): any => { +export const getListCannedResponse = ({ scope = '', departmentId = '', offset = 0, count = 25, text = '' }) => { const params = { offset, count, @@ -415,8 +415,6 @@ export const getListCannedResponse = ({ scope = '', departmentId = '', offset = }; // RC 3.17.0 - // TODO: missing definitions from server - // @ts-ignore return sdk.get('canned-responses', params); };