2017-08-11 21:04:36 +08:00
|
|
|
import {
|
|
|
|
SET_CURRENT_USER,
|
|
|
|
CHANGE_CURRENT_USER_FULL_NAME,
|
|
|
|
CHANGE_CURRENT_USER_INITIALS,
|
2017-08-14 19:31:26 +08:00
|
|
|
CHANGE_CURRENT_USER_EMAIL,
|
|
|
|
CHANGE_CURRENT_USER_PASSWORD,
|
2017-08-16 19:41:55 +08:00
|
|
|
CHANGE_CURRENT_USER_AVATAR,
|
2017-08-16 21:52:42 +08:00
|
|
|
CHANGE_CURRENT_USER_TIMEZONE,
|
|
|
|
CHANGE_ASSIGNMENTS_NOTIFICATION,
|
|
|
|
CHANGE_ASSIGNMENTS_NOTIFICATION_EMAIL,
|
|
|
|
CHANGE_RECENT_NOTIFICATION,
|
|
|
|
CHANGE_RECENT_NOTIFICATION_EMAIL,
|
|
|
|
CHANGE_SYSTEM_MESSAGE_NOTIFICATION_EMAIL
|
2017-08-11 21:04:36 +08:00
|
|
|
} from "../../app/action_types";
|
2017-08-09 15:08:13 +08:00
|
|
|
|
|
|
|
export function currentUser(
|
2017-08-11 21:04:36 +08:00
|
|
|
state = {
|
|
|
|
id: 0,
|
|
|
|
fullName: "",
|
|
|
|
initials: "",
|
|
|
|
email: "",
|
|
|
|
avatarPath: "",
|
2017-08-16 19:41:55 +08:00
|
|
|
avatarThumbPath: "",
|
2017-08-16 21:52:42 +08:00
|
|
|
timezone: "",
|
|
|
|
assignmentsNotification: false,
|
|
|
|
assignmentsNotificationEmail: false,
|
|
|
|
recentNotification: false,
|
|
|
|
recentNotificationEmail: false,
|
|
|
|
systemMessageNotificationEmail: false
|
2017-08-11 21:04:36 +08:00
|
|
|
},
|
2017-08-09 15:08:13 +08:00
|
|
|
action
|
|
|
|
) {
|
2017-08-11 21:04:36 +08:00
|
|
|
switch (action.type) {
|
|
|
|
case SET_CURRENT_USER:
|
|
|
|
return Object.assign({}, state, action.payload);
|
|
|
|
case CHANGE_CURRENT_USER_FULL_NAME:
|
|
|
|
return Object.assign({}, state, { fullName: action.payload });
|
|
|
|
case CHANGE_CURRENT_USER_INITIALS:
|
|
|
|
return Object.assign({}, state, { initials: action.payload });
|
|
|
|
case CHANGE_CURRENT_USER_EMAIL:
|
|
|
|
return Object.assign({}, state, { email: action.payload });
|
2017-08-14 19:31:26 +08:00
|
|
|
case CHANGE_CURRENT_USER_PASSWORD:
|
|
|
|
console.log("handle sending password to the server");
|
|
|
|
// return Object.assign({}, state, { password: action.payload });
|
|
|
|
return state;
|
|
|
|
case CHANGE_CURRENT_USER_AVATAR:
|
|
|
|
return Object.assign({}, state, { avatar: action.payload });
|
2017-08-16 19:41:55 +08:00
|
|
|
case CHANGE_CURRENT_USER_TIMEZONE:
|
|
|
|
return Object.assign({}, state, { timezone: action.payload });
|
2017-08-16 21:52:42 +08:00
|
|
|
case CHANGE_ASSIGNMENTS_NOTIFICATION:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
assignmentsNotification: action.payload
|
|
|
|
});
|
|
|
|
case CHANGE_ASSIGNMENTS_NOTIFICATION_EMAIL:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
assignmentsNotificationEmail: action.payload
|
|
|
|
});
|
|
|
|
case CHANGE_RECENT_NOTIFICATION:
|
|
|
|
return Object.assign({}, state, { recentNotification: action.payload });
|
|
|
|
case CHANGE_RECENT_NOTIFICATION_EMAIL:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
recentNotificationEmail: action.payload
|
|
|
|
});
|
|
|
|
case CHANGE_SYSTEM_MESSAGE_NOTIFICATION_EMAIL:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
systemMessageNotificationEmail: action.payload
|
|
|
|
});
|
2017-08-11 21:04:36 +08:00
|
|
|
default:
|
|
|
|
return state;
|
2017-08-09 15:08:13 +08:00
|
|
|
}
|
|
|
|
}
|