import React, { useEffect, useState } from 'react' import { invoke } from '@tauri-apps/api/core' import { Dialog, DialogHeader, DialogBody, DialogFooter, DialogActions, } from '@/components/dialogs' import { Button } from '@/components/buttons' import { Icon, info } from '@/components/icons' import VotesDisplay, { GameVotes } from '@/components/common/VotesDisplay' export interface SmokeAPIVotesDialogProps { visible: boolean gameId: string | null gameTitle: string | null onConfirm: () => void onClose: () => void } /** * Shown before installing SmokeAPI on a Proton game. * Fetches and displays community votes for SmokeAPI specifically, * then lets the user confirm or cancel the installation. */ const SmokeAPIVotesDialog: React.FC = ({ visible, gameId, gameTitle, onConfirm, onClose, }) => { const [votes, setVotes] = useState(null) const [loading, setLoading] = useState(false) useEffect(() => { if (!visible || !gameId) { setVotes(null) return } setLoading(true) invoke('get_game_votes', { gameId }) .then((results) => { setVotes(results.find((v) => v.unlocker === 'smokeapi') ?? null) }) .catch(() => setVotes(null)) .finally(() => setLoading(false)) }, [visible, gameId]) const hasVotes = votes && (votes.success > 0 || votes.fail > 0) return (

Install SmokeAPI

{gameTitle}

Community compatibility

{loading ? (

Fetching votes...

) : ( )}
{!loading && !hasVotes && (
No one has rated this game yet. You'll be able to submit a rating after installing.
)} {!loading && hasVotes && (
These ratings are from other CreamLinux users. Results may vary.
)}
) } export default SmokeAPIVotesDialog