11// @flow weak
22
3- import moment from 'moment' ;
4- import { auth } from '../../services/auth' ;
3+ import moment from 'moment' ;
4+ import { auth } from '../../services/auth' ;
5+
56const dateFormat = 'DD/MM/YYYY HH:mm' ;
67
78/* -----------------------------------------
89 constants
910 ------------------------------------------*/
1011const CHECK_IS_USER_IS_AUTHENTICATED = 'CHECK_IS_USER_IS_AUTHENTICATED' ;
1112
12- const RECEIVED_USER_LOGGED_IN = 'RECEIVED_USER_LOGGED_IN' ;
13- const ERROR_USER_LOGGED_IN = 'ERROR_USER_LOGGED_IN' ;
13+ const RECEIVED_USER_LOGGED_IN = 'RECEIVED_USER_LOGGED_IN' ;
14+ const ERROR_USER_LOGGED_IN = 'ERROR_USER_LOGGED_IN' ;
1415
15- const SET_LOADING_LOGGED_IN = 'SET_LOADING_LOGGED_IN' ;
16- const UNSET_LOADING_LOGGED_IN = 'UNSET_LOADING_LOGGED_IN' ;
16+ const SET_LOADING_LOGGED_IN = 'SET_LOADING_LOGGED_IN' ;
17+ const UNSET_LOADING_LOGGED_IN = 'UNSET_LOADING_LOGGED_IN' ;
1718
18- const RECEIVED_USER_REGISTER = 'RECEIVED_USER_REGISTER' ;
19- const ERROR_USER_REGISTER = 'ERROR_USER_REGISTER' ;
19+ const RECEIVED_USER_REGISTER = 'RECEIVED_USER_REGISTER' ;
20+ const ERROR_USER_REGISTER = 'ERROR_USER_REGISTER' ;
2021
21- const SET_LOADING_REGISTER = 'SET_LOADING_REGISTER' ;
22- const UNSET_LOADING_REGISTER = 'UNSET_LOADING_REGISTER' ;
22+ const SET_LOADING_REGISTER = 'SET_LOADING_REGISTER' ;
23+ const UNSET_LOADING_REGISTER = 'UNSET_LOADING_REGISTER' ;
2324
24- const SET_USER_LOGOUT = 'SET_USER_LOGOUT' ;
25+ const SET_USER_LOGOUT = 'SET_USER_LOGOUT' ;
2526
26- const RESET_LOG_ERRORS = 'RESET_LOG_ERRORS' ;
27+ const RESET_LOG_ERRORS = 'RESET_LOG_ERRORS' ;
2728
2829/* -----------------------------------------
2930 Reducer
3031 ------------------------------------------*/
3132const emptyUser = {
32- id : null ,
33+ id : '' ,
3334 username : '' ,
3435 lastLogin : '' ,
3536 createdAt : '' ,
@@ -51,30 +52,30 @@ export default function (state = initialState, action) {
5152 case RECEIVED_USER_REGISTER :
5253 return {
5354 ...state ,
54- lastActionTime : action . time ,
55+ lastActionTime : action . time ,
5556 isAuthenticated : action . isAuthenticated ,
56- id : action . user . id ,
57- username : action . user . username ,
58- lastLogin : action . user . lastLogin ,
59- createdAt : action . user . createdAt ,
60- modifiedAt : action . user . modifiedAt ,
57+ id : action . user . id ,
58+ username : action . user . username ,
59+ lastLogin : action . user . lastLogin ,
60+ createdAt : action . user . createdAt ,
61+ modifiedAt : action . user . modifiedAt ,
6162 lastRefreshTime : action . time ,
62- error : null
63+ error : null
6364 } ;
6465
6566 case ERROR_USER_LOGGED_IN :
6667 case ERROR_USER_REGISTER :
6768 return {
6869 ...state ,
69- lastActionTime : action . time ,
70- isAuthenticated : action . isAuthenticated ,
70+ lastActionTime : action . time ,
71+ isAuthenticated : action . isAuthenticated ,
7172 // errors:
7273 error : { ...action . error } ,
7374 // user infos:
74- id : initialState . id ,
75- username : initialState . username ,
76- lastLogin : initialState . lastLogin ,
77- createdAt : initialState . createdAt ,
75+ id : initialState . id ,
76+ username : initialState . username ,
77+ lastLogin : initialState . lastLogin ,
78+ createdAt : initialState . createdAt ,
7879 modifiedAt : initialState . modifiedAt
7980 } ;
8081
@@ -84,33 +85,33 @@ export default function (state = initialState, action) {
8485 case UNSET_LOADING_REGISTER :
8586 return {
8687 ...state ,
87- lastActionTime : action . time ,
88+ lastActionTime : action . time ,
8889 mutationLoading : action . loading
8990 } ;
9091
9192 case CHECK_IS_USER_IS_AUTHENTICATED :
9293 return {
9394 ...state ,
94- lastActionTime : action . time ,
95- isAuthenticated : action . isAuthenticated ,
95+ lastActionTime : action . time ,
96+ isAuthenticated : action . isAuthenticated ,
9697 // user infos from storage if authenticated:
97- id : action . user . id ,
98- username : action . user . username ,
99- lastLogin : action . user . lastLogin ,
100- createdAt : action . user . createdAt ,
101- modifiedAt : action . user . modifiedAt
98+ id : action . user . id ,
99+ username : action . user . username ,
100+ lastLogin : action . user . lastLogin ,
101+ createdAt : action . user . createdAt ,
102+ modifiedAt : action . user . modifiedAt
102103 } ;
103104
104105 case SET_USER_LOGOUT :
105106 return {
106107 ...state ,
107- lastActionTime : action . time ,
108+ lastActionTime : action . time ,
108109 isAuthenticated : action . isAuthenticated ,
109- id : action . user . id ,
110- username : action . user . username ,
111- lastLogin : action . user . lastLogin ,
112- createdAt : action . user . createdAt ,
113- modifiedAt : action . user . modifiedAt
110+ id : action . user . id ,
111+ username : action . user . username ,
112+ lastLogin : action . user . lastLogin ,
113+ createdAt : action . user . createdAt ,
114+ modifiedAt : action . user . modifiedAt
114115 } ;
115116
116117 case RESET_LOG_ERRORS :
0 commit comments