Skip to content

Commit

Permalink
๐Ÿ”€ Fix recruit State Btn API
Browse files Browse the repository at this point in the history
#265 ๋‚ด๊ฐ€ ๋ชจ์ง‘ ์ค‘์ธ ํŒ€ ๋ฏธ์„ ๋ฐœ/ํ•ฉ๋ฅ˜์™„๋ฃŒ ์ƒํƒœ๊ฐ’ API ์ˆ˜์ •
  • Loading branch information
sxxcxng authored Sep 28, 2024
2 parents dcd5e43 + e6c796d commit 68894e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
24 changes: 11 additions & 13 deletions gongjakso/src/pages/ProfileRecruit/ProfileRecruit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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}์— ํ•ด๋‹นํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.`);
}
};

Expand Down Expand Up @@ -288,7 +286,7 @@ const ProfileRecruit = () => {
</S.StyledThead>
<tbody>
{posts?.map((item, i, array) => (
<tr key={item.applyId}>
<tr key={item.id}>
<S.StyledTd
$state={item.is_canceled}
style={{
Expand All @@ -300,7 +298,7 @@ const ProfileRecruit = () => {
>
<S.User>
<img src={User} alt="UserImage" />
{item.memberName}
{item.applicant_name}
</S.User>
{item.is_canceled ? (
<S.CancelBox>
Expand All @@ -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,
);
}}
Expand Down
4 changes: 2 additions & 2 deletions gongjakso/src/service/apply_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit 68894e0

Please sign in to comment.