Chore: Evaluate LivechatEditView - TypeScript (#4125)
This commit is contained in:
parent
21a6fcee87
commit
83fb5ce7fb
|
@ -18,7 +18,7 @@ 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 { ICustomFields, IInputsRefs, TParams, ITitle, ILivechat } from '../definitions/ILivechatEditView';
|
import { ICustomFields, IInputsRefs, TParams, ITitle, ILivechat } from '../definitions/ILivechatEditView';
|
||||||
import { IApplicationState } from '../definitions';
|
import { IApplicationState, IUser } from '../definitions';
|
||||||
import { ChatsStackParamList } from '../stacks/types';
|
import { ChatsStackParamList } from '../stacks/types';
|
||||||
import sharedStyles from './Styles';
|
import sharedStyles from './Styles';
|
||||||
import { hasPermission } from '../lib/methods';
|
import { hasPermission } from '../lib/methods';
|
||||||
|
@ -44,8 +44,7 @@ const styles = StyleSheet.create({
|
||||||
});
|
});
|
||||||
|
|
||||||
interface ILivechatEditViewProps {
|
interface ILivechatEditViewProps {
|
||||||
// TODO: Refactor when migrate models
|
user: IUser;
|
||||||
user: any;
|
|
||||||
navigation: StackNavigationProp<ChatsStackParamList, 'LivechatEditView'>;
|
navigation: StackNavigationProp<ChatsStackParamList, 'LivechatEditView'>;
|
||||||
route: RouteProp<ChatsStackParamList, 'LivechatEditView'>;
|
route: RouteProp<ChatsStackParamList, 'LivechatEditView'>;
|
||||||
theme: TSupportedThemes;
|
theme: TSupportedThemes;
|
||||||
|
@ -102,7 +101,7 @@ const LivechatEditView = ({
|
||||||
|
|
||||||
const handleGetTagsList = async (agentDepartments: string[]) => {
|
const handleGetTagsList = async (agentDepartments: string[]) => {
|
||||||
const tags = await Services.getTagsList();
|
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
|
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))
|
||||||
.map(({ name }) => name);
|
.map(({ name }) => name);
|
||||||
|
|
Loading…
Reference in New Issue