import _ from 'lodash';
import features from 'features';

import About from 'components/About';
import Messages from 'components/Messages';
import Speakers from 'components/Speakers';
import Networking from 'components/Networking';
import Timeline from 'components/Timeline';
import Proposals from 'components/Proposals';
import CFP from 'components/CFP';
import Register from 'components/Register';
import Sponsors from 'components/Sponsors';
import Team from 'components/Team';
import Location from 'components/Location';
import ScheduleSection from 'components/ScheduleSection';


const sections = [
  { name: "messages", el: Messages },
  { name: "about", el: About },
  { name: "schedule", el: ScheduleSection, feature: 'publishAgenda', props: ['acceptedProposals'] },
  { name: "speakers", el: Speakers, props: ['speakers'], feature: 'publishAgenda' },
  { name: "timeline", el: Timeline, feature: 'timelineFinalized' },
  { name: "register", el: Register },
  { name: "proposals", el: Proposals, props: ['proposals', 'isReversimTeamMember'], feature: 'timelineFinalized' },
  { name: "cfp", el: CFP, feature: "submission" },
  { name: "team", el: Team, props: ['user.team'] },
  { name: "sponsors", el: Sponsors, feature: 'sponsored' },
  { name: "location", el: Location, props: ['location'] },
  { name: "networking", el: Networking, feature: "networking" }
];

export default (allProps) => {
  return sections.filter(item => {
    if (!item.feature) return true;
    const passFeature = features(item.feature, false);
    return item.isNot ? !passFeature : passFeature;
  }).map(item => {
    if (item.props) {
      item.props = item.props.map(prop => _.get(allProps, prop));
    }
    return item;
  });
};
@@ -848,24 +848,75 @@
 hAgenda' %7D,%0A
+  %7B name: %22cfp%22, el: CFP, feature: %22submission%22 %7D,%0A
   %7B name: %22t
@@ -1129,59 +1129,8 @@
  %7D,%0A
-  %7B name: %22cfp%22, el: CFP, feature: %22submission%22 %7D,%0A
   %7B 
@@ -1584,32 +1584,54 @@
 ).map(item =%3E %7B%0A
+    const props = %7B%7D;%0A
     if (item.pro
@@ -1656,33 +1656,133 @@
 rops
- = item.props.map(prop
+.forEach(prop =%3E %7B%0A        let propName = prop.includes(%22.%22) ? prop.split(%22.%22).slice(-1)%5B0%5D : prop;%0A        props%5BpropName%5D
  =
-%3E
  _.g
@@ -1799,17 +1799,53 @@
 s, prop)
-)
+;%0A      %7D);%0A%0A      item.props = props
 ;%0A    %7D%0A

reorder sections and fix prev commit