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:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user