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, action: (users: Array, 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 ( {message} {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, ))} ); }; export default renderPendingUsers;