Chore: Migrate REST API - getTagsList to Typescript (#3854)

This commit is contained in:
Reinaldo Neto 2022-03-07 23:30:13 -03:00 committed by GitHub
parent 8a01552b4b
commit 004f4ab0ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -1,5 +0,0 @@
export interface ITagsOmnichannel {
_id: string;
name: string;
departments: string[];
}

View File

@ -387,7 +387,13 @@ export const getRoutingConfig = (): Promise<{
// RC 2.0.0 // RC 2.0.0
sdk.methodCallWrapper('livechat:getRoutingConfig'); sdk.methodCallWrapper('livechat:getRoutingConfig');
export const getTagsList = () => export const getTagsList = (): Promise<
{
_id: string;
name: string;
departments: string[];
}[]
> =>
// RC 2.0.0 // RC 2.0.0
sdk.methodCallWrapper('livechat:getTagsList'); sdk.methodCallWrapper('livechat:getTagsList');

View File

@ -19,7 +19,6 @@ import Button from '../containers/Button';
import SafeAreaView from '../containers/SafeAreaView'; import SafeAreaView from '../containers/SafeAreaView';
import { MultiSelect } from '../containers/UIKit/MultiSelect'; import { MultiSelect } from '../containers/UIKit/MultiSelect';
import { ILivechatVisitor } from '../definitions/ILivechatVisitor'; import { ILivechatVisitor } from '../definitions/ILivechatVisitor';
import { ITagsOmnichannel } from '../definitions/ITagsOmnichannel';
import { IApplicationState, ISubscription } from '../definitions'; import { IApplicationState, ISubscription } from '../definitions';
import { ChatsStackParamList } from '../stacks/types'; import { ChatsStackParamList } from '../stacks/types';
import sharedStyles from './Styles'; import sharedStyles from './Styles';
@ -142,7 +141,7 @@ const LivechatEditView = ({
}, [availableUserTags]); }, [availableUserTags]);
const getTagsList = async (agentDepartments: string[]) => { const getTagsList = async (agentDepartments: string[]) => {
const tags: ITagsOmnichannel[] = await RocketChat.getTagsList(); const tags = await RocketChat.getTagsList();
const isAdmin = ['admin', 'livechat-manager'].find(role => user.roles.includes(role)); const isAdmin = ['admin', 'livechat-manager'].find(role => user.roles.includes(role));
const availableTags = tags const availableTags = tags
.filter(({ departments }) => isAdmin || departments.length === 0 || departments.some(i => agentDepartments.indexOf(i) > -1)) .filter(({ departments }) => isAdmin || departments.length === 0 || departments.some(i => agentDepartments.indexOf(i) > -1))