2016-05-06 02:50:18 +08:00
|
|
|
import React from 'react';
|
2018-01-08 12:44:42 +08:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2018-10-10 23:49:58 +08:00
|
|
|
import Users from '/imports/api/users';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-10-06 20:50:01 +08:00
|
|
|
import PollingService from './service';
|
2016-05-20 21:46:30 +08:00
|
|
|
import PollingComponent from './component';
|
2016-05-06 02:50:18 +08:00
|
|
|
|
2018-01-08 12:44:42 +08:00
|
|
|
const propTypes = {
|
|
|
|
pollExists: PropTypes.bool.isRequired,
|
2017-10-06 20:50:01 +08:00
|
|
|
};
|
2018-01-08 12:44:42 +08:00
|
|
|
|
|
|
|
const PollingContainer = ({ pollExists, ...props }) => {
|
2018-10-10 23:49:58 +08:00
|
|
|
const currentUser = Users.findOne({ userId: Auth.userID });
|
|
|
|
if (pollExists && !currentUser.presenter) {
|
2018-01-08 12:44:42 +08:00
|
|
|
return (
|
|
|
|
<PollingComponent {...props} />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
PollingContainer.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default withTracker(() => {
|
2016-05-06 02:50:18 +08:00
|
|
|
const data = PollingService.mapPolls();
|
|
|
|
return data;
|
2018-01-08 12:44:42 +08:00
|
|
|
})(PollingContainer);
|