From 7dede3787bcbbe3a7fa6d78e644ce5ff64a8e66c Mon Sep 17 00:00:00 2001 From: zaramalik03 Date: Tue, 19 Nov 2024 15:36:16 -0600 Subject: [PATCH 1/7] created Send Message button for Super Admin dashboard --- .../src/View/Components/SendMessageModal.js | 83 +++++++++++++++++++ FrontEndReact/src/View/Navbar/AppState.js | 25 +++++- 2 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 FrontEndReact/src/View/Components/SendMessageModal.js diff --git a/FrontEndReact/src/View/Components/SendMessageModal.js b/FrontEndReact/src/View/Components/SendMessageModal.js new file mode 100644 index 000000000..8a2672bfa --- /dev/null +++ b/FrontEndReact/src/View/Components/SendMessageModal.js @@ -0,0 +1,83 @@ +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 Notification to Admins"} + + + + + Use this form to send a message to all admin users. This notification will be delivered to their registered email addresses. + + + + + + + + + + + + + + + + + + ); +} diff --git a/FrontEndReact/src/View/Navbar/AppState.js b/FrontEndReact/src/View/Navbar/AppState.js index df9ce9095..ee7ba8325 100644 --- a/FrontEndReact/src/View/Navbar/AppState.js +++ b/FrontEndReact/src/View/Navbar/AppState.js @@ -30,6 +30,7 @@ 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 SendMessageModal from '../Components/SendMessageModal.js'; class AppState extends Component { @@ -465,7 +466,7 @@ class AppState extends Component { {this.state.activeTab==="SuperAdminUsers" && -
+
Users @@ -483,6 +484,18 @@ class AppState extends Component { > Add User +
} + + {this.state.activeTab==="SendMessageModal" && + + + + } ) } From a37d1a6f1849daadb64865124eaf99d17dbcceb4 Mon Sep 17 00:00:00 2001 From: zaramalik03 Date: Tue, 19 Nov 2024 15:51:08 -0600 Subject: [PATCH 2/7] edited parts of SendMessageModal --- .../src/View/Components/SendMessageModal.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/FrontEndReact/src/View/Components/SendMessageModal.js b/FrontEndReact/src/View/Components/SendMessageModal.js index 8a2672bfa..3cd444912 100644 --- a/FrontEndReact/src/View/Components/SendMessageModal.js +++ b/FrontEndReact/src/View/Components/SendMessageModal.js @@ -30,10 +30,10 @@ export default function SendMessageModal ( props ) { id="emailSubject" name="emailSubject" variant='outlined' - label="Subject" - value={props.subject} - error={!!props.error.subject} - helperText={props.error.subject} + label="Add Subject" + value={props.emailSubject} + error={!!props.error.emailSubject} + helperText={props.error.emailSubject} onChange={props.handleChange} required fullWidth @@ -47,10 +47,10 @@ export default function SendMessageModal ( props ) { id="emailMessage" name="emailMessage" variant='outlined' - label="Message" - value={props.message} - error={!!props.error.message} - helperText={props.error.message} + label="Add Message" + value={props.emailMessage} + error={!!props.error.emailMessage} + helperText={props.error.emailMessage} onChange={props.handleChange} required multiline From 320e2a1084d05e979ee550fd3d1b3ffbf4838ed9 Mon Sep 17 00:00:00 2001 From: zaramalik03 Date: Tue, 19 Nov 2024 15:56:57 -0600 Subject: [PATCH 3/7] error is gone but the page linked shows nothing --- .../src/View/Components/SendMessageModal.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/FrontEndReact/src/View/Components/SendMessageModal.js b/FrontEndReact/src/View/Components/SendMessageModal.js index 3cd444912..4ceb6e458 100644 --- a/FrontEndReact/src/View/Components/SendMessageModal.js +++ b/FrontEndReact/src/View/Components/SendMessageModal.js @@ -31,9 +31,9 @@ export default function SendMessageModal ( props ) { name="emailSubject" variant='outlined' label="Add Subject" - value={props.emailSubject} - error={!!props.error.emailSubject} - helperText={props.error.emailSubject} + value={props.emailSubject || ''} + error={!!(props.error && props.error.emailSubject)} + helperText={props.error?.emailSubject || ''} onChange={props.handleChange} required fullWidth @@ -48,9 +48,9 @@ export default function SendMessageModal ( props ) { name="emailMessage" variant='outlined' label="Add Message" - value={props.emailMessage} - error={!!props.error.emailMessage} - helperText={props.error.emailMessage} + value={props.emailMessage || ''} + error={!!(props.error && props.error.emailMessage)} + helperText={props.error?.emailMessage || ''} onChange={props.handleChange} required multiline From a5b5a60dbd838021782d2fdcc421ccf16b7ec294 Mon Sep 17 00:00:00 2001 From: zaramalik03 Date: Wed, 20 Nov 2024 15:09:00 -0600 Subject: [PATCH 4/7] added back button in send message page (super admin) --- FrontEndReact/src/View/Navbar/AppState.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/FrontEndReact/src/View/Navbar/AppState.js b/FrontEndReact/src/View/Navbar/AppState.js index ee7ba8325..216efa937 100644 --- a/FrontEndReact/src/View/Navbar/AppState.js +++ b/FrontEndReact/src/View/Navbar/AppState.js @@ -856,6 +856,10 @@ class AppState extends Component { tabSelected={"SendMessageModal"} aria-label="SendMessageModal" /> + } From b0e86b1c999e017b0fbdb5112228966493ca770f Mon Sep 17 00:00:00 2001 From: zaramalik03 Date: Mon, 2 Dec 2024 14:38:25 -0600 Subject: [PATCH 5/7] almost done, only an error when clicked on submit --- .../Admin/View/ViewDashboard/Notifications.js | 155 ++++++++++++++++++ .../src/View/Components/SendMessageModal.js | 27 ++- FrontEndReact/src/View/Navbar/AppState.js | 74 ++++----- 3 files changed, 202 insertions(+), 54 deletions(-) create mode 100644 FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js 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..a0e5b5d13 --- /dev/null +++ b/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js @@ -0,0 +1,155 @@ +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 { genericResourcePUT } from "../../../../utility.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, + // notes: '', + emailSubject: '', + emailMessage: '', + notificationSent: false, + + errors: { + // notes:'' + 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 notes = this.state.notes; + + var emailSubject = this.state.emailSubject; + + var emailMessage = this.state.emailMessage; + + // var navbar = this.props.navbar; + + // var state = navbar.state; + + // var chosenAssessmentTask = state.chosenAssessmentTask; + + var date = new Date(); + + 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; + } + + genericResourcePUT( + // `/assessment_task?assessment_task_id=${chosenAssessmentTask["assessment_task_id"]}¬ification=${true}`, + this, JSON.stringify({ + "notification_date": date, + "notification_message": emailMessage + }) + ).then((result) => { + if (result !== undefined && result.errorMessage === null) { + this.setState({ + showDialog: false, + notificationSent: date, + }); + } + }); + }; + + 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 index 4ceb6e458..115575446 100644 --- a/FrontEndReact/src/View/Components/SendMessageModal.js +++ b/FrontEndReact/src/View/Components/SendMessageModal.js @@ -16,7 +16,7 @@ export default function SendMessageModal ( props ) { aria-labelledby="responsive-dialog-title" > - {"Send Notification to Admins"} + {"Send Message to Admins"} @@ -31,9 +31,9 @@ export default function SendMessageModal ( props ) { name="emailSubject" variant='outlined' label="Add Subject" - value={props.emailSubject || ''} - error={!!(props.error && props.error.emailSubject)} - helperText={props.error?.emailSubject || ''} + value={props.emailSubject} + error={!!props.error.emailSubject} + helperText={props.error.emailSubject} onChange={props.handleChange} required fullWidth @@ -48,9 +48,9 @@ export default function SendMessageModal ( props ) { name="emailMessage" variant='outlined' label="Add Message" - value={props.emailMessage || ''} - error={!!(props.error && props.error.emailMessage)} - helperText={props.error?.emailMessage || ''} + value={props.emailMessage} + error={!!props.error.emailMessage} + helperText={props.error.emailMessage} onChange={props.handleChange} required multiline @@ -63,18 +63,11 @@ export default function SendMessageModal ( props ) { - - diff --git a/FrontEndReact/src/View/Navbar/AppState.js b/FrontEndReact/src/View/Navbar/AppState.js index 0298d0623..054ddaace 100644 --- a/FrontEndReact/src/View/Navbar/AppState.js +++ b/FrontEndReact/src/View/Navbar/AppState.js @@ -29,8 +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 SendMessageModal from '../Components/SendMessageModal.js'; +import UserAccount from './UserAccount.js'; +import ViewNotification from '../Admin/View/ViewDashboard/Notifications.js'; class AppState extends Component { @@ -465,38 +465,41 @@ class AppState extends Component { {this.state.activeTab==="SuperAdminUsers" && -
+
Users - - - + +
+ + +
+
- @@ -847,17 +850,14 @@ class AppState extends Component { /> } - - {this.state.activeTab==="SendMessageModal" && + {this.state.activeTab==="ViewNotification" && - - } From ea2ed82f40d98adfccf41673f066cd26c471b5bb Mon Sep 17 00:00:00 2001 From: zaramalik03 Date: Mon, 2 Dec 2024 15:59:42 -0600 Subject: [PATCH 6/7] Is working but no genericResourePUT since we have nothing in that page --- .../Admin/View/ViewDashboard/Notifications.js | 37 +++++++++---------- .../src/View/Components/SendMessageModal.js | 12 +++++- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js b/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js index a0e5b5d13..f098ef57a 100644 --- a/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js +++ b/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js @@ -7,7 +7,6 @@ import { genericResourcePUT } from "../../../../utility.js"; import SendMessageModal from '../../../Components/SendMessageModal.js'; import CustomDataTable from "../../../Components/CustomDataTable.js"; - class ViewNotification extends Component { constructor(props) { super(props); @@ -48,17 +47,15 @@ class ViewNotification extends Component { } handleSendNotification = () => { - // var notes = this.state.notes; - var emailSubject = this.state.emailSubject; var emailMessage = this.state.emailMessage; - // var navbar = this.props.navbar; + var navbar = this.props.navbar; - // var state = navbar.state; + var state = navbar.state; - // var chosenAssessmentTask = state.chosenAssessmentTask; + var chosenAssessmentTask = state.chosenAssessmentTask; var date = new Date(); @@ -94,20 +91,20 @@ class ViewNotification extends Component { return; } - genericResourcePUT( - // `/assessment_task?assessment_task_id=${chosenAssessmentTask["assessment_task_id"]}¬ification=${true}`, - this, JSON.stringify({ - "notification_date": date, - "notification_message": emailMessage - }) - ).then((result) => { - if (result !== undefined && result.errorMessage === null) { - this.setState({ - showDialog: false, - notificationSent: date, - }); - } - }); + // genericResourcePUT( + // this, JSON.stringify({ + // "notification_date": date, + // "notification_subject": emailSubject, + // "notification_message": emailMessage + // }) + // ).then((result) => { + // if (result !== undefined && result.errorMessage === null) { + // this.setState({ + // showDialog: false, + // notificationSent: date, + // }); + // } + // }); }; render() { diff --git a/FrontEndReact/src/View/Components/SendMessageModal.js b/FrontEndReact/src/View/Components/SendMessageModal.js index 115575446..31af4699d 100644 --- a/FrontEndReact/src/View/Components/SendMessageModal.js +++ b/FrontEndReact/src/View/Components/SendMessageModal.js @@ -66,7 +66,17 @@ export default function SendMessageModal ( props ) { - */} + From 422966437cde2e4e4ba183dbf2e47fe83ce13201 Mon Sep 17 00:00:00 2001 From: zaramalik03 Date: Tue, 3 Dec 2024 15:59:41 -0600 Subject: [PATCH 7/7] removed unecessary comments --- .../Admin/View/ViewDashboard/Notifications.js | 27 ------------------- .../src/View/Components/SendMessageModal.js | 4 +-- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js b/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js index f098ef57a..b9195bb92 100644 --- a/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js +++ b/FrontEndReact/src/View/Admin/View/ViewDashboard/Notifications.js @@ -3,7 +3,6 @@ import "bootstrap/dist/css/bootstrap.css"; import "../../../../SBStyles.css"; import { Box, Typography } from "@mui/material"; import CustomButton from "../../../Student/View/Components/CustomButton.js"; -import { genericResourcePUT } from "../../../../utility.js"; import SendMessageModal from '../../../Components/SendMessageModal.js'; import CustomDataTable from "../../../Components/CustomDataTable.js"; @@ -15,13 +14,11 @@ class ViewNotification extends Component { errorMessage: null, isLoaded: null, showDialog: false, - // notes: '', emailSubject: '', emailMessage: '', notificationSent: false, errors: { - // notes:'' emailSubject: '', emailMessage: '', } @@ -51,14 +48,6 @@ class ViewNotification extends Component { var emailMessage = this.state.emailMessage; - var navbar = this.props.navbar; - - var state = navbar.state; - - var chosenAssessmentTask = state.chosenAssessmentTask; - - var date = new Date(); - if (emailSubject.trim() === '' && emailMessage.trim() === '') { this.setState({ errors: { @@ -91,20 +80,6 @@ class ViewNotification extends Component { return; } - // genericResourcePUT( - // this, JSON.stringify({ - // "notification_date": date, - // "notification_subject": emailSubject, - // "notification_message": emailMessage - // }) - // ).then((result) => { - // if (result !== undefined && result.errorMessage === null) { - // this.setState({ - // showDialog: false, - // notificationSent: date, - // }); - // } - // }); }; render() { @@ -140,8 +115,6 @@ class ViewNotification extends Component { diff --git a/FrontEndReact/src/View/Components/SendMessageModal.js b/FrontEndReact/src/View/Components/SendMessageModal.js index 31af4699d..51509df5d 100644 --- a/FrontEndReact/src/View/Components/SendMessageModal.js +++ b/FrontEndReact/src/View/Components/SendMessageModal.js @@ -72,8 +72,8 @@ export default function SendMessageModal ( props ) {