import {useState} from 'react'; import {Link} from 'react-router-dom'; import {useTranslation} from 'react-i18next'; import {Layers, Link2Off, Unlink} from 'lucide-react'; import {toast} from 'sonner'; import {Button} from '@/components/ui/button'; import {Card} from '@/components/ui/card'; import GameStatusBadge from './GameStatusBadge.jsx'; import FitText from './FitText.jsx'; import {splitGame, unlinkGame} from '../utils/links.js'; import {platformLabel} from '../utils/platforms.js'; /** * The other editions of this game in the own library, and the buttons to ask for a link (everyone), to split the game * off its set (everyone, for the own library) or to unlink (auditor). Shown on every game: a request must be possible * from any game. */ export default function EditionsCard({game, auditor, onRequest, onChanged}) { const {t} = useTranslation(); const [busy, setBusy] = useState(false); const run = async (call, doneKey) => { setBusy(true); try { const response = await call(game.appid); if (response.status === 401) return; if (response.ok) { toast.success(t(doneKey)); onChanged(); } else { toast.error(t('LINKS.ERROR')); } } catch (err) { console.error('Edition change error:', err); toast.error(t('INFO.ERROR.NETWORK_FAILURE')); } finally { setBusy(false); } }; return ( {game.editions?.length > 0 && (

{t('LINKS.ALSO_IN_LIBRARY')}

{t('LINKS.SHARED_STATUS')}

)}
{game.editions?.length > 0 && ( )} {auditor && game.linked && ( )}
); }