import type { FC } from 'react'; import { useEffect } from 'react'; import { Message } from '../../src/utils/Message'; import { Result } from '../../src/utils/Result'; import { SearchField } from '../../src/utils/SearchField'; import { SimpleCard } from '../../src/utils/SimpleCard'; import { ShlinkApiError } from '../common/ShlinkApiError'; import { DomainRow } from './DomainRow'; import type { EditDomainRedirects } from './reducers/domainRedirects'; import type { DomainsList } from './reducers/domainsList'; interface ManageDomainsProps { listDomains: Function; filterDomains: (searchTerm: string) => void; editDomainRedirects: (redirects: EditDomainRedirects) => Promise; checkDomainHealth: (domain: string) => void; domainsList: DomainsList; } const headers = ['', 'Domain', 'Base path redirect', 'Regular 404 redirect', 'Invalid short URL redirect', '', '']; export const ManageDomains: FC = ( { listDomains, domainsList, filterDomains, editDomainRedirects, checkDomainHealth }, ) => { const { filteredDomains: domains, defaultRedirects, loading, error, errorData } = domainsList; const resolvedDefaultRedirects = 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()} ); };