2017-03-23 16:27:59 +09:00
|
|
|
import { registerComponent } from 'meteor/vulcan:lib';
|
2017-05-19 14:42:43 -06:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2016-12-01 16:09:54 +09:00
|
|
|
import withCurrentUser from '../containers/withCurrentUser.js';
|
|
|
|
|
|
|
|
const ShowIf = props => {
|
|
|
|
const { check, document, failureComponent = null, currentUser, children } = props;
|
|
|
|
return check(currentUser, document) ? children : failureComponent;
|
|
|
|
};
|
|
|
|
|
|
|
|
ShowIf.propTypes = {
|
2017-05-19 14:42:43 -06:00
|
|
|
check: PropTypes.func.isRequired,
|
|
|
|
currentUser: PropTypes.object,
|
|
|
|
document: PropTypes.object,
|
|
|
|
failureComponent: PropTypes.object,
|
2016-12-01 16:09:54 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
ShowIf.displayName = "ShowIf";
|
|
|
|
|
2017-01-30 19:46:48 +09:00
|
|
|
registerComponent('ShowIf', ShowIf, withCurrentUser);
|
|
|
|
|
|
|
|
export default withCurrentUser(ShowIf);
|