2021-05-19 10:08:30 +00:00
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
|
|
2022-07-27 08:40:34 +00:00
|
|
|
import Button from '../../../base/ui/components/native/Button';
|
2022-11-09 12:45:55 +00:00
|
|
|
import { BUTTON_TYPES } from '../../../base/ui/constants.native';
|
2022-11-25 11:59:45 +00:00
|
|
|
import { setKnockingParticipantApproval } from '../../../lobby/actions.native';
|
2021-05-19 10:08:30 +00:00
|
|
|
|
|
|
|
import ParticipantItem from './ParticipantItem';
|
|
|
|
import styles from './styles';
|
|
|
|
|
2022-11-25 11:59:45 +00:00
|
|
|
|
2021-05-19 10:08:30 +00:00
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Participant reference.
|
2021-05-19 10:08:30 +00:00
|
|
|
*/
|
|
|
|
participant: Object
|
|
|
|
};
|
|
|
|
|
|
|
|
export const LobbyParticipantItem = ({ participant: p }: Props) => {
|
|
|
|
const dispatch = useDispatch();
|
2022-11-25 11:59:45 +00:00
|
|
|
const admit = useCallback(() => dispatch(setKnockingParticipantApproval(p.id, true), [ dispatch ]));
|
|
|
|
const reject = useCallback(() => dispatch(setKnockingParticipantApproval(p.id, false), [ dispatch ]));
|
2021-05-19 10:08:30 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ParticipantItem
|
2021-07-12 15:14:38 +00:00
|
|
|
displayName = { p.name }
|
2021-06-09 12:41:00 +00:00
|
|
|
isKnockingParticipant = { true }
|
2022-11-25 11:59:45 +00:00
|
|
|
key = { p.id }
|
|
|
|
participantID = { p.id } >
|
|
|
|
<Button
|
|
|
|
accessibilityLabel = 'lobby.reject'
|
|
|
|
labelKey = 'lobby.reject'
|
|
|
|
onClick = { reject }
|
|
|
|
style = { styles.lobbyButtonReject }
|
|
|
|
type = { BUTTON_TYPES.DESTRUCTIVE } />
|
2021-06-03 16:23:18 +00:00
|
|
|
<Button
|
2022-07-07 12:29:18 +00:00
|
|
|
accessibilityLabel = 'lobby.admit'
|
2022-08-22 09:40:59 +00:00
|
|
|
labelKey = 'lobby.admit'
|
|
|
|
onClick = { admit }
|
2022-11-25 11:59:45 +00:00
|
|
|
style = { styles.lobbyButtonAdmit }
|
2022-07-07 12:29:18 +00:00
|
|
|
type = { BUTTON_TYPES.PRIMARY } />
|
2021-05-19 10:08:30 +00:00
|
|
|
</ParticipantItem>
|
|
|
|
);
|
|
|
|
};
|