2021-04-21 13:48:05 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
|
|
2021-06-24 13:26:55 +00:00
|
|
|
import { approveKnockingParticipant, rejectKnockingParticipant } from '../../../lobby/actions';
|
|
|
|
import { ACTION_TRIGGER, MEDIA_STATE } from '../../constants';
|
2021-04-21 13:48:05 +00:00
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
import ParticipantItem from './ParticipantItem';
|
2021-04-21 13:48:05 +00:00
|
|
|
import { ParticipantActionButton } from './styled';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Participant reference
|
|
|
|
*/
|
|
|
|
participant: Object
|
|
|
|
};
|
|
|
|
|
|
|
|
export const LobbyParticipantItem = ({ participant: p }: Props) => {
|
|
|
|
const dispatch = useDispatch();
|
2021-06-23 11:23:44 +00:00
|
|
|
const admit = useCallback(() => dispatch(approveKnockingParticipant(p.id), [ dispatch ]));
|
|
|
|
const reject = useCallback(() => dispatch(rejectKnockingParticipant(p.id), [ dispatch ]));
|
2021-04-21 13:48:05 +00:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ParticipantItem
|
2021-06-23 11:23:44 +00:00
|
|
|
actionsTrigger = { ACTION_TRIGGER.PERMANENT }
|
|
|
|
audioMediaState = { MEDIA_STATE.NONE }
|
2021-07-09 12:36:19 +00:00
|
|
|
displayName = { p.name }
|
|
|
|
local = { p.local }
|
|
|
|
participantID = { p.id }
|
|
|
|
raisedHand = { p.raisedHand }
|
|
|
|
videoMuteState = { MEDIA_STATE.NONE }
|
|
|
|
youText = { t('chat.you') }>
|
2021-04-21 13:48:05 +00:00
|
|
|
<ParticipantActionButton
|
|
|
|
onClick = { reject }>
|
|
|
|
{t('lobby.reject')}
|
|
|
|
</ParticipantActionButton>
|
|
|
|
<ParticipantActionButton
|
|
|
|
onClick = { admit }
|
|
|
|
primary = { true }>
|
|
|
|
{t('lobby.admit')}
|
|
|
|
</ParticipantActionButton>
|
|
|
|
</ParticipantItem>
|
|
|
|
);
|
|
|
|
};
|