import { useDispatch, useSelector } from "../components/FinsembleProvider";
import { FavoriteActions } from "../actions/favoriteActions";
/**
 * The useFavorites() hook is used by FavoriteMaker to interact with the redux store.
 */
export const useFavorites = () => {
    const dispatch = useDispatch();
    const { favorites } = useSelector((state) => state.favorite);
    const favoritesIds = favorites.map((fav) => fav.id);
    const addFavorite = (favorite) => {
        dispatch(FavoriteActions.ADD_FAVORITE(favorite));
    };
    const removeFavorite = (id) => {
        dispatch(FavoriteActions.REMOVE_FAVORITE(id));
    };
    const isFavorited = (id) => favoritesIds.includes(id);
    return {
        favorites,
        addFavorite,
        removeFavorite,
        isFavorited,
    };
};
//# sourceMappingURL=useFavorites.js.map