Skip to content

Commit e989fa2

Browse files
committed
feat: add functionality to create and schedule new section for facility admin per ticket id 47
1 parent 2de5ada commit e989fa2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

frontend/src/Pages/SectionManagementForm.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import {
88
DateInput,
99
ResetButton
1010
} from '@/Components/inputs';
11-
import { PrgSectionStatus } from '@/common';
11+
import { PrgSectionStatus, ToastState } from '@/common';
1212
import { SubmitHandler, useForm } from 'react-hook-form';
1313
import { useState } from 'react';
1414
import API from '@/api/api';
15+
import { useToast } from '@/Context/ToastCtx';
1516

1617
interface SectionInputs {
1718
capacity: number;
@@ -28,6 +29,7 @@ export default function SectionManagementForm() {
2829
const { id } = useParams<{ id: string }>();
2930
const navigate = useNavigate();
3031
const [errorMessage, setErrorMessage] = useState('');
32+
const { toaster } = useToast();
3133
const {
3234
register,
3335
handleSubmit,
@@ -50,10 +52,13 @@ export default function SectionManagementForm() {
5052
formattedJson
5153
);
5254
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+
);
5559
return;
5660
}
61+
toaster('Class created successfully', ToastState.success);
5762
reset();
5863
navigate(`/programs/${id}`);
5964
};

0 commit comments

Comments
 (0)