Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Modify GeotagCloudPage according to latest API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
voidxnull committed May 8, 2016
1 parent 3a7231c commit 1aa9d00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
4 changes: 3 additions & 1 deletion src/components/continent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default class Continent extends React.Component {
static displayName = 'Continent';
static propTypes = {
code: PropTypes.string.isRequired,
count: PropTypes.number.isRequired,
geotags: PropTypes.arrayOf(PropTypes.shape({
url_name: PropTypes.string
})).isRequired
Expand All @@ -16,6 +17,7 @@ export default class Continent extends React.Component {
render() {
const {
code,
count,
geotags
} = this.props;

Expand All @@ -30,7 +32,7 @@ export default class Continent extends React.Component {
}}
>
<Link className="continent__title" to={`/geo/${url_name}`}>
{name} <span className="continent__amount">({geotags.length})</span>
{name} <span className="continent__amount">({count})</span>
</Link>
<div className="layout__row">
<TagCloud geotags={geotags} />
Expand Down
30 changes: 13 additions & 17 deletions src/pages/geotag-cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import Helmet from 'react-helmet';
import { has, transform } from 'lodash';

import {
Page,
Expand Down Expand Up @@ -55,19 +54,10 @@ class GeotagCloudPage extends Component {
geotag_cloud
} = this.props;

const geotagsForCloud = geotag_cloud.map(url_name => geotags[url_name]);

let geotagsByContinents = {};
geotagsForCloud.forEach(geotag => {
if (geotag.continent_code) {
const code = geotag.continent_code;

if (!has(geotagsByContinents, code)) {
geotagsByContinents[code] = [geotag];
} else {
geotagsByContinents[code].push(geotag);
}
}
const geotagsByContinents = geotag_cloud.map(continent => {
return Object.assign(continent, {
geotags: continent.geotags.map(urlName => geotags[urlName])
});
});

return (
Expand All @@ -88,9 +78,15 @@ class GeotagCloudPage extends Component {
<PageBody>
<PageContent>
<PageCaption>Geotag cloud</PageCaption>
{transform(geotagsByContinents, (arr, value, key) =>
arr.push(<Continent code={key} geotags={value} key={key} />)
, [])
{
geotagsByContinents.map(continent => (
<Continent
code={continent.continent_code}
count={continent.geotag_count}
geotags={continent.geotags}
key={continent.continent_code}
/>
))
}
</PageContent>
</PageBody>
Expand Down

0 comments on commit 1aa9d00

Please sign in to comment.