diff --git a/src/api/retroGroupsApi/deleteGroup.tsx b/src/api/retroGroupsApi/deleteGroup.tsx new file mode 100644 index 0000000..09856e2 --- /dev/null +++ b/src/api/retroGroupsApi/deleteGroup.tsx @@ -0,0 +1,11 @@ +import { DeleteRetrospectiveRequest } from '@/api/@types/Groups'; +import axiosInstance from '@/api/axiosConfig'; + +export const DeleteGroup = async ({ retrospectiveGroupId }: DeleteRetrospectiveRequest): Promise => { + try { + const response = await axiosInstance.delete(`/retrospectiveGroups/${retrospectiveGroupId}`); + return response.data; + } catch (error) { + throw new Error(error as string); + } +}; diff --git a/src/components/projectRetro/DeleteModal.tsx b/src/components/projectRetro/DeleteModal.tsx index 5298831..7143813 100644 --- a/src/components/projectRetro/DeleteModal.tsx +++ b/src/components/projectRetro/DeleteModal.tsx @@ -1,13 +1,30 @@ import { IoMdClose } from 'react-icons/io'; import { RiFolder6Fill } from 'react-icons/ri'; +import { DeleteGroup } from '@/api/retroGroupsApi/deleteGroup'; +import { useCustomToast } from '@/hooks/useCustomToast'; import * as S from '@/styles/projectRetro/DeleteModal.styles'; interface DeleteModalProps { isClose: () => void; - // groupId: number; + modalClose: () => void; + groupId: number; } -const DeleteModal: React.FC = ({ isClose }) => { +const DeleteModal: React.FC = ({ isClose, modalClose, groupId }) => { + const toast = useCustomToast(); + const handleDeleteGroup = async () => { + try { + await DeleteGroup({ retrospectiveGroupId: groupId }); + setTimeout(() => { + isClose(); + modalClose(); + toast.info('그룹이 삭제되었습니다.'); + }, 1000); + } catch (e) { + toast.error('그룹 삭제에 실패했습니다.'); + } + }; + return ( @@ -27,7 +44,7 @@ const DeleteModal: React.FC = ({ isClose }) => { 프로젝트1 {/* 프로젝트 이름 */} 를 삭제하시겠습니까? - Delete + Delete diff --git a/src/components/projectRetro/Modal.tsx b/src/components/projectRetro/Modal.tsx index 4d250b7..159b17b 100644 --- a/src/components/projectRetro/Modal.tsx +++ b/src/components/projectRetro/Modal.tsx @@ -214,7 +214,8 @@ const Modal: React.FC = ({ isClose, type, groupId }) => { - {deleteModal && setDeleteModal(false)} />} + {deleteModal && setDeleteModal(false)} modalClose={isClose} />}{' '} + {/* groupId 받아오기 */} ); };