2021-09-02 03:46:14 +08:00
|
|
|
import React, { useContext } from 'react';
|
2020-02-04 04:41:12 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2022-02-15 23:54:55 +08:00
|
|
|
import { withModalMounter } from '/imports/ui/components/common/modal/service';
|
2020-02-04 04:41:12 +08:00
|
|
|
import GuestPolicyComponent from './component';
|
|
|
|
import Service from '../service';
|
2021-09-02 03:46:14 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
import { UsersContext } from '/imports/ui/components/components-data/users-context/context';
|
2020-02-04 04:41:12 +08:00
|
|
|
|
2021-09-02 03:46:14 +08:00
|
|
|
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
|
|
|
|
|
|
|
|
const guestPolicyContainer = (props) => {
|
|
|
|
const usingUsersContext = useContext(UsersContext);
|
|
|
|
const { users } = usingUsersContext;
|
|
|
|
const currentUser = users[Auth.meetingID][Auth.userID];
|
|
|
|
const amIModerator = currentUser.role === ROLE_MODERATOR;
|
|
|
|
|
|
|
|
return amIModerator && <GuestPolicyComponent {...props} />;
|
|
|
|
};
|
2020-02-04 04:41:12 +08:00
|
|
|
|
|
|
|
export default withModalMounter(withTracker(({ mountModal }) => ({
|
|
|
|
closeModal: () => mountModal(null),
|
|
|
|
guestPolicy: Service.getGuestPolicy(),
|
|
|
|
changeGuestPolicy: Service.changeGuestPolicy,
|
|
|
|
}))(guestPolicyContainer));
|