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.

18 lines
732 B

import { deleteFavoriteCity } from "../../asyncStorange/deleteFavoriteCityStorage";
import { storeFavoriteCity } from "../../asyncStorange/storeFavoriteCity";
import { City } from "../../data/stub";
import { setFavoriteCity } from "./setFavoriteCity";
export const addFavoriteCity = (city : City | null) => {
return async dispatch => {
try {
await deleteFavoriteCity()
await storeFavoriteCity(city)
dispatch(setFavoriteCity(city))
} catch (error) {
console.log('Error---------', error);
//You can dispatch to another action if you want to display an error message in the application
//dispatch(fetchDataRejected(error))
}
}
}