Skip to content

Commit

Permalink
Chore: Migrate REST API - getAgentDepartments to Typescript (#3855)
Browse files Browse the repository at this point in the history
  • Loading branch information
reinaldonetof authored Mar 8, 2022
1 parent c758fa5 commit 679a628
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/definitions/rest/v1/omnichannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
3 changes: 1 addition & 2 deletions app/ee/omnichannel/lib/subscriptions/inquiry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions app/lib/rocketchat/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () =>
Expand Down
2 changes: 1 addition & 1 deletion app/views/LivechatEditView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand Down

0 comments on commit 679a628

Please sign in to comment.