From 2c90d442c227de9ee2b6ebcc9c49ec43f3138d89 Mon Sep 17 00:00:00 2001 From: leehyeon Date: Wed, 14 Aug 2024 12:28:29 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat=20:=20vote=20post,=20get,=20delete=20a?= =?UTF-8?q?pi=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/recoil/states/vote.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/recoil/states/vote.ts b/src/recoil/states/vote.ts index b35fc26..464f568 100644 --- a/src/recoil/states/vote.ts +++ b/src/recoil/states/vote.ts @@ -247,6 +247,12 @@ export const selectedAgendaPics = atom({ default: null, }); +//투표현황 조회 결과 저장 api +export const selectedAgendaPics = atom({ + key: 'selectedAgendaPics', + default: null, +}); + // 안건에 등록할 사진들 export const registeredPics = atom({ key: 'registerdPics', From 2678c8d4b841a022a8360e6076d2aa045e841e20 Mon Sep 17 00:00:00 2001 From: E-hyeon Date: Sat, 17 Aug 2024 00:29:44 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat=20:=20Agenda=20delete=20api=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/deleteAgenda.ts | 23 +++++++++++++++++++++++ src/components/Vote/VoteList/VoteList.tsx | 14 ++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/apis/deleteAgenda.ts diff --git a/src/apis/deleteAgenda.ts b/src/apis/deleteAgenda.ts new file mode 100644 index 0000000..03a593c --- /dev/null +++ b/src/apis/deleteAgenda.ts @@ -0,0 +1,23 @@ +import { authInstance } from './instance'; + +const SERVER_URL = process.env.REACT_APP_SERVER_URL; + +interface IDeleteAgenda { + agendaId: number; +} + +export async function deleteAgenda({ agendaId }: IDeleteAgenda): Promise { + try { + const response = await authInstance().delete( + `${SERVER_URL}/agendas/${agendaId}`, + ); + if (response.status === 200) { + console.log('Agenda deleted successfully'); + } else { + throw new Error('Failed to delete agenda'); + } + } catch (error) { + console.error('Error deleting agenda:', error); + throw error; + } +} diff --git a/src/components/Vote/VoteList/VoteList.tsx b/src/components/Vote/VoteList/VoteList.tsx index 967ab83..2c8b525 100644 --- a/src/components/Vote/VoteList/VoteList.tsx +++ b/src/components/Vote/VoteList/VoteList.tsx @@ -6,6 +6,7 @@ import { useRecoilValue, useSetRecoilState } from 'recoil'; import { agendasList, selectedAgendaId } from 'recoil/states/vote'; import { useSwipeable } from 'react-swipeable'; import axios from 'axios'; +import { deleteAgenda } from 'apis/deleteAgenda'; const SERVER_URL = process.env.REACT_APP_SERVER_URL; @@ -50,6 +51,19 @@ const VoteList = () => { }, [currentPage]); */ + //delete api 호출 주석처리 + /* + const handleDelete = async (id: number) => { + try { + await deleteAgenda({ agendaId: id }); // 객체 형태로 전달 + // 삭제 후 상태를 새로 고칩니다 + fetchAgendas(currentPage); + } catch (error) { + console.error('Error deleting agenda:', error); + setError('Failed to delete agenda'); + } + }; + */ const handleClickBtn = (id: number) => { // setAgendaId(id); navigate('/vote/detail');