@@ -11,18 +11,48 @@ import styles from 'components/back4App/Header/Header.scss';
1111import navData from 'components/back4App/Header/headerNavData' ;
1212
1313export default class Header extends React . Component {
14+ constructor ( props ) {
15+ super ( props ) ;
16+
17+ this . state = {
18+ username : null
19+ } ;
20+ }
1421 componentWillMount ( ) {
1522 /*
16- - Thi-s resource should be implemented following parse-dashboard community standards (using flux).
23+ - This resource should be implemented following parse-dashboard community standards (using flux).
1724 But it was actualy not possible to use the subscribeTo decorator in the Header component
1825 before the App was injected in the router. This is a simple temporary solution.
1926 */
2027 fetch ( 'https://dashboard.back4app.com/me' , {
2128 method : 'GET' ,
2229 credentials : 'include'
2330 } )
31+ . then ( response => response . json ( ) )
2432 . then ( response => {
25- console . log ( response . json ( ) ) ;
33+ this . setState ( {
34+ username : response . username . split ( '@' ) [ 0 ]
35+ } ) ;
36+ } )
37+ . catch ( error => {
38+ console . log ( "Error" , error ) ;
39+ } ) ;
40+
41+ fetch ( 'https://dashboard.back4app.com/listApps' , {
42+ method : 'GET' ,
43+ credentials : 'include'
44+ } )
45+ . then ( response => response . json ( ) )
46+ . then ( apps => {
47+ let amountAppsWithExpiredPlans = apps . reduce ( ( accumulator , currentValue , currentIndex , array ) => {
48+ return accumulator + ( currentValue . planCloudColor === 'red' ? 1 : 0 ) ;
49+ } , 0 ) ;
50+ this . setState ( {
51+ amountAppsWithExpiredPlans
52+ } ) ;
53+ } )
54+ . catch ( function ( error ) {
55+ console . log ( 'error' , error ) ;
2656 } ) ;
2757 }
2858 render ( ) {
@@ -32,33 +62,28 @@ export default class Header extends React.Component {
3262 < Media query = "(max-width: 1099px)" >
3363 < div className = { styles [ 'hamburger-wrapper' ] } >
3464 < HamburgerButton onClick = { ( ) => {
35- props . sidebarToggle ( ) ;
65+ this . props . sidebarToggle ( ) ;
3666 } } />
3767 </ div >
3868 </ Media >
39- < Media query = "(min-width: 1100px)" >
40- < a className = { styles [ 'logo-face' ] } href = "http://www.back4app.com/" >
41- < Icon width = { 46 } height = { 47 } name = 'back4app-logo-face-blue' fill = '#208AEC' />
69+ < a className = { styles [ 'logo-face' ] } href = "http://www.back4app.com/" >
70+ < Icon width = { 46 } height = { 47 } name = 'back4app-logo-face-blue' fill = '#208AEC' />
71+ </ a >
72+ < Media query = "(min-width: 680px)" >
73+ < a className = { styles [ 'logo-text' ] } href = "http://www.back4app.com/" >
74+ < Icon width = { 134 } height = { 53 } name = 'back4app-logo-text-blue' fill = '#208AEC' />
4275 </ a >
4376 </ Media >
44- < a className = { styles [ 'logo-text' ] } href = "http://www.back4app.com/" >
45- < Icon width = { 134 } height = { 53 } name = 'back4app-logo-text-blue' fill = '#208AEC' />
46- </ a >
47- </ div >
4877
78+ </ div >
4979 < div className = { styles [ 'right-side' ] } >
50-
51- < Media query = "(min-width: 1100px)" >
52- < Nav items = { navData . items } />
53- </ Media >
54-
80+ < Nav items = { navData . items } amountAppsWithExpiredPlans = { this . state . amountAppsWithExpiredPlans } />
5581 < Media query = "(min-width: 1100px)" >
5682 < div className = "ml-auto" >
57- < Dropdown items = { navData . dropdownItems } > Hello, TBrayner! < i className = "dropdown-icon zmdi zmdi-caret-down" > </ i > </ Dropdown >
83+ < Dropdown items = { navData . dropdownItems } > { this . state . username && ` Hello, ${ this . state . username } ` } < i className = "dropdown-icon zmdi zmdi-caret-down" > </ i > </ Dropdown >
5884 < Button color = "green" weight = "700" url = "https://dashboard.back4app.com/apps/#!/apps/new" > NEW APP</ Button >
5985 </ div >
6086 </ Media >
61-
6287 </ div >
6388 </ header >
6489 ) ;
0 commit comments