text: import React, {useContext} from "react";
  
  import {WappContext} from "wapplr-react/dist/common/Wapp";
  import AppContext from "../../components/App/context";
  import User from "../../components/User";
  
  import defaultPostTypeConfig from "../post";
  
  import {runPostTypesConfigSync} from "../index";
  
  export function Component(props) {
  
      const appContext = useContext(AppContext);
      const context = useContext(WappContext);
  
      const {
          name = "user"
      } = props;
  
      const p = {context, appContext, postContext:{name}};
  
      const pages = {
         ...runPostTypesConfigSync({action:"userPageFunctions", rKey:"pages", p})
             .reduce((a, v) => {return {...a, ...v}}, {})
      };
  
      function getDashBoardTitle({user, post, page}) {
          return runPostTypesConfigSync({action:"userPageFunctions", rKey:"getDashBoardTitle", p})
              .map((f)=>(f) ? f({user, post, page}) : null)
              .filter((r)=>r)[0];
      }
  
      function addMenuItems(props) {
          return [
              ...runPostTypesConfigSync({action:"userPageFunctions", rKey:"addMenuItems", p})
                  .map((f)=>(f) ? f(props) : null)
                  .filter((r)=> !!(r && r.length))
                  .reduce((a, v) => {return [...a, ...v]}, [])
          ];
      }
  
      function addContentMenuItems(props) {
          return [
              ...runPostTypesConfigSync({action:"userPageFunctions", rKey:"addContentMenuItems", p})
                  .map((f)=>(f) ? f(props) : null)
                  .filter((r)=> !!(r && r.length))
                  .reduce((a, v) => {return [...a, ...v]}, [])
          ]
      }
  
      function getPageName(props) {
          return runPostTypesConfigSync({action:"userPageFunctions", rKey:"getPageName", p})
              .map((f)=>(f) ? f(props) : null)
              .filter((r)=>r)[0];
      }
  
      return (
          <User
              {...props}
              pages={pages}
              getDashBoardTitle={getDashBoardTitle}
              addMenuItems={addMenuItems}
              addContentMenuItems={addContentMenuItems}
              getPageName={getPageName}
          />
      )
  }
  
  export default function getComponent(p) {
      return defaultPostTypeConfig.getComponent({...p, name:"user", Component})
  }
  