From e6c796d8e0e821fc89d570e67b6e934d4b6fffb3 Mon Sep 17 00:00:00 2001 From: soobin Date: Sat, 28 Sep 2024 21:56:12 +0900 Subject: [PATCH] :bug: Fix recruit State Btn API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #265 모집중인팀 합류완료/미선발 버튼 API 상태값 수정 --- .../pages/ProfileRecruit/ProfileRecruit.jsx | 24 +++++++++---------- gongjakso/src/service/apply_service.js | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/gongjakso/src/pages/ProfileRecruit/ProfileRecruit.jsx b/gongjakso/src/pages/ProfileRecruit/ProfileRecruit.jsx index d81871c2..b68a8a26 100644 --- a/gongjakso/src/pages/ProfileRecruit/ProfileRecruit.jsx +++ b/gongjakso/src/pages/ProfileRecruit/ProfileRecruit.jsx @@ -90,8 +90,8 @@ const ProfileRecruit = () => { for (let i = 0; i < statuses.length; i++) { if (statuses[i] === 'black') { try { - const applyId = posts[i].applyId; - await patchApply(applyId, 'REJECTED'); + const id = posts[i].id; + await patchApply(id, 'REJECTED'); updatedStatuses[i] = 'notSelected'; } catch (error) { console.error('미선발 상태 업데이트 중 에러:', error); @@ -107,8 +107,8 @@ const ProfileRecruit = () => { for (let i = 0; i < statuses.length; i++) { if (statuses[i] === 'black') { try { - const applyId = posts[i].applyId; - await patchApply(applyId, 'ACCEPTED'); + const id = posts[i].id; + await patchApply(id, 'ACCEPTED'); updatedStatuses[i] = 'selected'; } catch (error) { console.error('합류 상태 업데이트 중 에러:', error); @@ -118,16 +118,14 @@ const ProfileRecruit = () => { setStatuses(updatedStatuses); }; - const handleClick = (index, applyId) => { + const handleClick = (index, id) => { const newData = [...posts]; // 데이터 복사 - const dataIndex = newData.findIndex(item => item.applyId === applyId); + const dataIndex = newData.findIndex(item => item.id === id); if (dataIndex !== -1) { newData[dataIndex].open = true; // 해당 데이터의 open 값을 true로 변경 setPosts(newData); // 상태 업데이트 } else { - console.error( - `ID ${applyId}에 해당하는 데이터를 찾을 수 없습니다.`, - ); + console.error(`ID ${id}에 해당하는 데이터를 찾을 수 없습니다.`); } }; @@ -288,7 +286,7 @@ const ProfileRecruit = () => { {posts?.map((item, i, array) => ( - + { > UserImage - {item.memberName} + {item.applicant_name} {item.is_canceled ? ( @@ -313,12 +311,12 @@ const ProfileRecruit = () => { setItem(i); handleClick(i, item.id); setShowApply(true); - setidNum(item.applyId); + setidNum(item.id); setidName( item.memberName, ); ClickOpen( - item.applyId, + item.id, item.state, ); }} diff --git a/gongjakso/src/service/apply_service.js b/gongjakso/src/service/apply_service.js index 9d6ab546..c9f29cef 100644 --- a/gongjakso/src/service/apply_service.js +++ b/gongjakso/src/service/apply_service.js @@ -143,8 +143,8 @@ export const getMyRecruitingTeam = async id => { }; // 지원자 합류하기, 미선발 -export const patchApply = async (applyId, status) => { - const reqURL = `apply/select/${applyId}`; +export const patchApply = async (id, status) => { + const reqURL = `apply/select/${id}`; try { const response = await axiosInstanceV2.patch(reqURL, { status });