sub-packs/themes/zealder-default-theme/src/routes/index.js
function getThemePage(component, scsId) {
  let mapStateToProps = (state) => {
    let page = state.pages[scsId];
    let zsDefaultContent = state.zlSite.zsDefaultContent;
    let gtags = state.zlSite.gtags;
    const {
      isFetching,
      lastUpdated,
      contents
    } = state.pages[scsId] || {
      isFetching: true,
      contents: []
    }
    let contentList;
    if (Array.isArray(contents) && contents.length > 0) {
      contentList = [];
      contents.forEach(function(scId) {
        contentList.push(state.siteContents[scId]);
      });
    }
    return { page, contentList, zsDefaultContent, isFetching, lastUpdated,
      getComponent, gtags };
  }

  // get pg type component. Add 'pg-' so themes can separate page/route
  // component from component. If same name is used, will not have confusion
  // e.g., pg-Form.js vs Form.js
  let compName = `Pg${component.charAt(0).toUpperCase() + component.slice(1)}`;
  let WrappedComponent = getComponent(compName);

  const enhance = compose(
    connect(mapStateToProps),
    pageSubscription
  )
  return enhance(WrappedComponent, scsId);
}
function getThemePage(component, scsId) {
  let mapStateToProps = (state) => {
    let page = state.pages[scsId];
    let zsDefaultContent = state.zlSite.zsDefaultContent;
    let gtags = state.zlSite.gtags;
    const {
      isFetching,
      lastUpdated,
      contents
    } = state.pages[scsId] || {
      isFetching: true,
      contents: []
    }
    let contentList;
    if (Array.isArray(contents) && contents.length > 0) {
      contentList = [];
      contents.forEach(function(scId) {
        contentList.push(state.siteContents[scId]);
      });
    }
    return { page, contentList, zsDefaultContent, isFetching, lastUpdated,
      getComponent, gtags };
  }

  // get pg type component. Add 'pg-' so themes can separate page/route
  // component from component. If same name is used, will not have confusion
  // e.g., pg-Form.js vs Form.js
  let compName = `Pg${component.charAt(0).toUpperCase() + component.slice(1)}`;
  let WrappedComponent = getComponent(compName);

  const enhance = compose(
    connect(mapStateToProps),
    pageSubscription
  )
  return enhance(WrappedComponent, scsId);
}
function getThemePage ( component , scsId ) { let mapStateToProps = ( state ) => { let page = state . pages [ scsId ] ; let zsDefaultContent = state . zlSite . zsDefaultContent ; let gtags = state . zlSite . gtags ; const { isFetching , lastUpdated , contents } = state . pages [ scsId ] || { isFetching : true , contents : [ ] } let contentList ; if ( Array . isArray ( contents ) && contents . length > 0 ) { contentList = [ ] ; contents . forEach ( function ( scId ) { contentList . push ( state . siteContents [ scId ] ) ; } ) ; } return { page , contentList , zsDefaultContent , isFetching , lastUpdated , getComponent , gtags } ; } // get pg type component. Add 'pg-' so themes can separate page/route // component from component. If same name is used, will not have confusion // e.g., pg-Form.js vs Form.js let compName = ` ${ component . charAt ( 0 ) . toUpperCase ( ) + component . slice ( 1 ) } ` ; let WrappedComponent = getComponent ( compName ) ; const enhance = compose ( connect ( mapStateToProps ) , pageSubscription ) return enhance ( WrappedComponent , scsId ) ; }
/* loads store connnected container with wrapped page component /* TODO: verify if we shouldn't save already loaded component and return that
instead of initiating a new copy. May be better optimized.
/ * loads store connnected container with wrapped page component / * TODO : verify if we shouldn t save already loaded component and return that instead of initiating a new copy . May be better optimized .