From e02b1c93e1b1fca5e7188d7fb19861c063ba6aec Mon Sep 17 00:00:00 2001 From: Franc Camps-Febrer Date: Mon, 3 Dec 2018 16:40:27 +0000 Subject: [PATCH] Add narrative schemas --- .gitignore | 1 + src/actions/index.js | 13 ++++++++++--- src/components/Dashboard.jsx | 2 +- src/components/Notification.jsx | 4 ++-- src/js/map/map.js | 1 - src/reducers/schema/narrativeSchema.js | 9 +++++++++ src/reducers/utils/validators.js | 10 +++++++++- src/selectors/index.js | 7 ++++--- 8 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 src/reducers/schema/narrativeSchema.js diff --git a/.gitignore b/.gitignore index 12b0846..4ce2e5c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/ node_modules/ config.js +dev.config.js diff --git a/src/actions/index.js b/src/actions/index.js index 77ead1b..e065b25 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -52,6 +52,10 @@ export function fetchDomain () { .then(response => response.json()) .catch(handleError('categories')) + const narPromise = fetch(NARRATIVE_URL) + .then(response => response.json()) + .catch(handleError('narratives')) + let sitesPromise = Promise.resolve([]) if (process.env.features.USE_SITES) { sitesPromise = fetch(SITES_URL) @@ -66,14 +70,16 @@ export function fetchDomain () { .catch(handleError('tags')) } - return Promise.all([ eventPromise, catPromise, sitesPromise, tagsPromise]) + return Promise.all([eventPromise, catPromise, narPromise, + sitesPromise, tagsPromise]) .then(response => { dispatch(toggleFetchingDomain()) const result = { events: response[0], categories: response[1], - sites: response[2], - tags: response[3], + narratives: response[2], + sites: response[3], + tags: response[4], notifications } return result @@ -102,6 +108,7 @@ export function updateDomain(domain) { categories: domain.categories, tags: domain.tags, sites: domain.sites, + narratives: domain.narratives, notifications: domain.notifications } } diff --git a/src/components/Dashboard.jsx b/src/components/Dashboard.jsx index 783fd78..1e758f2 100644 --- a/src/components/Dashboard.jsx +++ b/src/components/Dashboard.jsx @@ -67,7 +67,7 @@ class Dashboard extends React.Component { } getNarrativeLinks(event) { - const narrative = this.props.domain.narratives.find(nv => nv.key === event.narrative); + const narrative = this.props.domain.narratives.find(nv => nv.id === event.narrative); if (narrative) return narrative.byId[event.id]; return null; } diff --git a/src/components/Notification.jsx b/src/components/Notification.jsx index 260befa..1bee1b9 100644 --- a/src/components/Notification.jsx +++ b/src/components/Notification.jsx @@ -48,7 +48,7 @@ export default class Notification extends React.Component{ return (
{this.props.notifications.map((notification) => { - +console.log(notification) return (
this.toggleDetails() }>