@@ -12,7 +12,7 @@ import { requestPurchase, endPurchase, viewProfileQR, cancelPurchase } from "act
12
12
import { addProduct , removeProduct , selectProduct , increaseProductQty , changePage } from "actions/product" ;
13
13
14
14
import { Flex , Box } from "reflexbox" ;
15
- import { ProductList , PurchaseButton , Account , Sidebar , LoadingBox , Button } from "components" ;
15
+ import { ProductList , PurchaseButton , Account , Sidebar , LoadingBox , Button , DevToolbar } from "components" ;
16
16
import * as style from "styles/App.scss" ;
17
17
18
18
//Require since qrcode.react does not have support for new javascript "import"
@@ -36,25 +36,9 @@ interface IThunder {
36
36
}
37
37
38
38
class App extends React . Component < IAppProps , { } > {
39
- addRandomProduct ( ) {
40
- let codes = [
41
- "7310500088853" ,
42
- "7340083438684" ,
43
- "7611612221351" ,
44
- "7310500114934" ,
45
- "7310070765840" ,
46
- "7315360010754" ,
47
- "7622300342753"
48
- ] ;
49
-
50
- let randomIndex = Math . floor ( Math . random ( ) * codes . length ) ;
51
- this . props . dispatch ( addProduct ( codes [ randomIndex ] ) ) ;
52
- }
53
-
54
39
componentDidMount ( ) {
55
40
const { dispatch } = this . props ;
56
41
57
- // dispatch(login("154464990"));
58
42
Thunder . connect ( process . env . THUNDER . host , process . env . THUNDER . key , [ "products" , "cards" ] ) ;
59
43
Thunder . listen ( ( data : IThunder ) => {
60
44
if ( data . channel === "products" ) {
@@ -66,6 +50,20 @@ class App extends React.Component<IAppProps, {}> {
66
50
}
67
51
68
52
render ( ) {
53
+ if ( process . env . NODE_ENV == 'development' ) {
54
+ return (
55
+ < div >
56
+ < DevToolbar
57
+ dispatch = { this . props . dispatch }
58
+ />
59
+ { this . renderApp ( ) }
60
+ </ div >
61
+ ) ;
62
+ }
63
+ return this . renderApp ( ) ;
64
+ }
65
+
66
+ renderApp ( ) {
69
67
const { dispatch, products, account, purchase } = this . props ;
70
68
71
69
let selected = products . products . filter ( ( product : any ) => {
@@ -81,7 +79,6 @@ class App extends React.Component<IAppProps, {}> {
81
79
onRemove = { ( ) => dispatch ( removeProduct ( ) ) }
82
80
onScrollUp = { ( ) => dispatch ( changePage ( - 1 ) ) }
83
81
onScrollDown = { ( ) => dispatch ( changePage ( 1 ) ) }
84
- addRandomProduct = { ( ) => this . addRandomProduct ( ) }
85
82
active = { selected > 0 }
86
83
scrollUpActive = { products . page > 0 }
87
84
scrollDownActive = { products . page < products . maxPage } />
@@ -154,14 +151,6 @@ class App extends React.Component<IAppProps, {}> {
154
151
< Box py = { 1 } > Blip a card linked with your account</ Box >
155
152
< Box py = { 1 } > or</ Box >
156
153
< Box py = { 1 } > Scan a product to start a cash payment</ Box >
157
- { ( process . env . NODE_ENV === "development" ? (
158
- < Box py = { 1 } > < Button label = "dev cash buy" onClick = { ( ) => this . addRandomProduct ( ) } /> </ Box >
159
- ) : undefined ) }
160
- { ( process . env . NODE_ENV === "development" ? (
161
- < Box py = { 1 } >
162
- < Button label = "dev account buy" onClick = { ( ) => dispatch ( login ( "154464990" ) ) } />
163
- </ Box >
164
- ) : undefined ) }
165
154
{ ( account . request ? < LoadingBox /> : undefined ) }
166
155
{ ( account . request ? < Box className = { style . overlay } /> : undefined ) }
167
156
</ Flex >
0 commit comments