import { Button, Input, Modal, ModalBody, ModalContent, Table, TableBody, TableCell, TableColumn, TableHeader, TableRow, Tooltip } from "@heroui/react"; import React, {useEffect, useState} from "react"; import {ArrowRight, MagnifyingGlass} from "@phosphor-icons/react"; import {GameEndpoint} from "Frontend/generated/endpoints"; import GameSearchResultDto from "Frontend/generated/org/gameyfin/app/games/dto/GameSearchResultDto"; import PluginIcon from "../plugin/PluginIcon"; interface EditGameMetadataModalProps { path: string; libraryId: number; replaceGameId?: number; initialSearchTerm: string; isOpen: boolean; onOpenChange: () => void; } export default function MatchGameModal({ path, libraryId, replaceGameId, initialSearchTerm, isOpen, onOpenChange }: EditGameMetadataModalProps) { const [searchTerm, setSearchTerm] = useState(""); const [searchResults, setSearchResults] = useState([]); const [isSearching, setIsSearching] = useState(false); const [isMatching, setIsMatching] = useState(null); useEffect(() => { setSearchTerm(initialSearchTerm); setSearchResults([]); }, [isOpen]); async function matchGame(result: GameSearchResultDto) { await GameEndpoint.matchManually(result.originalIds, path, libraryId, replaceGameId); } async function search() { setIsSearching(true); const results = await GameEndpoint.getPotentialMatches(searchTerm, true); setSearchResults(results); setIsSearching(false); } return ( {(onClose) => (
{path}
{ if (e.key === "Enter") { e.preventDefault(); await search(); } }} />
Title & Release Developer(s) Publisher(s) {/* width={1} keeps the column as far to the right as possible*/} Sources {(item) => ( {item.title} ({item.release ? new Date(item.release).getFullYear() : "unknown"})
{item.developers ? item.developers.map( developer =>

{developer}

) : "unknown"}
{item.publishers ? item.publishers.map( publisher =>

{publisher}

) : "unknown"}
{Object.values(item.originalIds).map( originalId => )}
)}
)}
); }