mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
Merge remote-tracking branch 'origin/feature/Detail'
This commit is contained in:
@@ -2,32 +2,32 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import If from './If';
|
||||
|
||||
const Choose = props => {
|
||||
let when = null;
|
||||
let otherwise = null;
|
||||
const Choose = (props) => {
|
||||
let when = null;
|
||||
let otherwise = null;
|
||||
|
||||
React.Children.forEach(props.children, children => {
|
||||
if (children.props.condition === undefined) {
|
||||
otherwise = children;
|
||||
} else if (!when && children.props.condition === true) {
|
||||
when = children;
|
||||
}
|
||||
});
|
||||
React.Children.forEach(props.children, (children) => {
|
||||
if (children.props.condition === undefined) {
|
||||
otherwise = children;
|
||||
} else if (!when && children.props.condition === true) {
|
||||
when = children;
|
||||
}
|
||||
});
|
||||
|
||||
return when || otherwise;
|
||||
return when || otherwise;
|
||||
};
|
||||
|
||||
Choose.propTypes = {
|
||||
children: PropTypes.node
|
||||
children: PropTypes.node,
|
||||
};
|
||||
|
||||
Choose.When = If;
|
||||
|
||||
Choose.Otherwise = ({render, children}) => render ? render() : children;
|
||||
Choose.Otherwise = ({ render, children }) => (render ? render() : children);
|
||||
|
||||
Choose.Otherwise.propTypes = {
|
||||
children: PropTypes.node,
|
||||
render: PropTypes.func
|
||||
render: PropTypes.func,
|
||||
};
|
||||
|
||||
export default Choose;
|
||||
export default Choose;
|
||||
|
||||
Reference in New Issue
Block a user