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

Commit b8b6d29

Browse files
committed
Fix online school rendering with API
1 parent 3c7cd55 commit b8b6d29

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/scenes/home/codeSchools/codeSchools.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ class CodeSchools extends Component {
1616
schools: null
1717
};
1818
}
19+
1920
componentWillMount() {
2021
return fetch('https://api.operationcode.org/api/v1/code_schools.json').then(response =>
2122
response.json().then((data) => {
22-
console.log(data); // eslint-disable-line
2323
this.setState({ schools: data });
2424
})
2525
);
2626
}
27+
2728
render() {
2829
return (
2930
<div>

src/scenes/home/codeSchools/onlineSchools/onlineSchools.js

Lines changed: 15 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 PropTypes from 'prop-types';
34
import Section from 'shared/components/section/section';
@@ -21,17 +22,28 @@ class OnlineSchools extends Component {
2122
}
2223

2324
loadSchools() {
24-
return this.props.schools.filter(school => school.has_online);
25+
let onlineSchools = [];
26+
this.props.schools.forEach((school) => {
27+
if (school.has_online === true) {
28+
onlineSchools = onlineSchools.concat(school.locations.map(location =>
29+
Object.assign({}, _.omit(school, ['locations']), location)));
30+
}
31+
});
32+
33+
return onlineSchools;
2534
}
35+
2636
render() {
2737
const eSchools = this.state.eSchools.map(school =>
2838
(
2939
<SchoolCard
30-
key={school.name}
40+
key={school.address}
3141
alt={school.name}
3242
schoolName={school.name}
3343
link={school.url}
34-
schoolAddress="Online"
44+
schoolAddress={school.online_only ? 'Online Only' : 'Online and in'}
45+
schoolCity={school.city}
46+
schoolState={school.state}
3547
logo={school.logo}
3648
GI={school.va_accepted ? 'Yes' : 'No'}
3749
fullTime={school.full_time ? 'Full-Time' : 'Flexible'}

0 commit comments

Comments
 (0)