@@ -13,7 +13,10 @@ import {
1313 Button ,
1414 Stack ,
1515 Checkbox ,
16- FormControlLabel
16+ FormControlLabel ,
17+ ToggleButtonGroup ,
18+ ToggleButton ,
19+ useTheme
1720} from '@mui/material' ;
1821import { DatePicker , TimePicker } from '@mui/x-date-pickers' ;
1922import { Controller , useForm } from 'react-hook-form' ;
@@ -28,7 +31,8 @@ import {
2831 isHead ,
2932 MAX_FILE_SIZE ,
3033 getNextSevenDays ,
31- getDay
34+ getDay ,
35+ SlackMentionType
3236} from 'shared' ;
3337import { useToast } from '../../../hooks/toasts.hooks' ;
3438import { useAllMembers , useCurrentUser } from '../../../hooks/users.hooks' ;
@@ -79,6 +83,7 @@ export interface EventFormValues {
7983 recurrenceNumber : number ;
8084 days : DayOfWeek [ ] ;
8185 selectedScheduleSlotId ?: string ;
86+ mention : SlackMentionType ;
8287}
8388
8489export interface EventPayload {
@@ -96,6 +101,7 @@ export interface EventPayload {
96101 documentFiles : EventDocumentUploadArgs [ ] ;
97102 questionDocumentLink ?: string ;
98103 description ?: string ;
104+ mention : SlackMentionType ;
99105 // If the event type requires confirmation, only intialDateScheduled will be populated. If not,
100106 // scheduleSlots will be populated based on if the event is being editted or created
101107 initialDateScheduled ?: Date ;
@@ -144,7 +150,8 @@ const schema = yup.object().shape({
144150 allDay : yup . boolean ( ) . required ( ) ,
145151 recurrenceNumber : yup . number ( ) . min ( 0 ) . required ( 'Recurrence is required' ) ,
146152 days : yup . array ( ) . of ( yup . mixed < DayOfWeek > ( ) . required ( ) ) . default ( [ ] ) ,
147- selectedScheduleSlotId : yup . string ( ) . optional ( )
153+ selectedScheduleSlotId : yup . string ( ) . optional ( ) ,
154+ mention : yup . mixed < SlackMentionType > ( ) . required ( ) . default ( SlackMentionType . USER )
148155} ) ;
149156
150157export interface BaseEventModalProps {
@@ -221,6 +228,7 @@ const EventModal: React.FC<BaseEventModalProps> = ({
221228 eventId,
222229 actionsLeftChildren
223230} ) => {
231+ const theme = useTheme ( ) ;
224232 const toast = useToast ( ) ;
225233 const user = useCurrentUser ( ) ;
226234 const [ datePickerOpen , setDatePickerOpen ] = useState ( false ) ;
@@ -288,7 +296,8 @@ const EventModal: React.FC<BaseEventModalProps> = ({
288296 allDay : initialValues ?. allDay ?? false ,
289297 recurrenceNumber : 0 ,
290298 days : [ ] ,
291- selectedScheduleSlotId : initialValues ?. selectedScheduleSlotId
299+ selectedScheduleSlotId : initialValues ?. selectedScheduleSlotId ,
300+ mention : SlackMentionType . USER
292301 } ;
293302 } , [ initialValues , defaultDate , defaultStartTime , defaultEndTime ] ) ;
294303
@@ -506,7 +515,8 @@ const EventModal: React.FC<BaseEventModalProps> = ({
506515 workPackageIds : data . workPackageIds ,
507516 documentFiles : data . documentFiles ,
508517 questionDocumentLink : data . questionDocumentLink ,
509- description : data . description
518+ description : data . description ,
519+ mention : data . mention
510520 } ;
511521
512522 // If the event requires confirmation, only populate initialDateScheduled
@@ -1191,6 +1201,53 @@ const EventModal: React.FC<BaseEventModalProps> = ({
11911201 ) }
11921202 </ Box >
11931203 </ Tooltip >
1204+
1205+ { /* Slack Mention Type Toggle */ }
1206+ { selectedEventType . sendSlackNotifications && ! initialValues && (
1207+ < Box sx = { { display : 'flex' , alignItems : 'center' , gap : 1 , marginLeft : 'auto' } } >
1208+ < Controller
1209+ name = "mention"
1210+ control = { control }
1211+ render = { ( { field : { onChange, value } } ) => (
1212+ < ToggleButtonGroup
1213+ value = { value }
1214+ exclusive
1215+ onChange = { ( _ , val ) => {
1216+ if ( val ) onChange ( val ) ;
1217+ } }
1218+ size = "small"
1219+ sx = { {
1220+ '& .MuiToggleButton-root' : {
1221+ borderRadius : 0 ,
1222+ textTransform : 'none' ,
1223+ py : 0.55 ,
1224+ px : 1.1 ,
1225+ borderColor : theme . palette . divider ,
1226+ color : theme . palette . text . primary ,
1227+ '&.Mui-selected' : {
1228+ bgcolor : theme . palette . primary . main ,
1229+ color : 'black' ,
1230+ '&:hover' : { bgcolor : '#ff0000' , color : 'white' }
1231+ } ,
1232+ '&:hover' : { bgcolor : theme . palette . action . hover }
1233+ } ,
1234+ '& .MuiToggleButton-root:first-of-type' : {
1235+ borderTopLeftRadius : 8 ,
1236+ borderBottomLeftRadius : 8
1237+ } ,
1238+ '& .MuiToggleButton-root:last-of-type' : {
1239+ borderTopRightRadius : 8 ,
1240+ borderBottomRightRadius : 8
1241+ }
1242+ } }
1243+ >
1244+ < ToggleButton value = { SlackMentionType . USER } > @user</ ToggleButton >
1245+ < ToggleButton value = { SlackMentionType . CHANNEL } > @channel</ ToggleButton >
1246+ </ ToggleButtonGroup >
1247+ ) }
1248+ />
1249+ </ Box >
1250+ ) }
11941251 </ Box >
11951252 ) }
11961253 { /* Required Members Section */ }
0 commit comments