1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-11 18:32:50 +00:00

redux functionality for sensor page

This commit is contained in:
2016-09-14 20:44:04 +00:00
parent 2f45864fcc
commit e03b3eae25
4 changed files with 75 additions and 20 deletions

View File

@@ -29,6 +29,20 @@ function loadUniqueDates(dates){
}
}
export function setSelectedYearIndex(index){
return{
type: types.SET_SELECTED_YEAR_INDEX,
index
}
}
export function setSelectedMonthIndex(index){
return{
type: types.SET_SELECTED_MONTH_INDEX,
index
}
}
function fetchingList(){
return {
type: types.FETCHING_LIST
@@ -102,9 +116,15 @@ export function fetchUniqueDates(location){
.then(response => response.json())
.then(json => {
dispatch(loadUniqueDates(json));
if(json.length > 0){
let year = json[0].year;
let month = json[0].months[0].monthname;
dispatch(fetchSensorInfoYear(location, year));
dispatch(fetchSensorInfoMonth(location, year, month));
}
})
.catch(error => {
console.log(error);
});
}
}
}