Skip to content

Instantly share code, notes, and snippets.

@andreychev
Created March 22, 2017 06:27
Show Gist options
  • Save andreychev/a38f9e9329129d41c6016dcd06b3512d to your computer and use it in GitHub Desktop.
Save andreychev/a38f9e9329129d41c6016dcd06b3512d to your computer and use it in GitHub Desktop.
import React, { PropTypes } from 'react';
import Constants from 'cx-api/constants';
import Loading from 'ux/flow/Loading';
function isPending(loadingComponent) {
function pendingHOC({ status, loading = {}, children }) {
if (status === Constants.STATE_PENDING) {
return (<loadingComponent { ...loading } />);
}
return children || null;
}
pendingHOC.propTypes = {
status: PropTypes.oneOf([
'',
Constants.STATE_PENDING,
Constants.STATE_RESOLVED,
Constants.STATE_REJECTED
]),
loading: PropTypes.object
};
return pendingHOC;
}
export { isPending };
export default isPending(Loading);
@andreychev
Copy link
Author

import React, { PropTypes } from 'react';

import Constants from 'cx-api/constants';

import Incident from 'ux/flow/Incident';

function isRejecting(rejectingComponent) {
    function rejectingHOC({ status, rejecting = {}, children }) {
        if (status === Constants.STATE_REJECTED) {
            return (<rejectingComponent { ...rejecting } />);
        }

        return children || null;
    }

    rejectingHOC.propTypes = {
        status: PropTypes.oneOf([
            '',
            Constants.STATE_PENDING,
            Constants.STATE_RESOLVED,
            Constants.STATE_REJECTED
        ]),
        rejecting: PropTypes.object
    };

    return rejectingHOC;
}

export { isRejecting };

export default isRejecting(Incident);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment