appFactory.js 801B

12345678910111213141516171819202122232425262728293031323334
  1. import React from 'react'
  2. import { FETCH_CONFIG } from './helper.js'
  3. export function appFactory (WrappedComponent) {
  4. return class AppFactory extends React.Component {
  5. renderApp = (appConfig, user, content) => GLOBAL_renderApp({
  6. loggedUser: user.logged ? user : {},
  7. config: {
  8. ...appConfig,
  9. apiUrl: FETCH_CONFIG.apiUrl,
  10. mockApiUrl: FETCH_CONFIG.mockApiUrl
  11. },
  12. content
  13. })
  14. emitEventApp = (type, data) => GLOBAL_dispatchEvent(type, data)
  15. hideApp = appName => GLOBAL_hideApp(appName)
  16. render () {
  17. return (
  18. <WrappedComponent
  19. {...this.props}
  20. renderApp={this.renderApp}
  21. emitEventApp={this.emitEventApp}
  22. hideApp={this.hideApp}
  23. />
  24. )
  25. }
  26. }
  27. }
  28. export default appFactory