mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-09 01:37:24 +03:00
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { FC } from 'react';
|
|
import { Button } from 'reactstrap';
|
|
import { NoMenuLayout } from '../common/NoMenuLayout';
|
|
import { useGoBack } from '../utils/helpers/hooks';
|
|
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<EditServerProps>(({ editServer, selectedServer }) => {
|
|
const goBack = useGoBack();
|
|
|
|
if (!isServerWithId(selectedServer)) {
|
|
return null;
|
|
}
|
|
|
|
const handleSubmit = (serverData: ServerData) => {
|
|
editServer(selectedServer.id, serverData);
|
|
goBack();
|
|
};
|
|
|
|
return (
|
|
<NoMenuLayout>
|
|
<ServerForm
|
|
title={<h5 className="mb-0">Edit "{selectedServer.name}"</h5>}
|
|
initialValues={selectedServer}
|
|
onSubmit={handleSubmit}
|
|
>
|
|
<Button outline className="mr-2" onClick={goBack}>Cancel</Button>
|
|
<Button outline color="primary">Save</Button>
|
|
</ServerForm>
|
|
</NoMenuLayout>
|
|
);
|
|
}, ServerError);
|