2023-11-30 19:08:16 +08:00
|
|
|
import React from 'react';
|
2024-01-10 20:07:38 +08:00
|
|
|
import { useMutation } from '@apollo/client';
|
2020-02-04 04:41:12 +08:00
|
|
|
import GuestPolicyComponent from './component';
|
2023-11-30 19:08:16 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
2024-01-10 20:07:38 +08:00
|
|
|
import { SET_POLICY } from '../mutations';
|
2024-06-11 03:08:16 +08:00
|
|
|
import useMeeting from '/imports/ui/core/hooks/useMeeting';
|
2020-02-04 04:41:12 +08:00
|
|
|
|
2022-11-23 00:16:46 +08:00
|
|
|
const GuestPolicyContainer = (props) => {
|
2023-11-30 19:08:16 +08:00
|
|
|
const { data: currentUserData } = useCurrentUser((user) => ({
|
2023-11-30 21:24:25 +08:00
|
|
|
isModerator: user.isModerator,
|
2023-11-30 19:08:16 +08:00
|
|
|
}));
|
2024-06-11 03:08:16 +08:00
|
|
|
|
|
|
|
const {
|
|
|
|
data: currentMeeting,
|
|
|
|
} = useMeeting((m) => ({
|
|
|
|
usersPolicies: {
|
|
|
|
guestPolicy: m.usersPolicies.guestPolicy,
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
2023-11-30 21:24:25 +08:00
|
|
|
const amIModerator = currentUserData?.isModerator;
|
2021-09-02 03:46:14 +08:00
|
|
|
|
2024-01-10 20:07:38 +08:00
|
|
|
const [setPolicy] = useMutation(SET_POLICY);
|
|
|
|
|
|
|
|
const changeGuestPolicy = (guestPolicy) => {
|
|
|
|
setPolicy({
|
|
|
|
variables: {
|
|
|
|
guestPolicy,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2024-06-11 03:08:16 +08:00
|
|
|
return amIModerator
|
|
|
|
&& (
|
|
|
|
<GuestPolicyComponent
|
|
|
|
changeGuestPolicy={changeGuestPolicy}
|
|
|
|
guestPolicy={currentMeeting?.usersPolicies.guestPolicy}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
2021-09-02 03:46:14 +08:00
|
|
|
};
|
2020-02-04 04:41:12 +08:00
|
|
|
|
2024-06-11 03:08:16 +08:00
|
|
|
export default GuestPolicyContainer;
|