2023-11-30 19:08:16 +08:00
|
|
|
import React from 'react';
|
2020-02-04 04:41:12 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
|
|
|
import GuestPolicyComponent from './component';
|
|
|
|
import Service from '../service';
|
2023-11-30 19:08:16 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
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;
|
|
|
|
|
2022-11-23 00:16:46 +08:00
|
|
|
const GuestPolicyContainer = (props) => {
|
2023-11-30 19:08:16 +08:00
|
|
|
const { data: currentUserData } = useCurrentUser((user) => ({
|
|
|
|
role: user.role,
|
|
|
|
}));
|
|
|
|
const amIModerator = currentUserData?.role === ROLE_MODERATOR;
|
2021-09-02 03:46:14 +08:00
|
|
|
|
|
|
|
return amIModerator && <GuestPolicyComponent {...props} />;
|
|
|
|
};
|
2020-02-04 04:41:12 +08:00
|
|
|
|
2023-11-30 19:08:16 +08:00
|
|
|
export default withTracker(() => ({
|
2020-02-04 04:41:12 +08:00
|
|
|
guestPolicy: Service.getGuestPolicy(),
|
|
|
|
changeGuestPolicy: Service.changeGuestPolicy,
|
2023-03-22 04:45:20 +08:00
|
|
|
}))(GuestPolicyContainer);
|