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

import { City } from "../../data/stub";
import { ADD_FAVORITE_CITY, FETCH_CITY, FETCH_FAVORITE_CITY, GET_CITIES } from "../constants";
const initialState = {
city: [],
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_CITY:
// @ts-ignore
return {...state, city: action.payload};
case FETCH_FAVORITE_CITY:
return {...state, favoriteCity: state.favoriteCity}
case GET_CITIES:
return {...state, city: state.city}
default:
return state;
}
}
export default appReducer;