bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/waiting-users/waiting-users-graphql/guest-items/guestPendingUser.tsx
Tainan Felipe f05cfd0cf8
Refactor: migrate waitingUserPanel to TS and graphql (#18677)
* 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
2023-10-06 14:12:42 -03:00

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;