You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
854 B
26 lines
854 B
import { City } from "../../data/stub";
|
|
import { ADD_FAVORITE_CITY, FETCH_FAVORITE_CITY, FETCH_WEATHER, GET_FAVORITE_CITY, GET_WEATHER } from "../constants";
|
|
|
|
const initialState = {
|
|
weatherList : [],
|
|
favoriteCity: null,
|
|
}
|
|
|
|
const appReducer = (state = initialState, action) => {
|
|
switch (action.type) {
|
|
case ADD_FAVORITE_CITY:
|
|
return {...state, favoriteCity: state.favoriteCity};
|
|
case FETCH_WEATHER:
|
|
return {...state, weatherList: action.payload};
|
|
case FETCH_FAVORITE_CITY:
|
|
return {...state, favoriteCity: action.payload}
|
|
case GET_FAVORITE_CITY:
|
|
return {...state, favoriteCity: state.favoriteCity}
|
|
case GET_WEATHER:
|
|
return {...state, weatherList: state.weatherList}
|
|
default:
|
|
return state;
|
|
}
|
|
}
|
|
|
|
export default appReducer; |