diff --git a/app/containers/ActionSheet/Item.tsx b/app/containers/ActionSheet/Item.tsx index c29025b81..2b0b50080 100644 --- a/app/containers/ActionSheet/Item.tsx +++ b/app/containers/ActionSheet/Item.tsx @@ -2,20 +2,14 @@ import React from 'react'; import { Text, View } from 'react-native'; import { themes } from '../../lib/constants'; -import { CustomIcon, TIconsName } from '../CustomIcon'; +import { CustomIcon } from '../CustomIcon'; import { useTheme } from '../../theme'; import { Button } from './Button'; +import { TActionSheetOptionsItem } from './Provider'; import styles from './styles'; export interface IActionSheetItem { - item: { - title: string; - icon: TIconsName; - danger?: boolean; - testID?: string; - onPress: () => void; - right?: Function; - }; + item: TActionSheetOptionsItem; hide(): void; } diff --git a/app/containers/ActionSheet/Provider.tsx b/app/containers/ActionSheet/Provider.tsx index 4da84069c..8706dc95a 100644 --- a/app/containers/ActionSheet/Provider.tsx +++ b/app/containers/ActionSheet/Provider.tsx @@ -3,7 +3,14 @@ import React, { ForwardedRef, forwardRef, useContext, useRef } from 'react'; import ActionSheet from './ActionSheet'; import { TIconsName } from '../CustomIcon'; -export type TActionSheetOptionsItem = { title: string; icon: TIconsName; onPress: () => void; danger?: boolean }; +export type TActionSheetOptionsItem = { + title: string; + icon: TIconsName; + danger?: boolean; + testID?: string; + onPress: () => void; + right?: () => React.ReactElement; +}; export type TActionSheetOptions = { options: TActionSheetOptionsItem[]; diff --git a/app/lib/methods/helpers.ts b/app/lib/methods/helpers.ts index c31966e51..695b4a82b 100644 --- a/app/lib/methods/helpers.ts +++ b/app/lib/methods/helpers.ts @@ -85,7 +85,7 @@ export function hasRole(role): boolean { return userRoles.indexOf(role) > -1; } -export async function hasPermission(permissions, rid?: any) { +export async function hasPermission(permissions, rid?: any): boolean[] { let roomRoles = []; if (rid) { const db = database.active; diff --git a/app/stacks/MasterDetailStack/types.ts b/app/stacks/MasterDetailStack/types.ts index 00fa276a2..1edfff731 100644 --- a/app/stacks/MasterDetailStack/types.ts +++ b/app/stacks/MasterDetailStack/types.ts @@ -3,8 +3,7 @@ import { NavigatorScreenParams } from '@react-navigation/core'; import { IAttachment } from '../../definitions/IAttachment'; import { IMessage } from '../../definitions/IMessage'; -import { ISubscription, SubscriptionType } from '../../definitions/ISubscription'; -import { TRoomModel } from '../../definitions'; +import { ISubscription, SubscriptionType, TSubscriptionModel } from '../../definitions/ISubscription'; export type MasterDetailChatsStackParamList = { RoomView: { @@ -56,7 +55,7 @@ export type ModalStackParamList = { }; RoomMembersView: { rid: string; - room: TRoomModel; + room: TSubscriptionModel; }; DiscussionsView: { rid: string; diff --git a/app/views/LivechatEditView.tsx b/app/views/LivechatEditView.tsx index 5a4bf1a08..6fc475c17 100644 --- a/app/views/LivechatEditView.tsx +++ b/app/views/LivechatEditView.tsx @@ -66,7 +66,7 @@ const LivechatEditView = ({ }: ILivechatEditViewProps) => { const [customFields, setCustomFields] = useState({}); const [availableUserTags, setAvailableUserTags] = useState([]); - const [permissions, setPermissions] = useState([]); + const [permissions, setPermissions] = useState([]); const params = {} as TParams; const inputs = {} as IInputsRefs; diff --git a/app/views/RoomInfoEditView/index.tsx b/app/views/RoomInfoEditView/index.tsx index 462102793..31822ce27 100644 --- a/app/views/RoomInfoEditView/index.tsx +++ b/app/views/RoomInfoEditView/index.tsx @@ -43,7 +43,7 @@ import { Services } from '../../lib/services'; interface IRoomInfoEditViewState { room: ISubscription; avatar: IAvatar; - permissions: Record; + permissions: { [key in TSupportedPermissions]?: boolean }; name: string; description?: string; topic?: string; @@ -93,7 +93,7 @@ class RoomInfoEditView extends React.Component, + permissions: {}, name: '', description: '', topic: '', @@ -158,7 +158,6 @@ class RoomInfoEditView extends React.Component {}; // TODO: this work? + showActionSheet: (params: TActionSheetOptions) => {}; theme: TSupportedThemes; isMasterDetail: boolean; useRealName: boolean; @@ -64,14 +65,14 @@ interface IRoomMembersViewState { rid: string; members: TUserModel[]; membersFiltered: TUserModel[]; - room: TRoomModel; + room: TSubscriptionModel; end: boolean; } class RoomMembersView extends React.Component { private mounted: boolean; - private permissions: any; // TODO: fix when get props from api - private roomObservable!: Observable; + private permissions: { [key in TSupportedPermissions]?: boolean }; + private roomObservable!: Observable; private subscription!: Subscription; private roomRoles: any; @@ -88,7 +89,7 @@ class RoomMembersView extends React.Component