Chore: Evaluate LivechatEditView - TypeScript (#4125)

This commit is contained in:
Reinaldo Neto 2022-05-02 22:19:28 -03:00 committed by GitHub
parent 21a6fcee87
commit 83fb5ce7fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -18,7 +18,7 @@ import Button from '../containers/Button';
import SafeAreaView from '../containers/SafeAreaView';
import { MultiSelect } from '../containers/UIKit/MultiSelect';
import { ICustomFields, IInputsRefs, TParams, ITitle, ILivechat } from '../definitions/ILivechatEditView';
import { IApplicationState } from '../definitions';
import { IApplicationState, IUser } from '../definitions';
import { ChatsStackParamList } from '../stacks/types';
import sharedStyles from './Styles';
import { hasPermission } from '../lib/methods';
@ -44,8 +44,7 @@ const styles = StyleSheet.create({
});
interface ILivechatEditViewProps {
// TODO: Refactor when migrate models
user: any;
user: IUser;
navigation: StackNavigationProp<ChatsStackParamList, 'LivechatEditView'>;
route: RouteProp<ChatsStackParamList, 'LivechatEditView'>;
theme: TSupportedThemes;
@ -102,7 +101,7 @@ const LivechatEditView = ({
const handleGetTagsList = async (agentDepartments: string[]) => {
const tags = await Services.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
.filter(({ departments }) => isAdmin || departments.length === 0 || departments.some(i => agentDepartments.indexOf(i) > -1))
.map(({ name }) => name);