You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MeetingParticipantList.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // @flow
  2. import React, { useCallback } from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { Text, View } from 'react-native';
  5. import { Button } from 'react-native-paper';
  6. import { useDispatch, useSelector, useStore } from 'react-redux';
  7. import { Icon, IconInviteMore } from '../../../base/icons';
  8. import { getParticipants } from '../../../base/participants';
  9. import { doInvitePeople } from '../../../invite/actions.native';
  10. import { shouldRenderInviteButton } from '../../functions';
  11. import { MeetingParticipantItem } from './MeetingParticipantItem';
  12. import styles from './styles';
  13. export const MeetingParticipantList = () => {
  14. const dispatch = useDispatch();
  15. const onInvite = useCallback(() => dispatch(doInvitePeople()), [ dispatch ]);
  16. const showInviteButton = useSelector(shouldRenderInviteButton);
  17. const store = useStore();
  18. const state = store.getState();
  19. const participants = getParticipants(state);
  20. const { t } = useTranslation();
  21. return (
  22. <View style = { styles.meetingList }>
  23. <Text style = { styles.meetingListDescription }>
  24. {t('participantsPane.headings.participantsList',
  25. { count: participants.length })}
  26. </Text>
  27. {
  28. showInviteButton
  29. && <Button
  30. children = { t('participantsPane.actions.invite') }
  31. /* eslint-disable-next-line react/jsx-no-bind */
  32. icon = { () =>
  33. (<Icon
  34. size = { 24 }
  35. src = { IconInviteMore } />)
  36. }
  37. labelStyle = { styles.inviteLabel }
  38. mode = 'contained'
  39. onPress = { onInvite }
  40. style = { styles.inviteButton } />
  41. }
  42. {
  43. participants.map(p => (
  44. <MeetingParticipantItem
  45. key = { p.id }
  46. participant = { p } />)
  47. )
  48. }
  49. </View>
  50. );
  51. };