import React, { useState, useEffect } from 'react'; import { Card, CardContent, Typography, Box, Avatar, IconButton, Tooltip, Chip, Dialog, DialogTitle, DialogContent, TextField, DialogActions, Button } from '@mui/material'; import BoltIcon from '@mui/icons-material/Bolt'; import TimerIcon from '@mui/icons-material/Timer'; import OpenInNewIcon from '@mui/icons-material/OpenInNew'; import DeleteIcon from '@mui/icons-material/Delete'; interface SteamCardProps { account: { _id: string; steamId: string; personaName: string; loginName?: string; steamLoginSecure?: string; autoCheckCooldown: boolean; accountType: 'owned' | 'watched'; avatar: string; profileUrl?: string; status?: string; vacBanned: boolean; gameBans: number; lastBanCheck: string; cooldownExpiresAt?: string; }; onDelete: (id: string) => void; onUpdate: (id: string, data: any) => void; onFastLogin: () => void; } const SteamCard: React.FC = ({ account, onDelete, onUpdate, onFastLogin }) => { const [timeLeft, setTimeLeft] = useState(null); const [isLoginNameDialogOpen, setIsLoginNameDialogOpen] = useState(false); const [tempLoginName, setTempLoginName] = useState(account.loginName || ''); const isOwned = account.accountType === 'owned'; const isPermanentlyBanned = account.vacBanned || account.gameBans > 0 || account.status === 'banned'; const cooldownDate = account.cooldownExpiresAt ? new Date(account.cooldownExpiresAt) : null; const isCooldownActive = cooldownDate && !isNaN(cooldownDate.getTime()) && cooldownDate.getTime() > Date.now(); useEffect(() => { if (!isCooldownActive || !cooldownDate) { setTimeLeft(null); return; } const timer = setInterval(() => { const now = new Date(); const diff = cooldownDate.getTime() - now.getTime(); if (diff <= 0) { setTimeLeft(null); clearInterval(timer); return; } const hours = Math.floor(diff / 3600000); const mins = Math.floor((diff % 3600000) / 60000); const secs = Math.floor((diff % 60000) / 1000); setTimeLeft(`${hours}h ${mins}m ${secs}s`); }, 1000); return () => clearInterval(timer); }, [account.cooldownExpiresAt, isCooldownActive, cooldownDate]); const getStatusColor = () => { if (isPermanentlyBanned) return '#af3212'; if (isCooldownActive) return '#ff9800'; return '#5c7e10'; }; const getStatusText = () => { if (account.vacBanned) return 'VAC BANNED'; if (account.gameBans > 0) return `${account.gameBans} GAME BAN${account.gameBans > 1 ? 'S' : ''}`; if (isPermanentlyBanned) return 'BANNED'; if (isCooldownActive) return 'COOLDOWN'; return 'AVAILABLE'; }; const handleFastLoginClick = () => { if (!account.loginName) { setIsLoginNameDialogOpen(true); return; } onFastLogin(); }; return ( {account.personaName || 'Unknown'} {timeLeft && ( {timeLeft} )} {isOwned && ( )} onDelete(account._id)}> setIsLoginNameDialogOpen(false)}> Steam Login Name setTempLoginName(e.target.value)} /> ); }; export default SteamCard;