From 109c5252624a5bd1e59fe366efc178091ab68ee4 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Tue, 26 Apr 2022 13:08:56 -0400 Subject: [PATCH] refactor: `omnichannelPermissions` to object --- app/stacks/types.ts | 6 +++++- app/views/RoomActionsView/index.tsx | 13 ++++++++----- app/views/RoomView/RightButtons.tsx | 10 ++++++---- app/views/RoomView/index.tsx | 6 +++--- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/stacks/types.ts b/app/stacks/types.ts index 44732412e..15902f18a 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -42,7 +42,11 @@ export type ChatsStackParamList = { rid: string; t: SubscriptionType; joined: boolean; - omnichannelPermissions: boolean[]; + omnichannelPermissions: { + canForwardGuest: boolean; + canReturnQueue: boolean; + canViewCannedResponse: boolean; + }; }; SelectListView: { data?: IRoom[]; diff --git a/app/views/RoomActionsView/index.tsx b/app/views/RoomActionsView/index.tsx index cdf252908..5ff1c8c4e 100644 --- a/app/views/RoomActionsView/index.tsx +++ b/app/views/RoomActionsView/index.tsx @@ -61,7 +61,6 @@ interface IRoomActionsViewProps extends IBaseScreen; private subscription?: Subscription; @@ -967,7 +970,7 @@ class RoomActionsView extends React.Component - {this.omnichannelPermissions[0] ? ( + {this.omnichannelPermissions.canForwardGuest ? ( <> ) : null} - {this.omnichannelPermissions[1] ? ( + {this.omnichannelPermissions.canReturnQueue ? ( <> ) : null} - {['l'].includes(t) && !this.isOmnichannelPreview && this.omnichannelPermissions[2] ? ( + {['l'].includes(t) && !this.isOmnichannelPreview && this.omnichannelPermissions.canViewCannedResponse ? ( <> ; - omnichannelPermissions: boolean[]; // TODO: Update to proper type + omnichannelPermissions: { + canForwardGuest: boolean; + canReturnQueue: boolean; + }; } interface IRigthButtonsState { @@ -194,7 +197,6 @@ class RightButtonsContainer extends Component { const { dispatch, rid } = this.props; - dispatch(closeRoom(rid)); }; @@ -203,7 +205,7 @@ class RightButtonsContainer extends Component { numIconsRight = 3; } const headerTitlePosition = getHeaderTitlePosition({ insets, numIconsRight }); - const omnichannelPermissions = [canForwardGuest, canReturnQueue]; + const omnichannelPermissions = { canForwardGuest, canReturnQueue }; navigation.setOptions({ headerShown: true, headerTitleAlign: 'left', @@ -593,7 +593,7 @@ class RoomView extends React.Component { member, showCloseModal: !!screen, joined, - omnichannelPermissions: [canForwardGuest, canReturnQueue, canViewCannedResponse] + omnichannelPermissions: { canForwardGuest, canReturnQueue, canViewCannedResponse } } }); } else if (this.rid && this.t) { @@ -603,7 +603,7 @@ class RoomView extends React.Component { room: room as TSubscriptionModel, member, joined, - omnichannelPermissions: [canForwardGuest, canReturnQueue, canViewCannedResponse] + omnichannelPermissions: { canForwardGuest, canReturnQueue, canViewCannedResponse } }); } };