Skip to content

Instantly share code, notes, and snippets.

@kaleem-elahi
Created April 16, 2019 09:45
Show Gist options
  • Select an option

  • Save kaleem-elahi/2314b2fd68c210d1673cd7bf70ba3e33 to your computer and use it in GitHub Desktop.

Select an option

Save kaleem-elahi/2314b2fd68c210d1673cd7bf70ba3e33 to your computer and use it in GitHub Desktop.
Manage multi-tenant by using this file - RenderByTenant. Multitenant + role-based
import {
Component,
} from 'react';
import PropTypes from 'prop-types';
import {
connect,
} from 'react-redux';
class RenderByTenant extends Component {
render() {
const {
roles,
tenants,
} = this.props.accountInfo;
return tenants[0].name === 'WP' ? this.props.WP(roles) : this.props.ERG(roles);
}
}
RenderByTenant.propTypes = {
// roles: PropTypes.arrayOf(PropTypes.object)
// .isRequired,
accountInfo: PropTypes.objectOf(PropTypes.object)
.isRequired,
WP: PropTypes.func.isRequired,
ERG: PropTypes.func.isRequired,
};
const mapStateToProps = state => ({
accountInfo: state.recruiter.accountInfo,
});
export default connect(mapStateToProps)(RenderByTenant);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment