2021-06-03 16:23:18 +00:00
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { TouchableOpacity, View } from 'react-native';
|
2021-07-30 09:46:49 +00:00
|
|
|
import { Text } from 'react-native-paper';
|
2021-07-06 19:07:52 +00:00
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
2021-06-03 16:23:18 +00:00
|
|
|
|
|
|
|
import { Avatar } from '../../../base/avatar';
|
|
|
|
import BottomSheet from '../../../base/dialog/components/native/BottomSheet';
|
|
|
|
import {
|
2022-11-08 10:24:32 +00:00
|
|
|
Icon, IconCloseLarge
|
2021-06-03 16:23:18 +00:00
|
|
|
} from '../../../base/icons';
|
|
|
|
import { setKnockingParticipantApproval } from '../../../lobby/actions.native';
|
2021-07-06 19:07:52 +00:00
|
|
|
import { getKnockingParticipantsById } from '../../../lobby/functions';
|
2021-06-03 16:23:18 +00:00
|
|
|
|
|
|
|
import styles from './styles';
|
2022-06-20 14:53:19 +00:00
|
|
|
|
2021-06-03 16:23:18 +00:00
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Participant reference.
|
2021-06-03 16:23:18 +00:00
|
|
|
*/
|
|
|
|
participant: Object
|
|
|
|
};
|
|
|
|
|
2021-07-13 13:17:20 +00:00
|
|
|
const ContextMenuLobbyParticipantReject = ({ participant: p }: Props) => {
|
2021-06-03 16:23:18 +00:00
|
|
|
const dispatch = useDispatch();
|
2021-07-06 19:07:52 +00:00
|
|
|
const knockParticipantsIDArr = useSelector(getKnockingParticipantsById);
|
|
|
|
const knockParticipantIsAvailable = knockParticipantsIDArr.find(knockPartId => knockPartId === p.id);
|
2021-06-03 16:23:18 +00:00
|
|
|
const displayName = p.name;
|
|
|
|
const reject = useCallback(() => dispatch(setKnockingParticipantApproval(p.id, false), [ dispatch ]));
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
2021-07-30 09:46:49 +00:00
|
|
|
// eslint-disable-next-line react/no-multi-comp
|
|
|
|
const renderMenuHeader = () => (
|
|
|
|
<View
|
|
|
|
style = { styles.contextMenuItemSectionAvatar }>
|
|
|
|
<Avatar
|
|
|
|
participantId = { p.id }
|
|
|
|
size = { 24 } />
|
|
|
|
<Text style = { styles.contextMenuItemName }>
|
|
|
|
{ displayName }
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
|
2021-06-03 16:23:18 +00:00
|
|
|
return (
|
|
|
|
<BottomSheet
|
2021-07-06 19:07:52 +00:00
|
|
|
addScrollViewPadding = { false }
|
2021-07-30 09:46:49 +00:00
|
|
|
/* eslint-disable-next-line react/jsx-no-bind */
|
|
|
|
renderHeader = { renderMenuHeader }
|
2021-07-06 19:07:52 +00:00
|
|
|
showSlidingView = { Boolean(knockParticipantIsAvailable) }
|
2021-06-03 16:23:18 +00:00
|
|
|
style = { styles.contextMenuMore }>
|
|
|
|
<TouchableOpacity
|
|
|
|
onPress = { reject }
|
2021-06-04 15:07:18 +00:00
|
|
|
style = { styles.contextMenuItem }>
|
2021-06-03 16:23:18 +00:00
|
|
|
<Icon
|
2021-07-30 09:46:49 +00:00
|
|
|
size = { 24 }
|
2022-11-08 10:24:32 +00:00
|
|
|
src = { IconCloseLarge } />
|
2021-06-03 16:23:18 +00:00
|
|
|
<Text style = { styles.contextMenuItemText }>{ t('lobby.reject') }</Text>
|
|
|
|
</TouchableOpacity>
|
|
|
|
</BottomSheet>
|
|
|
|
);
|
|
|
|
};
|
2021-07-13 13:17:20 +00:00
|
|
|
|
|
|
|
export default ContextMenuLobbyParticipantReject;
|