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
812 B

import { City } from "../../data/stub";
import { ADD_FAVORITE_CITY, FETCH_FAVORITE_CITY, FETCH_WEATHER, GET_WEATHER } from "../constants";
const initialState = {
weatherList : [],
favoriteCity: null,
}
const appReducer = (state = initialState, action) => {
switch (action.type) {
case ADD_FAVORITE_CITY:
// @ts-ignore
return {...state, favoriteCity: state.favoriteCity = action.payload};
case FETCH_WEATHER:
// @ts-ignore
return {...state, weatherList: action.payload};
case FETCH_FAVORITE_CITY:
return {...state, favoriteCity: state.favoriteCity}
case GET_WEATHER:
return {...state, weatherList: state.weatherList}
default:
return state;
}
}
export default appReducer;