From f4a0e88199530fc1729a493f62a66a3859fb8ca3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 7 Nov 2018 08:22:26 +0100 Subject: [PATCH] Images URL at the context --- Dashboard.js | 28 ++++++++++++++++++++++++++-- ProductCard.js | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Dashboard.js b/Dashboard.js index 6ac455f36..6ab33d3d5 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -238,12 +238,15 @@ function newDashboard() { } ` + let teams; + const getTeams = () => { return new Promise((resolve, reject) => { apolloClientTeams.query({ query: ALL_TEAMS_QUERY }) - .then(response => { + .then(response => { + teams = response.data.teams_Teams; window.localStorage.setItem('Teams', JSON.stringify(response.data.teams_Teams)); resolve({ teams: response.data.teams_Teams }) }) @@ -263,7 +266,28 @@ function newDashboard() { // When all asynchronous fetches resolve, authenticate user or throw error. Promise.all(fetchDataPromises).then(result => { - /* All good */ + /* All good, we will go through the results creating a map with all the Images URLs */ + + + console.log("TEAMS", teams); + + let teamProfileImages = new Map(); + let fbProfileImages = new Map(); + + for (let i = 0; i < teams.edges.lenght; i++) { + + let team = teams.edges[i].node; + + teamProfileImages.set(team.slug, team.profile.avatar) + fbProfileImages.set(team.fb[0].slug, team.fb[0].avatar) + + } + + console.log("TEAM PROFILES", JSON.stringify(teamProfileImages)); + console.log("FB PROFILES", JSON.stringify(fbProfileImages)); + + window.canvasApp.context.teamProfileImages = teamProfileImages; + window.canvasApp.context.fbProfileImages = fbProfileImages; callBack(); diff --git a/ProductCard.js b/ProductCard.js index 0d0b8d389..6ee8de1d3 100644 --- a/ProductCard.js +++ b/ProductCard.js @@ -241,7 +241,7 @@ } teamAvatar.src = STORAGE_URL + "/" + TEAM + "/" + TEAM + "-" + "avatar.jpg"; - + console.log("TEAM NAME", TEAM); /* TODO Temporary code: Here we will temporary download the images of bots uploaded at the Teams Module. */