import React from 'react';

import ActivityIndicator from './ActivityIndicator';



export default ({ emptyInfoComponent, errorInfoComponent, ContentComponent, activityIndicatorComponent, activityIndicatorSize, className, isFresh, ...props}) => {
    let { status, error } = props;
    if (status == "pending" && !activityIndicatorComponent) {
        activityIndicatorComponent = <ActivityIndicator show={ true } size={ activityIndicatorSize } />
    }

    if (fresh && status == "pending") {
        return <div className={ className } {...props}>{ activityIndicatorComponent }</div>
    }

    if (error) {
        return (
            <div className={ className }>
                { errorInfoComponent }
                { status == "pending" ? activityIndicatorComponent : null }
            </div>
        );
    }

    return <ContentComponent className={ className } {...props} />;
}