Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ContextMenuLobbyParticipantReject.tsx 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import React, { useCallback } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { TouchableOpacity, View, ViewStyle } from 'react-native';
  4. import { Text } from 'react-native-paper';
  5. import { useDispatch, useSelector } from 'react-redux';
  6. import Avatar from '../../../base/avatar/components/Avatar';
  7. import BottomSheet from '../../../base/dialog/components/native/BottomSheet';
  8. import Icon from '../../../base/icons/components/Icon';
  9. import { IconCloseLarge } from '../../../base/icons/svg';
  10. import { IParticipant } from '../../../base/participants/types';
  11. import { setKnockingParticipantApproval } from '../../../lobby/actions.native';
  12. import { getKnockingParticipantsById } from '../../../lobby/functions';
  13. import styles from './styles';
  14. interface IProps {
  15. /**
  16. * Participant reference.
  17. */
  18. participant: IParticipant;
  19. }
  20. const ContextMenuLobbyParticipantReject = ({ participant: p }: IProps) => {
  21. const dispatch = useDispatch();
  22. const knockParticipantsIDArr = useSelector(getKnockingParticipantsById);
  23. const knockParticipantIsAvailable = knockParticipantsIDArr.find(knockPartId => knockPartId === p.id);
  24. const displayName = p.name;
  25. const reject = useCallback(() => {
  26. dispatch(setKnockingParticipantApproval(p.id, false));
  27. },
  28. [ dispatch ]);
  29. const { t } = useTranslation();
  30. // eslint-disable-next-line react/no-multi-comp
  31. const renderMenuHeader = () => (
  32. <View
  33. style = { styles.contextMenuItemSectionAvatar as ViewStyle }>
  34. <Avatar
  35. participantId = { p.id }
  36. size = { 24 } />
  37. <Text style = { styles.contextMenuItemName }>
  38. { displayName }
  39. </Text>
  40. </View>
  41. );
  42. return (
  43. <BottomSheet
  44. addScrollViewPadding = { false }
  45. /* eslint-disable-next-line react/jsx-no-bind */
  46. renderHeader = { renderMenuHeader }
  47. showSlidingView = { Boolean(knockParticipantIsAvailable) }>
  48. <TouchableOpacity
  49. onPress = { reject }
  50. style = { styles.contextMenuItem as ViewStyle }>
  51. <Icon
  52. size = { 24 }
  53. src = { IconCloseLarge } />
  54. <Text style = { styles.contextMenuItemText }>{ t('lobby.reject') }</Text>
  55. </TouchableOpacity>
  56. </BottomSheet>
  57. );
  58. };
  59. export default ContextMenuLobbyParticipantReject;