bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/waiting-users/guest-policy/container.jsx
2024-06-10 16:08:16 -03:00

44 lines
1.0 KiB
JavaScript

import React from 'react';
import { useMutation } from '@apollo/client';
import GuestPolicyComponent from './component';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
import { SET_POLICY } from '../mutations';
import useMeeting from '/imports/ui/core/hooks/useMeeting';
const GuestPolicyContainer = (props) => {
const { data: currentUserData } = useCurrentUser((user) => ({
isModerator: user.isModerator,
}));
const {
data: currentMeeting,
} = useMeeting((m) => ({
usersPolicies: {
guestPolicy: m.usersPolicies.guestPolicy,
},
}));
const amIModerator = currentUserData?.isModerator;
const [setPolicy] = useMutation(SET_POLICY);
const changeGuestPolicy = (guestPolicy) => {
setPolicy({
variables: {
guestPolicy,
},
});
};
return amIModerator
&& (
<GuestPolicyComponent
changeGuestPolicy={changeGuestPolicy}
guestPolicy={currentMeeting?.usersPolicies.guestPolicy}
{...props}
/>
);
};
export default GuestPolicyContainer;