Completed
Pull Request — master (#227)
by Alejandro
06:25
created

src/servers/EditServer.js

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 35
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 0
eloc 28
mnd 0
bc 0
fnc 0
dl 0
loc 35
ccs 9
cts 9
cp 1
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import React from 'react';
2
import PropTypes from 'prop-types';
3
import { ServerForm } from './helpers/ServerForm';
4
import { withSelectedServer } from './helpers/withSelectedServer';
5
import { serverType } from './prop-types';
6
7 1
const propTypes = {
8
  editServer: PropTypes.func,
9
  selectedServer: serverType,
10
  history: PropTypes.shape({
11
    push: PropTypes.func,
12
  }),
13
};
14
15 1
export const EditServer = (ServerError) => {
16 2
  const EditServerComp = ({ editServer, selectedServer, history: { push } }) => {
17 2
    const handleSubmit = (serverData) => {
18 1
      editServer(selectedServer.id, serverData);
19 1
      push(`/server/${selectedServer.id}/list-short-urls/1`);
20
    };
21
22 2
    return (
23
      <div className="create-server">
24
        <ServerForm initialValues={selectedServer} onSubmit={handleSubmit}>
25
          <button className="btn btn-outline-primary">Save</button>
26
        </ServerForm>
27
      </div>
28
    );
29
  };
30
31 2
  EditServerComp.propTypes = propTypes;
32
33 2
  return withSelectedServer(EditServerComp, ServerError);
34
};
35