Skip to content

Commit

Permalink
✨ Feat: ProjectRetro 그룹 삭제 api 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
yeneua committed Jul 13, 2024
1 parent 64dd878 commit 7b310bc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/api/retroGroupsApi/deleteGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DeleteRetrospectiveRequest } from '@/api/@types/Groups';
import axiosInstance from '@/api/axiosConfig';

export const DeleteGroup = async ({ retrospectiveGroupId }: DeleteRetrospectiveRequest): Promise<void> => {
try {
const response = await axiosInstance.delete(`/retrospectiveGroups/${retrospectiveGroupId}`);
return response.data;
} catch (error) {
throw new Error(error as string);
}
};
23 changes: 20 additions & 3 deletions src/components/projectRetro/DeleteModal.tsx
Original file line number Diff line number Diff line change
@@ -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<DeleteModalProps> = ({ isClose }) => {
const DeleteModal: React.FC<DeleteModalProps> = ({ 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 (
<S.Background>
<S.Container>
Expand All @@ -27,7 +44,7 @@ const DeleteModal: React.FC<DeleteModalProps> = ({ isClose }) => {
<S.ProjectName>프로젝트1</S.ProjectName> {/* 프로젝트 이름 */}
<S.Text>를 삭제하시겠습니까?</S.Text>
</div>
<S.Button>Delete</S.Button>
<S.Button onClick={handleDeleteGroup}>Delete</S.Button>
</S.Bottom>
</S.Modal>
</S.Container>
Expand Down
3 changes: 2 additions & 1 deletion src/components/projectRetro/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ const Modal: React.FC<ModalProps> = ({ isClose, type, groupId }) => {
</S.ButtonContainer>
</S.Modal>
</S.Container>
{deleteModal && <DeleteModal isClose={() => setDeleteModal(false)} />}
{deleteModal && <DeleteModal groupId={9} isClose={() => setDeleteModal(false)} modalClose={isClose} />}{' '}
{/* groupId 받아오기 */}
</S.Background>
);
};
Expand Down

0 comments on commit 7b310bc

Please sign in to comment.