Skip to content
This repository was archived by the owner on Jun 10, 2019. It is now read-only.

Commit ee00a36

Browse files
committed
Push progress for Spence
1 parent 62f349e commit ee00a36

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

src/scenes/home/codeSchools/approvedSchools/approvedSchools.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import _ from 'lodash';
12
import React, { Component } from 'react';
23
import Section from 'shared/components/section/section';
34
import 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() {

0 commit comments

Comments
 (0)