import classNames from 'classnames';
import React, { CSSProperties, memo, PropsWithChildren } from 'react';
import EmptySpace from '../EmptySpace';
import styles from './index.less';

interface PropsType {
  conditions: boolean;
  style?: CSSProperties;
  className?: string;
}

/**
 *  @name 条件判空高阶组件
 *  @example
 *  <EmptyWithConditions conditions={true}>
 *  ///
 * </EmptyWithConditions>
 *
 */
const EmptyWithConditions: React.FC<PropsWithChildren<PropsType>> = memo(
  (props) => {
    const { conditions, style, className, children } = props;
    return (
      <div className={classNames(styles.container, className)} style={style}>
        {conditions ? <EmptySpace /> : children}
      </div>
    );
  },
);

export default EmptyWithConditions;
