This repository was archived by the owner on Jun 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
src/scenes/home/codeSchools/approvedSchools Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import _ from 'lodash' ;
12import React , { Component } from 'react' ;
23import Section from 'shared/components/section/section' ;
34import SchoolCard from 'shared/components/schoolCard/schoolCard' ;
@@ -10,12 +11,28 @@ class ApprovedSchools extends Component {
1011 constructor ( props ) {
1112 super ( props ) ;
1213 this . state = {
14+ schools : null ,
1315 vaSchools : null
1416 } ;
1517
16- gettingSchoolData . then ( data =>
17- this . setState ( { vaSchools : data } )
18- ) ;
18+ gettingSchoolData . then ( data => this . setState ( { schools : data } ) ) ;
19+ }
20+
21+ componentWillMount ( ) {
22+ this . setState ( { vaSchools : this . getApprovedSchools ( this . state . schools ) } ) ;
23+ }
24+
25+ getApprovedSchools = ( schools ) => {
26+ const approvedSchools = [ ] ;
27+ schools . forEach ( ( school ) => {
28+ const locations = school . locations . filter ( location => location . va_accepted === true ) ;
29+ if ( locations . length > 0 ) {
30+ approvedSchools . push ( locations . map ( location =>
31+ Object . assign ( { } , _ . omit ( school , [ 'locations' ] ) , location ) ) ) ;
32+ }
33+ } ) ;
34+
35+ return approvedSchools ;
1936 }
2037
2138 render ( ) {
You can’t perform that action at this time.
0 commit comments