2021-04-21 13:48:05 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-06-09 11:25:39 +00:00
|
|
|
import { makeStyles } from '@material-ui/core/styles';
|
|
|
|
import React, { useCallback } from 'react';
|
2021-04-21 13:48:05 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2021-06-09 11:25:39 +00:00
|
|
|
import { useSelector, useDispatch } from 'react-redux';
|
2021-04-21 13:48:05 +00:00
|
|
|
|
2021-06-09 16:06:09 +00:00
|
|
|
import { withPixelLineHeight } from '../../../base/styles/functions.web';
|
|
|
|
import { admitMultiple } from '../../../lobby/actions.web';
|
2021-05-19 10:08:30 +00:00
|
|
|
import { getLobbyState } from '../../../lobby/functions';
|
2021-04-21 13:48:05 +00:00
|
|
|
|
|
|
|
import { LobbyParticipantItem } from './LobbyParticipantItem';
|
2021-06-09 11:25:39 +00:00
|
|
|
|
|
|
|
const useStyles = makeStyles(theme => {
|
|
|
|
return {
|
|
|
|
headingContainer: {
|
|
|
|
alignItems: 'center',
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'space-between'
|
|
|
|
},
|
|
|
|
heading: {
|
|
|
|
...withPixelLineHeight(theme.typography.heading7),
|
|
|
|
color: theme.palette.text02
|
|
|
|
},
|
|
|
|
link: {
|
|
|
|
...withPixelLineHeight(theme.typography.labelBold),
|
|
|
|
color: theme.palette.link01,
|
|
|
|
cursor: 'pointer'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2021-04-21 13:48:05 +00:00
|
|
|
|
|
|
|
export const LobbyParticipantList = () => {
|
|
|
|
const {
|
|
|
|
lobbyEnabled,
|
|
|
|
knockingParticipants: participants
|
|
|
|
} = useSelector(getLobbyState);
|
|
|
|
const { t } = useTranslation();
|
2021-06-09 11:25:39 +00:00
|
|
|
const classes = useStyles();
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const admitAll = useCallback(() => {
|
|
|
|
dispatch(admitMultiple(participants));
|
|
|
|
}, [ dispatch, participants ]);
|
2021-04-21 13:48:05 +00:00
|
|
|
|
|
|
|
if (!lobbyEnabled || !participants.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2021-06-09 11:25:39 +00:00
|
|
|
<div className = { classes.headingContainer }>
|
|
|
|
<div className = { classes.heading }>
|
|
|
|
{t('participantsPane.headings.lobby', { count: participants.length })}
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
className = { classes.link }
|
|
|
|
onClick = { admitAll }>{t('lobby.admitAll')}</div>
|
|
|
|
</div>
|
2021-04-21 13:48:05 +00:00
|
|
|
<div>
|
|
|
|
{participants.map(p => (
|
|
|
|
<LobbyParticipantItem
|
|
|
|
key = { p.id }
|
|
|
|
participant = { p } />)
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|