refactor: `omnichannelPermissions` to object
This commit is contained in:
parent
e49ba5e1c5
commit
109c525262
|
@ -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[];
|
||||
|
|
|
@ -61,7 +61,6 @@ interface IRoomActionsViewProps extends IBaseScreen<ChatsStackParamList, 'RoomAc
|
|||
createTeamPermission?: string[];
|
||||
addTeamChannelPermission?: string[];
|
||||
convertTeamPermission?: string[];
|
||||
omnichannelPermissions: string[];
|
||||
}
|
||||
|
||||
interface IRoomActionsViewState {
|
||||
|
@ -85,7 +84,11 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
|||
private rid: string;
|
||||
private t: string;
|
||||
private joined: boolean;
|
||||
private omnichannelPermissions: boolean[];
|
||||
private omnichannelPermissions: {
|
||||
canForwardGuest: boolean;
|
||||
canReturnQueue: boolean;
|
||||
canViewCannedResponse: boolean;
|
||||
};
|
||||
private roomObservable?: Observable<TSubscriptionModel>;
|
||||
private subscription?: Subscription;
|
||||
|
||||
|
@ -967,7 +970,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
|||
|
||||
return (
|
||||
<List.Section>
|
||||
{this.omnichannelPermissions[0] ? (
|
||||
{this.omnichannelPermissions.canForwardGuest ? (
|
||||
<>
|
||||
<List.Item
|
||||
title='Forward'
|
||||
|
@ -984,7 +987,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
|||
</>
|
||||
) : null}
|
||||
|
||||
{this.omnichannelPermissions[1] ? (
|
||||
{this.omnichannelPermissions.canReturnQueue ? (
|
||||
<>
|
||||
<List.Item
|
||||
title='Return'
|
||||
|
@ -1109,7 +1112,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
|||
</>
|
||||
) : null}
|
||||
|
||||
{['l'].includes(t) && !this.isOmnichannelPreview && this.omnichannelPermissions[2] ? (
|
||||
{['l'].includes(t) && !this.isOmnichannelPreview && this.omnichannelPermissions.canViewCannedResponse ? (
|
||||
<>
|
||||
<List.Item
|
||||
title='Canned_Responses'
|
||||
|
|
|
@ -34,7 +34,10 @@ interface IRightButtonsProps {
|
|||
showActionSheet: Function; // TODO: Change to proper type
|
||||
transferLivechatGuestPermission: boolean;
|
||||
navigation: StackNavigationProp<ChatsStackParamList, 'RoomView'>;
|
||||
omnichannelPermissions: boolean[]; // TODO: Update to proper type
|
||||
omnichannelPermissions: {
|
||||
canForwardGuest: boolean;
|
||||
canReturnQueue: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface IRigthButtonsState {
|
||||
|
@ -194,7 +197,6 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
|||
|
||||
closeLivechat = () => {
|
||||
const { dispatch, rid } = this.props;
|
||||
|
||||
dispatch(closeRoom(rid));
|
||||
};
|
||||
|
||||
|
@ -203,7 +205,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
|||
const { showActionSheet, rid, navigation, omnichannelPermissions } = this.props;
|
||||
|
||||
const options = [];
|
||||
if (omnichannelPermissions[0]) {
|
||||
if (omnichannelPermissions.canForwardGuest) {
|
||||
options.push({
|
||||
title: i18n.t('Forward_Chat'),
|
||||
icon: 'chat-forward',
|
||||
|
@ -211,7 +213,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
|||
});
|
||||
}
|
||||
|
||||
if (omnichannelPermissions[1]) {
|
||||
if (omnichannelPermissions.canReturnQueue) {
|
||||
options.push({
|
||||
title: i18n.t('Return_to_waiting_line'),
|
||||
icon: 'move-to-the-queue',
|
||||
|
|
|
@ -518,7 +518,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
|||
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<IRoomViewProps, IRoomViewState> {
|
|||
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<IRoomViewProps, IRoomViewState> {
|
|||
room: room as TSubscriptionModel,
|
||||
member,
|
||||
joined,
|
||||
omnichannelPermissions: [canForwardGuest, canReturnQueue, canViewCannedResponse]
|
||||
omnichannelPermissions: { canForwardGuest, canReturnQueue, canViewCannedResponse }
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue