import { FC, useEffect } from 'react'; import Message from '../utils/Message'; import { Result } from '../utils/Result'; import { ShlinkApiError } from '../api/ShlinkApiError'; import { SimpleCard } from '../utils/SimpleCard'; import SearchField from '../utils/SearchField'; import { ShlinkDomainRedirects } from '../api/types'; import { DomainsList } from './reducers/domainsList'; import { DomainRow } from './DomainRow'; interface ManageDomainsProps { listDomains: Function; filterDomains: (searchTerm: string) => void; editDomainRedirects: (domain: string, redirects: Partial) => Promise; domainsList: DomainsList; } const headers = [ '', 'Domain', 'Base path redirect', 'Regular 404 redirect', 'Invalid short URL redirect', '' ]; export const ManageDomains: FC = ( { listDomains, domainsList, filterDomains, editDomainRedirects }, ) => { const { filteredDomains: domains, loading, error, errorData } = domainsList; const defaultRedirects = domains.find(({ isDefault }) => isDefault)?.redirects; useEffect(() => { listDomains(); }, []); if (loading) { return ; } const renderContent = () => { if (error) { return ( ); } return ( {headers.map((column, index) => )} {domains.length < 1 && } {domains.map((domain) => ( ))}
{column}
No results found
); }; return ( <> {renderContent()} ); };