@@ -2,6 +2,7 @@ import React, { Component, PropTypes } from 'react';
2
2
import { connect } from 'react-redux' ;
3
3
import NumberPicker from '../components/NumberPicker' ;
4
4
import NumberList from '../components/NumberList' ;
5
+ import WorkingMessage from '../components/WorkingMessage' ;
5
6
import { setNumberEntry } from '../actions/numberentry' ;
6
7
import { addNumber } from '../actions/primes' ;
7
8
@@ -26,14 +27,23 @@ class App extends Component {
26
27
27
28
render ( ) {
28
29
const submitText = "Add Number" ;
29
- const { numberEntry, primes, nonPrimes } = this . props ;
30
+ const { numberEntry, primes, nonPrimes, queue } = this . props ;
31
+ let workMessage = < span > </ span > ;
32
+
33
+ if ( queue . length > 0 ) {
34
+ workMessage = < WorkingMessage count = { queue . length } itemType = "number" /> ;
35
+ }
30
36
31
37
return (
32
38
< div >
39
+ < h1 > Calculate Prime Numbers</ h1 >
33
40
< NumberPicker submitText = { submitText }
34
41
value = { numberEntry }
35
42
onChange = { this . handleNumberEntryChange }
36
- onSubmit = { this . handleNumberEntrySubmit } />
43
+ onSubmit = { this . handleNumberEntrySubmit } />
44
+
45
+ < em > { workMessage } </ em >
46
+
37
47
< h2 > Primes</ h2 >
38
48
< NumberList numbers = { primes } />
39
49
< h2 > Non-Primes</ h2 >
@@ -47,17 +57,19 @@ App.propTypes = {
47
57
numberEntry : PropTypes . string . isRequired ,
48
58
primes : PropTypes . array . isRequired ,
49
59
nonPrimes : PropTypes . array . isRequired ,
60
+ queue : PropTypes . array . isRequired ,
50
61
dispatch : PropTypes . func . isRequired
51
62
} ;
52
63
53
64
function mapStateToProps ( state ) {
54
65
const { numberEntry, primeState } = state ;
55
- const { primes, nonPrimes } = primeState ;
66
+ const { primes, nonPrimes, queue } = primeState ;
56
67
57
68
return {
58
69
numberEntry,
59
70
primes,
60
- nonPrimes
71
+ nonPrimes,
72
+ queue
61
73
} ;
62
74
}
63
75
0 commit comments