-
Notifications
You must be signed in to change notification settings - Fork 52
/
App.js
77 lines (68 loc) · 1.89 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from 'react';
import './App.css';
import Divider from '@material-ui/core/Divider';
import Providers from './Providers.js';
import Frontend from './Frontend.js';
import Services from './Services.js';
import GenerateButton from './GenerateButton.js';
import Complete from './Complete.js';
import axios from 'axios';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
success: null,
provider: 'aws',
frontend: 'react',
services: [
{
name: "test service 1",
description: "Things.",
language: "go"
}
]
};
}
setProvider = (p) => {
this.setState({ provider: p });
}
setFrontend = (f) => {
this.setState({ frontend: f });
}
addServices = (s) => {
this.setState({ services: [1] });
}
generate = () => {
let self = this;
axios.post('http://localhost:8080/v1/generate', {
frontendFramework: this.state.frontend,
})
.then(function (response) {
// handle success
console.log(response);
this.setState({success: true});
})
.catch(function (error) {
// handle error
console.log(error);
self.setState({success: false});
})
.finally(function () {
// always executed
});
}
render() {
console.log(this.state);
return (
<div className="App">
<h1>Commit0 - Create a new project</h1>
<Providers provider={this.state.provider} setProvider={this.setProvider} />
<Frontend frontend={this.state.frontend} setFrontend={this.setFrontend} />
<Services services={this.state.services} addService={this.addService} />
<Divider variant="middle" />
<GenerateButton generate={this.generate} />
{this.state.success !== null && <Complete succes={this.state.success} />}
</div>
);
}
}