From 78639ad0a574e07191bbc3ab6c46543f6fc93a07 Mon Sep 17 00:00:00 2001 From: Madhushree Gupta Date: Wed, 23 Dec 2020 15:34:06 +0000 Subject: [PATCH 1/2] functions added --- src/data/data-provider.js | 51 ++++++++++++++++++++------- src/main.js | 2 -- src/views/Home.vue | 3 +- src/views/Ins.vue | 72 +++++++++++++++++++++------------------ 4 files changed, 78 insertions(+), 50 deletions(-) diff --git a/src/data/data-provider.js b/src/data/data-provider.js index ad97b0e..689faa8 100644 --- a/src/data/data-provider.js +++ b/src/data/data-provider.js @@ -1,22 +1,47 @@ const data = require('./ins-data.json') -//TODO: Fill with countries taken from the data object -export function getCountries() { - //Dummy answer - return ['Kenya', 'Tanzania'] +// TODO: Fill with countries taken from the data object +export function getCountries () { + let country = [] + data.map((item, index, obj) => { + if (index === 0) { + country.push(item.country) + } else if (item.country !== obj[index - 1].country) { + country.push(item.country) + } + }) + return country + // Dummy answer + // return ['Kenya', 'Tanzania'] } -//TODO: Fill with camps taken from the data object filtered by country -export function getCamps(country) { - //Dummy answer - return ['Kakuma', 'Omaka'] +// TODO: Fill with camps taken from the data object filtered by country +export function getCamps (country) { + let camps = [] + const newData = data.filter(item => item.country === country) + newData.map(item => camps.push(item.camp)) + return camps + + // Dummy answer + // return ['Kakuma', 'Omaka'] } -//TODO: Fill with total lessons taken from the data object filtered by country -export function getLessonsByYear(country) { - //Dummy answer +// TODO: Fill with total lessons taken from the data object filtered by country +export function getLessonsByYear (country) { + const newData = data.filter(item => item.country === country) + let years = [] + let lessons = [] + newData.map(item => { + years.push(item.year) + lessons.push(item.lessons) + }) return { - years: ['2018', '2019', '2020'], - lessons: [100, 150, 130] + years, + lessons } + // Dummy answer + // return { + // years: ['2018', '2019', '2020'], + // lessons: [100, 150, 130] + // } } diff --git a/src/main.js b/src/main.js index 1622926..a1c815c 100644 --- a/src/main.js +++ b/src/main.js @@ -8,8 +8,6 @@ import 'vue-select/dist/vue-select.css' Vue.component('row', Row) Vue.component('column', Column) - - Vue.component('v-select', vSelect) Vue.config.productionTip = false diff --git a/src/views/Home.vue b/src/views/Home.vue index 85b593b..c93267b 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -9,8 +9,7 @@ diff --git a/src/views/Ins.vue b/src/views/Ins.vue index 1eb5693..9ed5f01 100644 --- a/src/views/Ins.vue +++ b/src/views/Ins.vue @@ -4,9 +4,9 @@ Countries: - + Camps: - + Schools: @@ -20,46 +20,52 @@ -