@@ -2,112 +2,112 @@ import React, { Component, PropTypes } from 'react';
22import AccountStore from '../stores/account-store' ;
33
44const AccountProvider = class extends Component {
5- static displayName = 'AccountProvider'
5+ static displayName = 'AccountProvider'
66
7- constructor ( props , context ) {
8- super ( props , context ) ;
9- this . state = {
10- isLoading : AccountStore . isLoading ,
11- organisation : AccountStore . getOrganisation ( ) ,
12- organisations : AccountStore . getOrganisations ( ) ,
13- user : AccountStore . getUser ( ) ,
14- } ;
15- }
7+ constructor ( props , context ) {
8+ super ( props , context ) ;
9+ this . state = {
10+ isLoading : AccountStore . isLoading ,
11+ organisation : AccountStore . getOrganisation ( ) ,
12+ organisations : AccountStore . getOrganisations ( ) ,
13+ user : AccountStore . getUser ( ) ,
14+ } ;
15+ }
1616
17- componentDidMount ( ) {
18- ES6Component ( this ) ;
19- this . listenTo ( AccountStore , 'change' , ( ) => {
20- this . setState ( {
21- isLoading : AccountStore . isLoading ,
22- isSaving : AccountStore . isSaving ,
23- organisation : AccountStore . getOrganisation ( ) ,
24- organisations : AccountStore . getOrganisations ( ) ,
25- user : AccountStore . getUser ( ) ,
26- error : AccountStore . error ,
27- } ) ;
28- } ) ;
17+ componentDidMount ( ) {
18+ ES6Component ( this ) ;
19+ this . listenTo ( AccountStore , 'change' , ( ) => {
20+ this . setState ( {
21+ isLoading : AccountStore . isLoading ,
22+ isSaving : AccountStore . isSaving ,
23+ organisation : AccountStore . getOrganisation ( ) ,
24+ organisations : AccountStore . getOrganisations ( ) ,
25+ user : AccountStore . getUser ( ) ,
26+ error : AccountStore . error ,
27+ } ) ;
28+ } ) ;
2929
30- this . listenTo ( AccountStore , 'loaded' , ( ) => {
31- this . props . onLogin && this . props . onLogin ( ) ;
32- } ) ;
30+ this . listenTo ( AccountStore , 'loaded' , ( ) => {
31+ this . props . onLogin && this . props . onLogin ( ) ;
32+ } ) ;
3333
34- this . listenTo ( AccountStore , 'saved' , ( ) => {
35- this . props . onSave && this . props . onSave ( AccountStore . savedId ) ;
36- } ) ;
34+ this . listenTo ( AccountStore , 'saved' , ( ) => {
35+ this . props . onSave && this . props . onSave ( AccountStore . savedId ) ;
36+ } ) ;
3737
38- this . listenTo ( AccountStore , 'logout' , ( ) => {
39- this . setState ( {
40- isLoading : false ,
41- isSaving : false ,
42- organisation : AccountStore . getOrganisation ( ) ,
43- user : AccountStore . getUser ( ) ,
44- } ) ;
45- this . props . onLogout && this . props . onLogout ( ) ;
46- } ) ;
47- this . listenTo ( AccountStore , 'no-user' , ( ) => {
48- this . setState ( {
49- isSaving : false ,
50- isLoading : false ,
51- organisation : AccountStore . getOrganisation ( ) ,
52- user : AccountStore . getUser ( ) ,
53- } ) ;
54- this . props . onNoUser && this . props . onNoUser ( ) ;
55- } ) ;
56- this . listenTo ( AccountStore , 'problem' , ( ) => {
57- this . setState ( {
58- isLoading : AccountStore . isLoading ,
59- isSaving : AccountStore . isSaving ,
60- error : AccountStore . error ,
61- } ) ;
62- } ) ;
63- this . listenTo ( AccountStore , 'removed' , ( ) => {
64- this . props . onRemove && this . props . onRemove ( ) ;
65- if ( this . props . onLogin ) {
66- this . setState ( {
67- isLoading : false ,
68- isSaving : false ,
69- organisation : AccountStore . getOrganisation ( ) ,
70- user : AccountStore . getUser ( ) ,
71- } ) ;
72- }
73- } ) ;
74- }
38+ this . listenTo ( AccountStore , 'logout' , ( ) => {
39+ this . setState ( {
40+ isLoading : false ,
41+ isSaving : false ,
42+ organisation : AccountStore . getOrganisation ( ) ,
43+ user : AccountStore . getUser ( ) ,
44+ } ) ;
45+ this . props . onLogout && this . props . onLogout ( ) ;
46+ } ) ;
47+ this . listenTo ( AccountStore , 'no-user' , ( ) => {
48+ this . setState ( {
49+ isSaving : false ,
50+ isLoading : false ,
51+ organisation : AccountStore . getOrganisation ( ) ,
52+ user : AccountStore . getUser ( ) ,
53+ } ) ;
54+ this . props . onNoUser && this . props . onNoUser ( ) ;
55+ } ) ;
56+ this . listenTo ( AccountStore , 'problem' , ( ) => {
57+ this . setState ( {
58+ isLoading : AccountStore . isLoading ,
59+ isSaving : AccountStore . isSaving ,
60+ error : AccountStore . error ,
61+ } ) ;
62+ } ) ;
63+ this . listenTo ( AccountStore , 'removed' , ( ) => {
64+ this . props . onRemove && this . props . onRemove ( ) ;
65+ if ( this . props . onLogin ) {
66+ this . setState ( {
67+ isLoading : false ,
68+ isSaving : false ,
69+ organisation : AccountStore . getOrganisation ( ) ,
70+ user : AccountStore . getUser ( ) ,
71+ } ) ;
72+ }
73+ } ) ;
74+ }
7575
7676
77- login = ( details ) => {
78- AppActions . login ( details ) ;
79- } ;
77+ login = ( details ) => {
78+ AppActions . login ( details ) ;
79+ } ;
8080
81- loginDemo = ( ) => {
82- AppActions . login ( Project . demoAccount ) ;
83- } ;
81+ loginDemo = ( ) => {
82+ AppActions . login ( Project . demoAccount ) ;
83+ } ;
8484
85- register = ( details , isInvite ) => {
86- AppActions . register ( details , isInvite ) ;
87- } ;
85+ register = ( details , isInvite ) => {
86+ AppActions . register ( details , isInvite ) ;
87+ } ;
8888
89- render ( ) {
90- const { isLoading, isSaving, user, organisation, organisations, error } = this . state ;
91- return (
92- this . props . children ( {
93- isLoading,
94- isSaving,
95- user,
96- organisation,
97- organisations,
98- error,
99- } , {
100- loginDemo : this . loginDemo ,
101- login : this . login ,
102- register : this . register ,
103- selectOrganisation : AppActions . selectOrganisation ,
104- createOrganisation : AppActions . createOrganisation ,
105- editOrganisation : AppActions . editOrganisation ,
106- acceptInvite : AppActions . acceptInvite ,
107- deleteOrganisation : AppActions . deleteOrganisation ,
108- } )
109- ) ;
110- }
89+ render ( ) {
90+ const { isLoading, isSaving, user, organisation, organisations, error } = this . state ;
91+ return (
92+ this . props . children ( {
93+ isLoading,
94+ isSaving,
95+ user,
96+ organisation,
97+ organisations,
98+ error,
99+ } , {
100+ loginDemo : this . loginDemo ,
101+ login : this . login ,
102+ register : this . register ,
103+ selectOrganisation : AppActions . selectOrganisation ,
104+ createOrganisation : AppActions . createOrganisation ,
105+ editOrganisation : AppActions . editOrganisation ,
106+ acceptInvite : AppActions . acceptInvite ,
107+ deleteOrganisation : AppActions . deleteOrganisation ,
108+ } )
109+ ) ;
110+ }
111111} ;
112112
113113AccountProvider . propTypes = { } ;
0 commit comments