diff --git a/csm_web/frontend/src/components/coord_interface/CoordSectionDelete.tsx b/csm_web/frontend/src/components/coord_interface/CoordSectionDelete.tsx index 8c1aedf3..9cf61188 100644 --- a/csm_web/frontend/src/components/coord_interface/CoordSectionDelete.tsx +++ b/csm_web/frontend/src/components/coord_interface/CoordSectionDelete.tsx @@ -1,55 +1,50 @@ import React, { useState } from "react"; +import { useNavigate } from "react-router-dom"; -import { useCoordDeleteSectionMutation } from "../../utils/queries/coord"; -// import Modal from "../Modal"; -import XIcon from "../../../static/frontend/img/x.svg"; +import { useDeleteSectionMutation } from "../../utils/queries/sections"; +import Modal from "../Modal"; +import TrashIcon from "../../../static/frontend/img/trash-alt.svg"; -// import "../../css/student_dropper.scss"; +import "../../css/section_delete.scss"; interface CoordSectionDeleteProps { sectionId: number; } export default function CoordSectionDelete({ sectionId }: CoordSectionDeleteProps) { - const [showDropPrompt, setShowDropPrompt] = useState(false); - const [drop, setDrop] = useState(false); - const [ban, setBan] = useState(false); - const [blacklist, setBlacklist] = useState(false); - - /** - * Mutation to drop a student from the section. (Inspiration taken from dropping students within sections) - */ - const coordSectionDeleteMutation = useCoordDeleteSectionMutation(sectionId); - - function handleClickDrop() { - coordSectionDeleteMutation.mutate({ banned: ban, blacklisted: blacklist }); - setShowDropPrompt(false); + const [showDeletePrompt, setShowDeletePrompt] = useState(false); + const [confirmed, setConfirmed] = useState(false); + const deleteSectionMutation = useDeleteSectionMutation(sectionId); + const navigate = useNavigate(); + + function handleDelete() { + deleteSectionMutation.mutate(undefined, { + onSuccess: () => navigate(-1) + }); } - const dropDiv = ( -
-

DROP Student

-
- setDrop(e.target.checked)} /> - -

-
-
- ); - return ( - // - // setShowDropPrompt(true)} - // /> - //
dropDiv
- - //
+
+ + {showDeletePrompt && ( + setShowDeletePrompt(false)}> +

Delete section

+

This section will be hidden, but its enrollment and attendance history will be preserved.

+ + +
+ )} +
); } diff --git a/csm_web/frontend/src/components/section/MentorSectionInfo.tsx b/csm_web/frontend/src/components/section/MentorSectionInfo.tsx index d3ecddce..84ce3319 100644 --- a/csm_web/frontend/src/components/section/MentorSectionInfo.tsx +++ b/csm_web/frontend/src/components/section/MentorSectionInfo.tsx @@ -8,6 +8,7 @@ import { } from "../../utils/queries/sections"; import { Mentor, Spacetime, Student } from "../../utils/types"; import LoadingSpinner from "../LoadingSpinner"; +import CoordSectionDelete from "../coord_interface/CoordSectionDelete"; import { CoordinatorAddStudentModal } from "./CoordinatorAddStudentModal"; import MetaEditModal from "./MetaEditModal"; import { InfoCard, SectionSpacetime } from "./Section"; @@ -16,7 +17,7 @@ import SpacetimeEditModal from "./SpacetimeEditModal"; import StudentDropper from "./StudentDropper"; import PencilIcon from "../../../static/frontend/img/pencil.svg"; -import XIcon from "../../../static/frontend/img/x.svg"; +import TrashIcon from "../../../static/frontend/img/trash-alt.svg"; import "../../css/coordinator-add-student.scss"; @@ -162,6 +163,7 @@ export default function MentorSectionInfo({

{`${ isCoordinator ? `${mentor.name || mentor.email}'s` : "My" } Section`}

+ {isCoordinator && }
- Delete +