import CollectionAdminDto from "Frontend/generated/org/gameyfin/app/collections/dto/CollectionAdminDto"; import React, {useEffect, useState} from "react"; import GameDto from "Frontend/generated/org/gameyfin/app/games/dto/GameDto"; import {useSnapshot} from "valtio/react"; import {gameState} from "Frontend/state/GameState"; import IconBackgroundPattern from "Frontend/components/general/IconBackgroundPattern"; import {Card} from "@heroui/react"; interface CollectionHeaderProps { collection: CollectionAdminDto; className?: string; } export default function CollectionHeader({collection, className}: CollectionHeaderProps) { const MAX_COVER_COUNT = 5; const state = useSnapshot(gameState); const [randomGames, setRandomGames] = useState([]); useEffect(() => { if (!state.randomlyOrderedGamesByCollectionId) return; setRandomGames(getRandomGames()); }, [state]); function getRandomGames() { if (!state.randomlyOrderedGamesByCollectionId[collection.id]) return []; const games = state.randomlyOrderedGamesByCollectionId[collection.id] .filter(game => game.images && game.images.length > 0); if (!games) return []; return games.slice(0, MAX_COVER_COUNT); } return (
{randomGames.map((game, idx) => (
{`Image
))}

{collection.name}

); }