Skip to content

Commit 4da7605

Browse files
committed
async order update
1 parent 06a7c52 commit 4da7605

File tree

15 files changed

+293
-162
lines changed

15 files changed

+293
-162
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"react-dom": "^16.13.1",
1313
"react-router-dom": "^5.1.2",
1414
"react-scripts": "3.4.1",
15+
"react-stomp": "^5.0.0",
1516
"sockjs-client": "^1.4.0"
1617
},
1718
"scripts": {

src/App.css

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import "./css/sb-admin-2.min.css";
33
import SideBar from "./components/sideBar";
44
import Header from "./components/header";
55
import MainPanel from "./components/mainPanel";
6-
import { BrowserRouter as Router, Link, Switch, Route } from "react-router-dom";
6+
import { BrowserRouter as Router } from "react-router-dom";
77

88
class App extends Component {
99
state = {};

src/components/card.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Card extends Component {
3232
{this.state.header}
3333
</div>
3434
<div className="h5 mb-0 font-weight-bold text-gray-800">
35-
{this.state.result}
35+
{this.props.result}
3636
</div>
3737
</div>
3838
</div>

src/components/createOrder.jsx

Lines changed: 81 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { Component } from "react";
22
import InstBlotter from "./instBlotter";
3-
import { Formik, FormikProps, Form, Field } from "formik";
43
import AppConfig from "../utils/constants";
54

65
class OrderComponent extends Component {
@@ -88,95 +87,93 @@ class OrderComponent extends Component {
8887

8988
render() {
9089
return (
91-
<div className="container">
92-
<div className="card o-hidden border-0 shadow-lg my-2">
93-
<div className="card-body p-0">
94-
<div className="row">
95-
<div className="col-lg-6">
96-
<div className="p-2">
97-
<div className="text-center">
98-
<h1 className="h4 text-gray-900 mb-4">Create new Order</h1>
90+
<div className="card o-hidden border-0 shadow-lg my-2">
91+
<div className="card-body">
92+
<div className="row">
93+
<div className="col-lg-10">
94+
<InstBlotter />
95+
</div>
96+
<div className="col-lg-6">
97+
<div className="p-2">
98+
<div className="text-center">
99+
<h1 className="h4 text-gray-900 mb-4">Create new Order</h1>
100+
</div>
101+
<form className="user">
102+
<div className="form-group row">
103+
<div className="col-sm-6 mb-3 mb-sm-0">
104+
<input
105+
type="text"
106+
className="form-control form-control-user"
107+
id="ticker"
108+
placeholder="Ticker"
109+
onBlur={this.handleFormPropertyChange}
110+
/>
111+
</div>
112+
<div className="col-sm-6">
113+
<input
114+
type="text"
115+
className="form-control form-control-user"
116+
id="issuer"
117+
placeholder="Issuer"
118+
disabled="true"
119+
value={this.state.issuer}
120+
/>
121+
</div>
99122
</div>
100-
<form className="user">
101-
<div className="form-group row">
102-
<div className="col-sm-6 mb-3 mb-sm-0">
103-
<input
104-
type="text"
105-
className="form-control form-control-user"
106-
id="ticker"
107-
placeholder="Ticker"
108-
onBlur={this.handleFormPropertyChange}
109-
/>
110-
</div>
111-
<div className="col-sm-6">
112-
<input
113-
type="text"
114-
className="form-control form-control-user"
115-
id="issuer"
116-
placeholder="Issuer"
117-
disabled="true"
118-
value={this.state.issuer}
119-
/>
120-
</div>
123+
<div className="form-group row">
124+
<div className="col-sm-6 mb-3 mb-sm-0">
125+
<input
126+
type="text"
127+
className="form-control form-control-user"
128+
id="quantity"
129+
placeholder="quantity"
130+
onBlur={this.handleFormPropertyChange}
131+
/>
121132
</div>
122-
<div className="form-group row">
123-
<div className="col-sm-6 mb-3 mb-sm-0">
124-
<input
125-
type="text"
126-
className="form-control form-control-user"
127-
id="quantity"
128-
placeholder="quantity"
129-
onBlur={this.handleFormPropertyChange}
130-
/>
131-
</div>
132-
<div className="col-sm-6 mb-3 mb-sm-0">
133-
<input
134-
type="text"
135-
className="form-control form-control-user"
136-
id="price"
137-
placeholder="Price"
138-
onBlur={this.handleFormPropertyChange}
139-
/>
140-
</div>
133+
<div className="col-sm-6 mb-3 mb-sm-0">
134+
<input
135+
type="text"
136+
className="form-control form-control-user"
137+
id="price"
138+
placeholder="Price"
139+
onBlur={this.handleFormPropertyChange}
140+
/>
141141
</div>
142-
<div className="form-group row">
143-
<div className="col-sm-6 mb-3 mb-sm-0">
144-
<select
145-
className="form-control form-control-user"
146-
id="buySell"
147-
onBlur={this.handleFormPropertyChange}
148-
>
149-
<option value="B">Buy</option>
150-
<option value="S">Sell</option>
151-
</select>
152-
</div>
153-
<div className="col-sm-6 mb-3 mb-sm-0">
154-
<input
155-
type="text"
156-
className="form-control form-control-user"
157-
id="tradeDate"
158-
placeholder="date "
159-
onBlur={this.handleFormPropertyChange}
160-
/>
161-
</div>
142+
</div>
143+
<div className="form-group row">
144+
<div className="col-sm-6 mb-3 mb-sm-0">
145+
<select
146+
className="form-control form-control-user"
147+
id="buySell"
148+
onBlur={this.handleFormPropertyChange}
149+
>
150+
<option value="B">Buy</option>
151+
<option value="S">Sell</option>
152+
</select>
162153
</div>
163-
<a
164-
href="#"
165-
className="btn btn-primary btn-user"
166-
onClick={this.handleSubmit}
167-
>
168-
Create
169-
</a>
170-
</form>
171-
</div>
172-
</div>
173-
<div className="col-lg-6 col-xl">
174-
<InstBlotter />
154+
<div className="col-sm-6 mb-3 mb-sm-0">
155+
<input
156+
type="text"
157+
className="form-control form-control-user"
158+
id="tradeDate"
159+
placeholder="date "
160+
onBlur={this.handleFormPropertyChange}
161+
/>
162+
</div>
163+
</div>
164+
<a
165+
href="#"
166+
className="btn btn-primary btn-user"
167+
onClick={this.handleSubmit}
168+
>
169+
Create
170+
</a>
171+
</form>
175172
</div>
176173
</div>
177-
<div>
178-
<h4>Order created with Id= {this.state.lastOrder.orderId}</h4>
179-
</div>
174+
</div>
175+
<div>
176+
<h4>Order created with Id= {this.state.lastOrder.orderId}</h4>
180177
</div>
181178
</div>
182179
</div>

src/components/dashboard.jsx

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,52 @@ import React, { Component } from "react";
22
import DashboardSummary from "./dashboardSummary";
33
import PositionBlotter from "./positionBlotter";
44
import InstBlotteer from "./instBlotter";
5+
import AppConfig from "../utils/constants";
56

67
class Dashboard extends Component {
7-
state = {};
8+
state = {
9+
accountId: 1,
10+
results: {
11+
daily: 0,
12+
mtd: 0,
13+
orderCount: 0,
14+
test: 0,
15+
},
16+
};
17+
18+
constructor(props) {
19+
super(props);
20+
this.reloadTradeCount();
21+
}
22+
23+
tradeChanged = (e) => {
24+
const { results } = this.state;
25+
var tradeCount = results["orderCount"];
26+
const newResults = { ...results, orderCount: tradeCount + 1 };
27+
this.setState({ results: newResults });
28+
};
29+
30+
reloadTradeCount = () => {
31+
const { results } = this.state;
32+
fetch(AppConfig.serverUrl + "/orders/count/" + this.state.accountId, {
33+
mode: "cors",
34+
})
35+
.then((resp) => resp.json())
36+
.then((data) =>
37+
this.setState({ results: { ...results, orderCount: data.result } })
38+
);
39+
};
40+
841
render() {
942
return (
1043
<div>
1144
<div className="d-sm-flex align-items-center justify-content-between mb-4">
1245
<h1 className="h3 mb-0 text-primary">Dashboard</h1>
13-
<a
14-
href="#"
15-
className="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm"
16-
>
17-
<i className="fas fa-download fa-sm text-white-50"></i> Generate
18-
Report
19-
</a>
2046
</div>
2147

22-
<DashboardSummary />
48+
<DashboardSummary results={this.state.results} />
2349
<div className="row">
24-
<PositionBlotter />
50+
<PositionBlotter reloadTradeCount={this.reloadTradeCount} />
2551
<InstBlotteer />
2652
</div>
2753
</div>

src/components/dashboardSummary.jsx

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,41 @@ import Card from "./card";
44
class DashboardSummary extends Component {
55
state = {
66
accountId: 1,
7+
results: {
8+
daily: 0,
9+
mtd: 0,
10+
orderCount: 0,
11+
test: 0,
12+
},
713
};
814
render() {
915
return (
1016
<React.Fragment>
1117
<div className="row">
12-
<Card header="Monthly Earning" url="/acctsummary" />
13-
<Card header="Total P/L" url="/acctsummary" />
14-
<Card header="Order Count" url="/orders/count/1" />
15-
<Card header="Some Other" url="/acctsummary" />
18+
<Card
19+
header="Monthly Earning"
20+
url="/acctsummary"
21+
id="mtd"
22+
result={this.props.results["mtd"]}
23+
/>
24+
<Card
25+
header="Daily P/L"
26+
url="/acctsummary"
27+
id="daily"
28+
result={this.props.results["daily"]}
29+
/>
30+
<Card
31+
header="Order Count"
32+
url="/orders/count/1"
33+
id="orderCount"
34+
result={this.props.results["orderCount"]}
35+
/>
36+
<Card
37+
header="Some Other"
38+
url="/acctsummary"
39+
id="test"
40+
result={this.props.results["test"]}
41+
/>
1642
</div>
1743
</React.Fragment>
1844
);

0 commit comments

Comments
 (0)