appFactory.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. renderCreateContentApp = (appConfig, user, folder) => GLOBAL_renderCreateContentApp({
  15. loggedUser: user.logged ? user : {},
  16. config: {
  17. ...appConfig,
  18. domContainer: 'popupCreateContentContainer',
  19. apiUrl: FETCH_CONFIG.apiUrl,
  20. mockApiUrl: FETCH_CONFIG.mockApiUrl
  21. },
  22. folder
  23. })
  24. emitEventApp = (type, data) => GLOBAL_dispatchEvent(type, data)
  25. render () {
  26. return (
  27. <WrappedComponent
  28. {...this.props}
  29. renderApp={this.renderApp}
  30. renderCreateContentApp={this.renderCreateContentApp}
  31. emitEventApp={this.emitEventApp}
  32. hideApp={this.hideApp}
  33. />
  34. )
  35. }
  36. }
  37. }
  38. export default appFactory