Skip to content

Commit c714151

Browse files
authored
Merge pull request #3349 from Vizzuality/fix/404s
Fix/404s
2 parents 186df85 + feb8b84 commit c714151

File tree

10 files changed

+189
-590
lines changed

10 files changed

+189
-590
lines changed

app/assets/stylesheets/layouts/_static.scss

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// LAYOUT
2-
.layout-content {
3-
// padding: 0 15px;
4-
}
1+
2+
/* eslint-disable */
53

64
.loader-mobile{
75
display: block;
@@ -107,6 +105,9 @@
107105
}
108106
.inner {
109107
padding: 0 15px;
108+
&.-redirect {
109+
text-align: center;
110+
}
110111
}
111112
.row {
112113
display: flex;

app/javascript/pages/country/header/header-component.js

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class Header extends PureComponent {
7070
theme="theme-dropdown-dark"
7171
placeholder="Country"
7272
noItemsFound="No country found"
73+
noSelectedValue="Country"
7374
value={locationNames.country}
7475
options={locationOptions.countries}
7576
onChange={handleCountryChange}

app/javascript/pages/country/header/header.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ class HeaderContainer extends PureComponent {
136136
let secondSentence = '';
137137
if (data.extent > 0) {
138138
firstSentence = `
139-
In 2010, <b>${location}</b> had <b>${extent}ha</b> of tree cover, extending over <b>${percentageCover}%</b> of its land area.
139+
In 2010, <b>${location}</b> had <b>${
140+
extent
141+
}ha</b> of tree cover, extending over <b>${
142+
percentageCover
143+
}%</b> of its land area.
140144
`;
141145
} else {
142146
firstSentence = `
@@ -145,14 +149,16 @@ class HeaderContainer extends PureComponent {
145149
}
146150
if (data.extent > 0 && data.totalLoss.area) {
147151
secondSentence = `
148-
In ${
149-
data.totalLoss.year
150-
}, it lost <b>${lossWithOutPlantations}ha</b> of forest${
151-
data.plantationsLoss.area ? ' excluding tree plantations' : ''
152-
}, equivalent to <b>${emissionsWithoutPlantations}t</b> of CO₂ of emissions.
152+
In ${data.totalLoss.year}, it lost <b>${
153+
lossWithOutPlantations
154+
}ha</b> of forest${
155+
data.plantationsLoss.area ? ' excluding tree plantations' : ''
156+
}, equivalent to <b>${
157+
emissionsWithoutPlantations
158+
}t</b> of CO₂ of emissions.
153159
`;
154160
}
155-
return `${firstSentence} ${secondSentence}`;
161+
return `${location ? firstSentence : ''} ${secondSentence}`;
156162
};
157163

158164
render() {

app/javascript/pages/country/root/root-component.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class Root extends PureComponent {
7272
<div className="widgets">
7373
{loading && <Loader className="widgets-loader large" />}
7474
{!loading &&
75+
currentLocation &&
7576
widgets &&
7677
widgets.length > 0 &&
7778
widgets.map(widget => (
@@ -82,12 +83,16 @@ class Root extends PureComponent {
8283
/>
8384
))}
8485
{!loading &&
85-
(!widgets || widgets.length === 0) && (
86+
(!currentLocation || (!widgets || widgets.length === 0)) && (
8687
<NoContent
8788
className="no-widgets-message large"
88-
message={`${upperFirst(
89-
category
90-
)} data for ${currentLocation} coming soon`}
89+
message={
90+
currentLocation
91+
? `${upperFirst(category)} data for ${
92+
currentLocation
93+
} coming soon`
94+
: 'Please select a country'
95+
}
9196
icon
9297
/>
9398
)}

app/javascript/pages/country/router.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { connectRoutes } from 'redux-first-router';
1+
import { connectRoutes, NOT_FOUND, redirect } from 'redux-first-router';
22
import createHistory from 'history/createBrowserHistory';
33
import queryString from 'query-string';
44
import { setWidgetSettingsStore } from 'pages/country/widget/widget-actions';
@@ -26,6 +26,10 @@ export const routes = {
2626
},
2727
[COUNTRY]: {
2828
path: '/country/:country/:region?/:subRegion?'
29+
},
30+
[NOT_FOUND]: {
31+
path: '/404',
32+
thunk: dispatch => dispatch(redirect({ type: COUNTRY }))
2933
}
3034
};
3135

app/views/layouts/about.html.erb

-42
This file was deleted.

0 commit comments

Comments
 (0)