@@ -8,10 +8,11 @@ import {
8
8
DateInput ,
9
9
ResetButton
10
10
} from '@/Components/inputs' ;
11
- import { PrgSectionStatus } from '@/common' ;
11
+ import { PrgSectionStatus , ToastState } from '@/common' ;
12
12
import { SubmitHandler , useForm } from 'react-hook-form' ;
13
13
import { useState } from 'react' ;
14
14
import API from '@/api/api' ;
15
+ import { useToast } from '@/Context/ToastCtx' ;
15
16
16
17
interface SectionInputs {
17
18
capacity : number ;
@@ -28,6 +29,7 @@ export default function SectionManagementForm() {
28
29
const { id } = useParams < { id : string } > ( ) ;
29
30
const navigate = useNavigate ( ) ;
30
31
const [ errorMessage , setErrorMessage ] = useState ( '' ) ;
32
+ const { toaster } = useToast ( ) ;
31
33
const {
32
34
register,
33
35
handleSubmit,
@@ -50,10 +52,13 @@ export default function SectionManagementForm() {
50
52
formattedJson
51
53
) ;
52
54
if ( ! response . success ) {
53
- //should we put a toast message here??
54
- console . log ( 'error occurred, ' , response . message ) ;
55
+ toaster ( 'Failed to create class' , ToastState . error ) ;
56
+ console . log (
57
+ `error occurred while trying to create class, error message: ${ response . message } `
58
+ ) ;
55
59
return ;
56
60
}
61
+ toaster ( 'Class created successfully' , ToastState . success ) ;
57
62
reset ( ) ;
58
63
navigate ( `/programs/${ id } ` ) ;
59
64
} ;
0 commit comments