diff --git a/app/javascript/packs/app/action_types.js b/app/javascript/packs/app/action_types.js index 4a2ee313a..059d8c6a6 100644 --- a/app/javascript/packs/app/action_types.js +++ b/app/javascript/packs/app/action_types.js @@ -13,3 +13,12 @@ export const CHANGE_CURRENT_USER_EMAIL = "CHANGE_CURRENT_USER_EMAIL"; export const CHANGE_CURRENT_USER_PASSWORD = "CHANGE_CURRENT_USER_PASSWORD"; export const CHANGE_CURRENT_USER_AVATAR = "CHANGE_CURRENT_USER_AVATAR"; export const CHANGE_CURRENT_USER_TIMEZONE = "CHANGE_CURRENT_USER_TIMEZONE"; +export const CHANGE_ASSIGNMENTS_NOTIFICATION = + "CHANGE_ASSIGNMENTS_NOTIFICATION"; +export const CHANGE_ASSIGNMENTS_NOTIFICATION_EMAIL = + "CHANGE_ASSIGNMENTS_NOTIFICATION_EMAIL"; +export const CHANGE_RECENT_NOTIFICATION = "CHANGE_RECENT_NOTIFICATION"; +export const CHANGE_RECENT_NOTIFICATION_EMAIL = + "CHANGE_RECENT_NOTIFICATION_EMAIL"; +export const CHANGE_SYSTEM_MESSAGE_NOTIFICATION_EMAIL = + "CHANGE_SYSTEM_MESSAGE_NOTIFICATION_EMAIL"; diff --git a/app/javascript/packs/shared/actions/UsersActions.js b/app/javascript/packs/shared/actions/UsersActions.js index 4c4ff3b8d..c8ff005db 100644 --- a/app/javascript/packs/shared/actions/UsersActions.js +++ b/app/javascript/packs/shared/actions/UsersActions.js @@ -7,7 +7,10 @@ import { CHANGE_CURRENT_USER_EMAIL, CHANGE_CURRENT_USER_PASSWORD, CHANGE_CURRENT_USER_AVATAR, - CHANGE_CURRENT_USER_TIMEZONE + CHANGE_CURRENT_USER_TIMEZONE, + CHANGE_CURRENT_USER_SYSTEM_NOTIFICATION, + CHANGE_CURRENT_USER_CHANGES_NOTIFICATION, + CHANGE_CURRENT_USER_ASSIGNEMENT_NOTIFICATION } from "../../app/action_types"; function addCurrentUser(data) { @@ -71,3 +74,36 @@ export function changeTimezone(timezone) { payload: timezone }; } + +export function changeAssignmentsNotification(status) { + return { + type: CHANGE_CURRENT_USER_ASSIGNEMENT_NOTIFICATION, + payload: status + }; +} +export function changeAssignmentsNotificationEmail(status) { + return { + type: CHANGE_CURRENT_USER_CHANGES_NOTIFICATION, + payload: status + }; +} +export function changeRecentNotification(status) { + return { + type: CHANGE_CURRENT_USER_SYSTEM_NOTIFICATION, + payload: status + }; +} + +export function changeRecentNotificationEmail(status) { + return { + type: CHANGE_CURRENT_USER_SYSTEM_NOTIFICATION, + payload: status + }; +} + +export function changeSystemMessageNotificationEmail(status) { + return { + type: CHANGE_CURRENT_USER_SYSTEM_NOTIFICATION, + payload: status + }; +} diff --git a/app/javascript/packs/shared/reducers/UsersReducer.js b/app/javascript/packs/shared/reducers/UsersReducer.js index 32a1ca6d5..d2375e110 100644 --- a/app/javascript/packs/shared/reducers/UsersReducer.js +++ b/app/javascript/packs/shared/reducers/UsersReducer.js @@ -5,7 +5,12 @@ import { CHANGE_CURRENT_USER_EMAIL, CHANGE_CURRENT_USER_PASSWORD, CHANGE_CURRENT_USER_AVATAR, - CHANGE_CURRENT_USER_TIMEZONE + CHANGE_CURRENT_USER_TIMEZONE, + CHANGE_ASSIGNMENTS_NOTIFICATION, + CHANGE_ASSIGNMENTS_NOTIFICATION_EMAIL, + CHANGE_RECENT_NOTIFICATION, + CHANGE_RECENT_NOTIFICATION_EMAIL, + CHANGE_SYSTEM_MESSAGE_NOTIFICATION_EMAIL } from "../../app/action_types"; export function currentUser( @@ -16,7 +21,12 @@ export function currentUser( email: "", avatarPath: "", avatarThumbPath: "", - timezone: "" + timezone: "", + assignmentsNotification: false, + assignmentsNotificationEmail: false, + recentNotification: false, + recentNotificationEmail: false, + systemMessageNotificationEmail: false }, action ) { @@ -37,6 +47,24 @@ export function currentUser( return Object.assign({}, state, { avatar: action.payload }); case CHANGE_CURRENT_USER_TIMEZONE: return Object.assign({}, state, { timezone: action.payload }); + 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 + }); default: return state; } diff --git a/app/javascript/packs/src/settings/components/NotificationsBtnGroup.jsx b/app/javascript/packs/src/settings/components/NotificationsBtnGroup.jsx new file mode 100644 index 000000000..94d3d1f8c --- /dev/null +++ b/app/javascript/packs/src/settings/components/NotificationsBtnGroup.jsx @@ -0,0 +1,52 @@ +import React, { Component } from "react"; +import { connect } from "react-redux"; + +import { + changeAssignmentsNotification, + changeAssignmentsNotificationEmail, + changeRecentNotification, + changeRecentNotificationEmail, + changeSystemMessageNotificationEmail +} from "../../../shared/actions/UsersActions"; + +class NotificationsBtnGroup extends Component { + constructor(props) { + super(props); + + this.state = { + isSciNoteSwitchOn: false, + isEmailSwitchOn: false + }; + } + + render() { + return ( +
+ {this.props.subtitle} +
+