import React, { useState } from 'react'; import { defineMessages, FormattedMessage } from 'react-intl'; import Badge from '../Common/Badge'; import Button from '../Common/Button'; import useSWR from 'swr'; import type { RadarrSettings, SonarrSettings, } from '../../../server/lib/settings'; import LoadingSpinner from '../Common/LoadingSpinner'; import RadarrModal from './RadarrModal'; interface ServerInstanceProps { name: string; isDefault?: boolean; isDefault4K?: boolean; address: string; isSSL?: boolean; profileName: string; isSonarr?: boolean; onEdit: () => void; onDelete: () => void; } const ServerInstance: React.FC = ({ name, address, profileName, isDefault4K = false, isDefault = false, isSSL = false, isSonarr = false, onEdit, onDelete, }) => { return (
  • {name}

    {isDefault && Default} {isDefault4K && Default 4K} {isSSL && SSL}

    Address {address}

    Active Profile {profileName}

  • ); }; const SettingsServices: React.FC = () => { const { data: radarrData, error: radarrError, revalidate: revalidateRadarr, } = useSWR('/api/v1/settings/radarr'); const { data: sonarrData, error: sonarrError } = useSWR( '/api/v1/settings/sonarr' ); const [editRadarrModal, setEditRadarrModal] = useState<{ open: boolean; radarr: RadarrSettings | null; }>({ open: false, radarr: null, }); return ( <>

    Radarr Settings

    Configure your Radarr connection below. You can have multiple Radarr configurations but only two can be active as defaults at any time (one for standard HD and one for 4K). Administrations can override a titles connection to use in the manage title screen.

    {editRadarrModal.open && ( setEditRadarrModal({ open: false, radarr: null })} onSave={() => { revalidateRadarr(); setEditRadarrModal({ open: false, radarr: null }); }} /> )}
    {!radarrData && !radarrError && } {radarrData && !radarrError && (
      {radarrData.map((radarr) => ( setEditRadarrModal({ open: true, radarr })} onDelete={() => console.log('delete clicked')} /> ))}
    )}

    Sonarr Settings

    Configure your Sonarr connection below. You can have multiple Sonarr configurations but only two can be active as defaults at any time (one for standard HD and one for 4K). Administrations can override a titles connection to use in the manage title screen.

    {!sonarrData && !sonarrError && } {sonarrData && !sonarrError && (
      {sonarrData.map((sonarr) => ( console.log('nada')} onDelete={() => console.log('delete clicked')} /> ))}
    )}
    ); }; export default SettingsServices;