Skip to content

Commit c55af7b

Browse files
committed
Inventory Transfer
1 parent 5f2493d commit c55af7b

File tree

8 files changed

+291
-138
lines changed

8 files changed

+291
-138
lines changed

AuthService.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,27 @@ var Events = require('./Events');
55
var $ = require('jquery');
66
//var jwt = require('jsonwebtoken');
77

8+
var localStorage = window.localStorage;
9+
810
var token = null;
911
var user = null;
12+
var date = null;
13+
//Retrieve
14+
if (!!localStorage) {
15+
16+
date = !!localStorage.getItem("date") ? new Date(localStorage.getItem("date")) : null;
17+
18+
if (!!date && date.getDate() == new Date().getDate()) {
19+
token = localStorage.getItem("token");
20+
user = localStorage.getItem("user");
21+
try {
22+
user = JSON.parse(user);
23+
} catch (e) {
24+
token = null;
25+
user = null;
26+
}
27+
}
28+
}
1029

1130
class AuthService {
1231

@@ -26,6 +45,13 @@ class AuthService {
2645
resolve(user);
2746

2847
console.log("LOGIN_SUCCESS", JSON.stringify({token: token, user: user}));
48+
49+
//Store
50+
if (!!localStorage) {
51+
localStorage.setItem("token", token);
52+
localStorage.setItem("user", JSON.stringify(user));
53+
localStorage.setItem("date", new Date().toJSON());
54+
}
2955
},
3056
error: reject
3157
});

EventBus.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ var send = eb.send;
2929

3030
eb.send = function (address, message, headers, callback) {
3131

32+
if (eb.state != EventBus.OPEN) {
33+
window.alert("Disconnected from server. Please login again.");
34+
location.href = Uris.toAbsoluteUri(Uris.LOGIN_URI);
35+
callback(new Error("Invalid state error."), null);
36+
return;
37+
}
38+
3239
headers = headers || {};
3340
if (authSerice.isLoggedIn()) {
3441
headers['authToken'] = authSerice.authToken();

inventory/AddAnotherProductForm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var AddAnotherProductForm = React.createClass({
99
{id: 2, name: 'op-2'},
1010
{id: 3, name: 'op-3'}
1111
],
12+
productsUnitWisePrice: {},
1213
units: [
1314
{id: 1, name: 'op-1'},
1415
{id: 2, name: 'op-2'},
@@ -51,7 +52,7 @@ var AddAnotherProductForm = React.createClass({
5152
<label htmlFor="unitId">Unit</label>
5253
<Select id="unitId" name="unitId" value={product.unitId}
5354
initialOption={{id: 0, name: 'Select Unit'}}
54-
options={$this.props.units || []}
55+
options={$this.props.units}
5556
onChange={$this.props.onChange}/>
5657
</div>
5758
</div>

inventory/AddRemoveEditForm.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,11 @@ var AddRemoveEditForm = React.createClass({
2727
<form onSubmit={$this.props.onSubmit}>
2828

2929
<div className="form-group">
30-
<label>Current Quantity</label>
30+
<label forHtml="quantity">New Quantity</label>
3131
<input type="text" className="form-control" id="quantity"
32-
style={{width: '130px'}}
33-
placeholder={''}
34-
value={item.quantity} readOnly={true}/>
35-
36-
</div>
37-
38-
<div className="form-group">
39-
<label forHtml="__quantity__">New Quantity</label>
40-
<input type="text" className="form-control" id="__quantity__"
4132
style={{width: '130px'}}
4233
placeholder={placeholder}
43-
name="__quantity__" value={item.__quantity__} onChange={$this.props.onChange}/>
34+
name="quantity" value={item.quantity} onChange={$this.props.onChange}/>
4435

4536
</div>
4637

0 commit comments

Comments
 (0)