f05cfd0cf8
* Refactor: migrate waitingUserPanel to TS and graphql * Small code improvements * Fix: allow everyone aren't working * Fix: add a condition for edge cases * Make the remember choice works well * Fix TS and eslint errors * Change eslint * Change eslint
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
import Styled from '../styles';
|
|
import { GuestWaitingUser } from '../queries';
|
|
import renderGuestUserItem from './guestUserItem';
|
|
|
|
const ALLOW_STATUS = 'ALLOW';
|
|
const DENY_STATUS = 'DENY';
|
|
|
|
const renderPendingUsers = (
|
|
message: string,
|
|
usersArray: Array<GuestWaitingUser>,
|
|
action: (users: Array<GuestWaitingUser>, status: string) => void,
|
|
privateMessageVisible: (id: string) => void,
|
|
setPrivateGuestLobbyMessage: (msg: string, userId: string) => void,
|
|
privateGuestLobbyMessage: (userId: string) => string | null,
|
|
isGuestLobbyMessageEnabled: boolean,
|
|
) => {
|
|
if (!usersArray.length) return null;
|
|
return (
|
|
<Styled.PendingUsers>
|
|
<Styled.MainTitle>{message}</Styled.MainTitle>
|
|
<Styled.UsersWrapper>
|
|
<Styled.Users>
|
|
{usersArray.map((user, idx) => renderGuestUserItem(
|
|
user.user.name ?? '',
|
|
user.user.color ?? '',
|
|
() => action([user], ALLOW_STATUS),
|
|
() => action([user], DENY_STATUS),
|
|
user.user.role ?? '',
|
|
idx + 1,
|
|
user.user.userId ?? '',
|
|
user.user.avatar ?? '',
|
|
() => privateMessageVisible(`privateMessage-${user.user.userId}`),
|
|
(msg: string) => setPrivateGuestLobbyMessage(msg, user?.user?.userId ?? ''),
|
|
privateGuestLobbyMessage(user?.user?.userId ?? '') ?? '',
|
|
isGuestLobbyMessageEnabled,
|
|
))}
|
|
|
|
</Styled.Users>
|
|
</Styled.UsersWrapper>
|
|
</Styled.PendingUsers>
|
|
);
|
|
};
|
|
|
|
export default renderPendingUsers;
|