diff --git a/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js b/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js new file mode 100644 index 000000000..b9195bb92 --- /dev/null +++ b/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js @@ -0,0 +1,125 @@ +import React, { Component } from "react"; +import "bootstrap/dist/css/bootstrap.css"; +import "../../../../SBStyles.css"; +import { Box, Typography } from "@mui/material"; +import CustomButton from "../../../Student/View/Components/CustomButton.js"; +import SendMessageModal from '../../../Components/SendMessageModal.js'; +import CustomDataTable from "../../../Components/CustomDataTable.js"; + +class ViewNotification extends Component { + constructor(props) { + super(props); + + this.state = { + errorMessage: null, + isLoaded: null, + showDialog: false, + emailSubject: '', + emailMessage: '', + notificationSent: false, + + errors: { + emailSubject: '', + emailMessage: '', + } + }; + } + + handleChange = (e) => { + const { id, value } = e.target; + + this.setState({ + [id]: value, + errors: { + ...this.state.errors, + [id]: value.trim() === '' ? `${id.charAt(0).toUpperCase() + id.slice(1)} cannot be empty` : '', + }, + }); + }; + + handleDialog = () => { + this.setState({ + showDialog: this.state.showDialog === false ? true : false, + }) + } + + handleSendNotification = () => { + var emailSubject = this.state.emailSubject; + + var emailMessage = this.state.emailMessage; + + if (emailSubject.trim() === '' && emailMessage.trim() === '') { + this.setState({ + errors: { + emailSubject: 'Subject cannot be empty', + emailMessage: 'Message cannot be empty', + }, + }); + + return; + } + + if (emailMessage.trim() === '') { + this.setState({ + errors: { + emailMessage: 'Message cannot be empty', + }, + }); + + return; + } + + + if (emailSubject.trim() === '') { + this.setState({ + errors: { + emailSubject: 'Subject cannot be empty', + }, + }); + + return; + } + + }; + + render() { + var navbar = this.props.navbar; + + var state = navbar.state; + + var notificationSent = state.notificationSent; + + return ( + + + View Notifications + + + + + + + + + + + ); + } +} + +export default ViewNotification; diff --git a/FrontEndReact/src/View/Components/SendMessageModal.js b/FrontEndReact/src/View/Components/SendMessageModal.js new file mode 100644 index 000000000..51509df5d --- /dev/null +++ b/FrontEndReact/src/View/Components/SendMessageModal.js @@ -0,0 +1,86 @@ +import React from "react"; +import Button from '@mui/material/Button'; +import Dialog from '@mui/material/Dialog'; +import { TextField } from "@mui/material"; +import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogContentText from '@mui/material/DialogContentText'; +import DialogTitle from '@mui/material/DialogTitle'; + +export default function SendMessageModal ( props ) { + return ( + + + + {"Send Message to Admins"} + + + + + Use this form to send a message to all admin users. This notification will be delivered to their registered email addresses. + + + + + + + + + + + + + + Cancel + + {/* + Send Message + */} + { + props.sendNotification(); + props.handleDialog(); + }} + aria-label="addMessagePromptSendNotificationButton" + > + Send Message + + + + + ); +} diff --git a/FrontEndReact/src/View/Navbar/AppState.js b/FrontEndReact/src/View/Navbar/AppState.js index 87fc14b0c..054ddaace 100644 --- a/FrontEndReact/src/View/Navbar/AppState.js +++ b/FrontEndReact/src/View/Navbar/AppState.js @@ -29,7 +29,8 @@ import StudentNavigation from '../Components/StudentNavigation.js'; import ReportingDashboard from '../Admin/View/Reporting/ReportingDashboard.js'; import AdminAddCustomRubric from '../Admin/Add/AddCustomRubric/AdminAddCustomRubric.js'; import AdminViewCustomRubrics from '../Admin/View/ViewCustomRubrics/AdminViewCustomRubrics.js'; -import UserAccount from './UserAccount.js' +import UserAccount from './UserAccount.js'; +import ViewNotification from '../Admin/View/ViewDashboard/Notifications.js'; class AppState extends Component { @@ -468,22 +469,37 @@ class AppState extends Component { Users - - { - this.setState({ - activeTab: "AddUser", - user: null, - addUser: true - }); - }} - > - Add User - + + + { + this.setState({ + activeTab: "AddUser", + user: null, + addUser: true + }); + }} + > + Add User + + { + this.setState({ + activeTab: "ViewNotification", + user: null, + addUser: true + }); + }} + > + View Notifications + + + - @@ -834,6 +850,17 @@ class AppState extends Component { /> } + {this.state.activeTab==="ViewNotification" && + + + + + } ) }