import React from 'react'; import { Playlist, ServerType, PlexServerConnection } from '../types'; import PlaylistCard from './PlaylistCard'; import { RefreshCw, Server, Cloud, WifiOff } from 'lucide-react'; interface ServerPanelProps { type: ServerType; playlists: Playlist[]; isLoading: boolean; onRefresh: () => void; serverInfo?: PlexServerConnection; } const ServerPanel: React.FC = ({ type, playlists, isLoading, onRefresh, 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...'}

); } } return (
{/* Header */} {/* Mobile: Order Last (Right side), Vertical Text */} {/* Desktop: Order First (Top side), Horizontal Text */}
{/* Title Group */}
{/* Icon Box */}
{/* Text Container - Vertical on Mobile, Horizontal on Desktop */}
{/* Use vertical-rl for vertical text flow, rotate-180 to flip it bottom-up */}

{displayTitle}

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

Syncing...

) : playlists.length === 0 ? (

No playlists found.

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