2021-04-07 03:58:11 +08:00
|
|
|
import React, { useContext } from 'react';
|
2019-02-27 01:08:15 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
import GuestUsers from '/imports/api/guest-users/';
|
2021-04-07 03:58:11 +08:00
|
|
|
import { UsersContext } from '/imports/ui/components/components-data/users-context/context';
|
2019-02-27 01:08:15 +08:00
|
|
|
import WaitingComponent from './component';
|
2021-08-05 19:03:24 +08:00
|
|
|
import LayoutContext from '../../layout/context';
|
2021-05-18 04:25:07 +08:00
|
|
|
import { PANELS } from '../../layout/enums';
|
2019-02-27 01:08:15 +08:00
|
|
|
|
|
|
|
const USER_CONFIG = Meteor.settings.public.user;
|
|
|
|
const ROLE_MODERATOR = USER_CONFIG.role_moderator;
|
|
|
|
|
2021-04-07 03:58:11 +08:00
|
|
|
const WaitingContainer = (props) => {
|
2021-08-05 19:03:24 +08:00
|
|
|
const layoutContext = useContext(LayoutContext);
|
|
|
|
const { layoutContextState, layoutContextDispatch } = layoutContext;
|
|
|
|
const { input } = layoutContextState;
|
2021-05-19 22:51:31 +08:00
|
|
|
const { sidebarContent } = input;
|
|
|
|
const { sidebarContentPanel } = sidebarContent;
|
2021-05-18 04:25:07 +08:00
|
|
|
const managementPanelIsOpen = sidebarContentPanel === PANELS.WAITING_USERS;
|
|
|
|
|
2021-04-07 03:58:11 +08:00
|
|
|
const usingUsersContext = useContext(UsersContext);
|
|
|
|
const { users } = usingUsersContext;
|
2021-04-15 20:12:21 +08:00
|
|
|
const currentUser = users[Auth.meetingID][Auth.userID];
|
2021-04-07 03:58:11 +08:00
|
|
|
const currentUserIsModerator = currentUser.role === ROLE_MODERATOR;
|
|
|
|
const joinTime = currentUser.authTokenValidatedTime;
|
|
|
|
return (
|
|
|
|
<WaitingComponent {...{
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch,
|
2021-05-18 04:25:07 +08:00
|
|
|
managementPanelIsOpen,
|
2021-04-07 03:58:11 +08:00
|
|
|
...props,
|
|
|
|
currentUserIsModerator,
|
|
|
|
joinTime,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2019-02-27 01:08:15 +08:00
|
|
|
export default withTracker(() => {
|
2019-02-27 01:21:57 +08:00
|
|
|
const pendingUsers = GuestUsers.find({
|
2019-02-27 01:08:15 +08:00
|
|
|
meetingId: Auth.meetingID,
|
|
|
|
approved: false,
|
|
|
|
denied: false,
|
|
|
|
}).fetch();
|
|
|
|
|
|
|
|
return {
|
2019-02-27 01:21:57 +08:00
|
|
|
pendingUsers,
|
2019-02-27 01:08:15 +08:00
|
|
|
};
|
|
|
|
})(WaitingContainer);
|