boredgame/src/lib/util/manipulateCollection.ts

21 lines
666 B
TypeScript
Raw Normal View History

import { collectionStore } from '$lib/stores/collectionStore';
import { toast } from '$lib/components/toast/toast';
import { ToastType, type GameType, type SavedGameType } from '$lib/types';
function convertToSavedGame(game: GameType): SavedGameType {
return {
id: game.id,
name: game.name,
};
}
export function addToCollection(game: GameType) {
collectionStore.add(convertToSavedGame(game));
2022-07-29 00:34:34 +00:00
toast.send("Added to collection", { duration: 3000, type: ToastType.INFO });
}
export function removeFromCollection(game: GameType) {
2022-07-28 00:05:54 +00:00
collectionStore.remove(game.id);
2022-07-29 00:34:34 +00:00
toast.send("Removed from collection", { duration: 3000, type: ToastType.INFO });
2022-07-28 00:05:54 +00:00
}