import { FC } from 'react'; import { Button } from 'reactstrap'; import { NoMenuLayout } from '../common/NoMenuLayout'; import { ServerForm } from './helpers/ServerForm'; import { withSelectedServer } from './helpers/withSelectedServer'; import { isServerWithId, ServerData } from './data'; interface EditServerProps { editServer: (serverId: string, serverData: ServerData) => void; } export const EditServer = (ServerError: FC) => withSelectedServer(( { editServer, selectedServer, history: { goBack } }, ) => { if (!isServerWithId(selectedServer)) { return null; } const handleSubmit = (serverData: ServerData) => { editServer(selectedServer.id, serverData); goBack(); }; return ( Edit "{selectedServer.name}"} initialValues={selectedServer} onSubmit={handleSubmit} > ); }, ServerError);