2016-12-06 18:06:29 +01:00
|
|
|
import { registerComponent } from 'meteor/nova:lib';
|
2016-12-01 16:09:54 +09:00
|
|
|
import React, { PropTypes } from 'react';
|
|
|
|
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 = {
|
|
|
|
check: React.PropTypes.func.isRequired,
|
|
|
|
currentUser: React.PropTypes.object,
|
|
|
|
document: React.PropTypes.object,
|
|
|
|
failureComponent: React.PropTypes.object,
|
|
|
|
};
|
|
|
|
|
|
|
|
ShowIf.displayName = "ShowIf";
|
|
|
|
|
2017-01-19 11:19:36 +09:00
|
|
|
export default registerComponent('ShowIf', ShowIf, withCurrentUser);
|