"use client"; import { SettingsSection, SettingsRow, SettingsSelect } from "../ui"; import { SystemSettings } from "../../types"; interface DownloadPreferencesSectionProps { settings: SystemSettings; onUpdate: (updates: Partial) => void; } export function DownloadPreferencesSection({ settings, onUpdate, }: DownloadPreferencesSectionProps) { // Service configuration detection const isLidarrConfigured = settings.lidarrEnabled === true && settings.lidarrUrl.trim() !== "" && settings.lidarrApiKey.trim() !== ""; const isSoulseekConfigured = settings.soulseekUsername.trim() !== "" && settings.soulseekPassword.trim() !== ""; const areBothServicesConfigured = isLidarrConfigured && isSoulseekConfigured; const isDisabled = !areBothServicesConfigured; // Dynamic fallback options based on primary source const getFallbackOptions = () => { if (settings.downloadSource === "soulseek") { return [ { value: "none", label: "Skip track" }, { value: "lidarr", label: "Download full album via Lidarr" }, ]; } else { return [ { value: "none", label: "Skip album" }, { value: "soulseek", label: "Try Soulseek for individual tracks" }, ]; } }; return ( onUpdate({ downloadSource: v as "soulseek" | "lidarr", primaryFailureFallback: "none" }) } options={[ { value: "soulseek", label: "Soulseek (Per-track)" }, { value: "lidarr", label: "Lidarr (Full albums)" }, ]} disabled={isDisabled} /> onUpdate({ primaryFailureFallback: v as "none" | "lidarr" | "soulseek", }) } options={getFallbackOptions()} disabled={isDisabled} /> onUpdate({ soulseekConcurrentDownloads: parseInt(v), }) } options={[ { value: "1", label: "1" }, { value: "2", label: "2" }, { value: "3", label: "3" }, { value: "4", label: "4 (Default)" }, { value: "5", label: "5" }, { value: "6", label: "6" }, { value: "7", label: "7" }, { value: "8", label: "8" }, { value: "9", label: "9" }, { value: "10", label: "10" }, ]} disabled={!isSoulseekConfigured} /> ); }