import { FC } from 'react'; import AddMailServerForm from './AddMailServerForm'; import CrudList from '../CrudList'; import EditMailServerForm from './EditMailServerForm'; import { BodyText } from '../Text'; import useFetch from '../../hooks/useFetch'; const ManageMailServer: FC = () => { const { data: host, loading: loadingHost } = useFetch('/host/local'); return ( <> addHeader="Add mail server" editHeader={(entry) => `Update ${entry?.address}:${entry?.port}`} entriesUrl="/mail-server" getAddLoading={(previous) => previous || loadingHost} getDeleteErrorMessage={({ children, ...rest }) => ({ ...rest, children: <>Failed to delete mail server(s). {children}, })} getDeleteHeader={(count) => `Delete the following ${count} mail server(s)?` } getDeleteSuccessMessage={() => ({ children: <>Successfully deleted mail server(s)., })} listEmpty="No mail server(s) found" renderAddForm={(tools) => host && ( ) } renderDeleteItem={(mailServers, { key }) => { const ms = mailServers?.[key]; return ( {ms?.address}:{ms?.port} ); }} renderEditForm={(tools, mailServer) => mailServer && ( ) } renderListItem={(uuid, { address, port }) => ( {address}:{port} )} /> ); }; export default ManageMailServer;