@@ -6,6 +6,7 @@ import { CourseInfo, TimeOffset, TimeZones } from 'types/course/admin/course';
66import { getCourseLogoUrl } from 'course/helper' ;
77import AvatarSelector from 'lib/components/core/AvatarSelector' ;
88import RadioButton from 'lib/components/core/buttons/RadioButton' ;
9+ import Prompt , { PromptText } from 'lib/components/core/dialogs/Prompt' ;
910import InfoLabel from 'lib/components/core/InfoLabel' ;
1011import Section from 'lib/components/core/layouts/Section' ;
1112import Subsection from 'lib/components/core/layouts/Subsection' ;
@@ -28,6 +29,8 @@ interface CourseSettingsFormProps {
2829 timeZones : TimeZones ;
2930 onSubmit : ( data : CourseInfo , timeOffset ?: TimeOffset ) => void ;
3031 onDeleteCourse : ( ) => void ;
32+ onSuspendCourse : ( ) => void ;
33+ onUnsuspendCourse : ( ) => void ;
3134 onUploadCourseLogo : ( image : File , onSuccess : ( ) => void ) => void ;
3235 disabled : boolean ;
3336}
@@ -38,11 +41,13 @@ const CourseSettingsForm = forwardRef<
3841> ( ( props , ref ) : JSX . Element => {
3942 const { t } = useTranslation ( ) ;
4043 const [ offsetTimesPrompt , setOffsetTimesPrompt ] = useState ( false ) ;
44+ const [ suspendingCourse , setSuspendingCourse ] = useState ( false ) ;
4145 const [ deletingCourse , setDeletingCourse ] = useState ( false ) ;
4246 const [ stagedLogo , setStagedLogo ] = useState < File > ( ) ;
4347
4448 const closeOffsetTimesPrompt = ( ) : void => setOffsetTimesPrompt ( false ) ;
4549 const closeDeleteCoursePrompt = ( ) : void => setDeletingCourse ( false ) ;
50+ const closeSuspendingCoursePrompt = ( ) : void => setSuspendingCourse ( false ) ;
4651
4752 const timeZonesOptions = useMemo (
4853 ( ) =>
@@ -327,13 +332,72 @@ const CourseSettingsForm = forwardRef<
327332 </ Section >
328333
329334 < Section sticksToNavbar title = { t ( translations . suspension ) } >
335+ { props . data . canSuspendCourse && (
336+ < >
337+ < Typography variant = "body2" >
338+ { t ( translations . suspendCourseDescription ) }
339+ </ Typography >
340+ { ! props . data . isSuspended && (
341+ < Button
342+ color = "warning"
343+ disabled = { props . disabled }
344+ onClick = { ( ) => setSuspendingCourse ( true ) }
345+ variant = "outlined"
346+ >
347+ { t ( translations . suspendCourse ) }
348+ </ Button >
349+ ) }
350+ < Prompt
351+ onClickPrimary = { ( ) => {
352+ props . onSuspendCourse ( ) ;
353+ setSuspendingCourse ( false ) ;
354+ } }
355+ onClose = { closeSuspendingCoursePrompt }
356+ open = { suspendingCourse }
357+ primaryColor = "warning"
358+ primaryLabel = { t ( translations . suspendCourse ) }
359+ >
360+ < PromptText >
361+ { t ( translations . suspendCoursePromptText ) }
362+ </ PromptText >
363+ </ Prompt >
364+ { props . data . isSuspended && (
365+ < Button
366+ color = "warning"
367+ disabled = { props . disabled }
368+ onClick = { props . onUnsuspendCourse }
369+ variant = "outlined"
370+ >
371+ { t ( translations . unsuspendCourse ) }
372+ </ Button >
373+ ) }
374+ < Subsection
375+ subtitle = { t ( translations . courseSuspensionMessageDescription ) }
376+ title = { t ( translations . courseSuspensionMessage ) }
377+ >
378+ < Controller
379+ control = { control }
380+ name = "courseSuspensionMessage"
381+ render = { ( { field, fieldState } ) : JSX . Element => (
382+ < FormTextField
383+ disabled = { props . disabled }
384+ field = { field }
385+ fieldState = { fieldState }
386+ fullWidth
387+ placeholder = { t ( courseTranslations . suspendedSubtitle ) }
388+ />
389+ ) }
390+ />
391+ </ Subsection >
392+ </ >
393+ ) }
330394 < Subsection
331- subtitle = { t ( translations . suspensionMessageDescription ) }
332- title = { t ( translations . suspensionMessage ) }
395+ subtitle = { t ( translations . userSuspensionMessageDescription ) }
396+ title = { t ( translations . userSuspensionMessage ) }
333397 >
334398 < Controller
335399 control = { control }
336- name = "suspensionMessage "
400+ name = "userSuspensionMessage "
337401 render = { ( { field, fieldState } ) : JSX . Element => (
338402 < FormTextField
339403 disabled = { props . disabled }
0 commit comments