21 lines
601 B
TypeScript
21 lines
601 B
TypeScript
import { useFavoriteStore } from "@/store/favorites"
|
|
|
|
export function listFavorites() {
|
|
return useFavoriteStore.getState().favorites
|
|
}
|
|
|
|
export function listFavoritesByUser(userId: string) {
|
|
return useFavoriteStore.getState().favorites.filter((favorite) => favorite.userId === userId)
|
|
}
|
|
|
|
export function isFavorited(userId: string, targetType: "player" | "shop", targetId: string) {
|
|
return useFavoriteStore
|
|
.getState()
|
|
.favorites.some(
|
|
(favorite) =>
|
|
favorite.userId === userId &&
|
|
favorite.targetType === targetType &&
|
|
favorite.targetId === targetId,
|
|
)
|
|
}
|