"use client"; import Image from "next/image"; import { useEffect } from "react"; import { ModalPrices, ModalReviews, ModalScreenshots } from "@/components/game-profile-sections"; import { formatReleaseDate, selectGameView, type ModalDict } from "@/lib/game/game-format"; import { steamdbAppUrl } from "@/lib/game/discord-app"; import type { Locale } from "@/lib/i18n/locales"; import { useGameProfile } from "@/hooks/use-game-profile"; export function GameProfileModal({ applicationId, heroSeed, lang, iconUrl, fallbackName, fallbackGameUrl, dict, onClose, }: { applicationId: string; heroSeed: number; lang: Locale; iconUrl: string | null; fallbackName: string; fallbackGameUrl: string; dict: ModalDict; onClose: () => void; }) { const { profile, failed, localeTag, hero, hasDetails, partialFail, isDeterministicMiss, canRetry, retry, reset, setBannerPick, } = useGameProfile(applicationId, lang, heroSeed); useEffect(() => { function onKey(event: KeyboardEvent): void { if (event.key === "Escape") { onClose(); } } document.addEventListener("keydown", onKey); const previous = document.body.style.overflow; document.body.style.overflow = "hidden"; return () => { document.removeEventListener("keydown", onKey); document.body.style.overflow = previous; }; }, [onClose]); const { gameUrl, name, bestPrice, historyLow, isFree } = selectGameView( profile, fallbackName, fallbackGameUrl, ); return (
{dict.loading}
) : null} {failed && !profile ? ({dict.loadError}
{dict.noGameData}
{dict.partialFail}
{profile.description}
) : null}