import React from 'react'; import { Playlist, ServerType, PlexServerConnection } from '../types'; import PlaylistCard from './PlaylistCard'; import { RefreshCw, Server, Cloud, WifiOff, X } from 'lucide-react'; interface ServerPanelProps { type: ServerType; playlists: Playlist[]; isLoading: boolean; onRefresh: () => void; onCancel?: () => void; serverInfo?: PlexServerConnection; } const ServerPanel: React.FC = ({ type, playlists, isLoading, onRefresh, onCancel, serverInfo }) => { const isLocal = type === ServerType.LOCAL; let Icon = isLocal ? Server : Cloud; let headerColor = isLocal ? 'text-blue-400' : 'text-green-400'; const borderColor = isLocal ? 'border-blue-500/30' : 'border-green-500/30'; const bgGradient = isLocal ? 'bg-gradient-to-br from-gray-800/80 to-gray-900/80' : 'bg-gradient-to-bl from-gray-800/80 to-gray-900/80'; // Resolve Title and Subtitle Logic let displayTitle = ''; let displaySubtitle: React.ReactNode = null; if (isLocal) { displayTitle = 'Local Server'; displaySubtitle = (

{playlists.length} Playlists

); } else { // Cloud Logic if (serverInfo) { if (serverInfo.isConnected) { displayTitle = serverInfo.name || 'Cloud Server'; displaySubtitle = (
{serverInfo.libraryName} {serverInfo.ip}:{serverInfo.port}
); } else { displayTitle = 'Not Connected'; Icon = WifiOff; headerColor = 'text-red-400'; displaySubtitle = (

Connection failed

); } } else { displayTitle = 'Cloud Server'; displaySubtitle = (

{isLoading ? 'Connecting...' : 'Waiting...'}

); } } // Handle Refresh/Cancel Click const handleAction = () => { if (isLoading && onCancel) { onCancel(); } else { onRefresh(); } }; return (
{/* Header */}
{/* Title Group */}
{/* Icon Box */}
{/* Text Container */}

{displayTitle}

{displaySubtitle}
{/* Refresh/Stop Button */}
{/* Content List */}
{isLoading && playlists.length === 0 ? (

Syncing...

) : playlists.length === 0 ? (

No playlists found.

) : (
{playlists.map((playlist) => ( ))}
)}
); }; export default ServerPanel;