@@ -54,6 +54,9 @@ import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
5454import Tooltip from '@mui/material/Tooltip' ;
5555import { convertDayToInt , convertIntToDay } from '../../../utils/calendar.utils' ;
5656import EditSeriesConfirmationModal from './EditSeriesConfirmationModal' ;
57+ import NotificationsIcon from '@mui/icons-material/Notifications' ;
58+ import NERSwitch from '../../../components/NERSwitch' ;
59+ import WarningAmberIcon from '@mui/icons-material/WarningAmber' ;
5760
5861export interface EventFormValues {
5962 title : string ;
@@ -237,6 +240,9 @@ const EventModal: React.FC<BaseEventModalProps> = ({
237240 const [ pendingPayload , setPendingPayload ] = useState < EventPayload | null > ( null ) ;
238241 const [ pendingFormData , setPendingFormData ] = useState < EventFormValues | null > ( null ) ;
239242
243+ // used in edit mode for ability to send notifs when wp changes
244+ const [ workPackageIds , setWorkPackageIds ] = useState < string [ ] > ( initialValues ?. workPackageIds ?? [ ] ) ;
245+
240246 // Fetch preview of other schedule slots that would be affected when editing with "edit all in series"
241247 const isEditMode = ! ! initialValues ;
242248 const scheduleSlotId = initialValues ?. selectedScheduleSlotId ;
@@ -1151,6 +1157,37 @@ const EventModal: React.FC<BaseEventModalProps> = ({
11511157 ) }
11521158 </ Box >
11531159 ) }
1160+ { /* Notification Section */ }
1161+ { selectedEventType && (
1162+ < Box sx = { { display : 'flex' , alignItems : 'center' , gap : 2 } } >
1163+ < NotificationsIcon
1164+ sx = { { color : selectedEventType . sendSlackNotifications ? 'text.secondary' : 'text.disabled' } }
1165+ />
1166+ < Tooltip
1167+ arrow
1168+ placement = "right"
1169+ title = {
1170+ ! selectedEventType . sendSlackNotifications
1171+ ? 'Slack notifications are disabled for this event type.'
1172+ : ! selectedTeams . length && ! workPackageIds . length
1173+ ? ''
1174+ : 'Slack notifications will be sent for this event.'
1175+ }
1176+ >
1177+ < Box sx = { { display : 'flex' , alignItems : 'center' , gap : 1 , cursor : 'default' } } >
1178+ < NERSwitch checked = { selectedEventType . sendSlackNotifications } disabled />
1179+ { selectedEventType . sendSlackNotifications && ! selectedTeams . length && ! workPackageIds . length ? (
1180+ < Box sx = { { display : 'flex' , alignItems : 'center' , gap : 0.5 } } >
1181+ < WarningAmberIcon sx = { { color : 'error.main' , fontSize : 18 } } />
1182+ < Typography variant = "body2" color = "error.main" >
1183+ Add a team or work package to send notifications
1184+ </ Typography >
1185+ </ Box >
1186+ ) : null }
1187+ </ Box >
1188+ </ Tooltip >
1189+ </ Box >
1190+ ) }
11541191 { /* Required Members Section */ }
11551192 { selectedEventType ?. requiredMembers && (
11561193 < Box sx = { { display : 'flex' , alignItems : 'flex-start' , gap : 2 } } >
@@ -1417,7 +1454,9 @@ const EventModal: React.FC<BaseEventModalProps> = ({
14171454 value = { workPackageOptions . find ( ( wp ) => value ?. [ 0 ] === wp . id ) || null }
14181455 onChange = { ( _ , newValue ) => {
14191456 if ( newValue ?. id !== 'loading' ) {
1420- onChange ( newValue ? [ newValue . id ] : [ ] ) ;
1457+ const ids = newValue ? [ newValue . id ] : [ ] ;
1458+ onChange ( ids ) ;
1459+ setWorkPackageIds ( ids ) ;
14211460 }
14221461 } }
14231462 getOptionLabel = { ( option ) => option . label }
0 commit comments