diff --git a/src/components/pages/postPage/questionDetailPage.tsx b/src/components/pages/postPage/questionDetailPage.tsx index 2368a188..194c9394 100644 --- a/src/components/pages/postPage/questionDetailPage.tsx +++ b/src/components/pages/postPage/questionDetailPage.tsx @@ -216,7 +216,7 @@ function QuestionDetailPage() { content: questionContent, questionStatus: false, }; - // console.log('edit'); + console.log(questionId); try { await fetchAPI(`/api/question/${questionId}`, 'PATCH', editBody); } catch (error) { @@ -225,18 +225,28 @@ function QuestionDetailPage() { }; const handleClickDelete = async () => { - // console.log('delete'); + const deleteBody = { title: questionTitle, content: questionContent, questionStatus: false, }; + console.log(questionId); try { - await fetchAPI(`/api/question/${questionId}`, 'DELETE', deleteBody); - if (confirm('삭제하시겠습니까?')) + fetchAPI(`/api/question/${questionId}`, 'DELETE', deleteBody); + if (confirm('삭제하시겠습니까?')){ showSuccessToast('질문이 삭제되었습니다.'); + const pathSegments = window.location.pathname.split('/'); + const companyId = pathSegments[2]; + + navigate(`/company-info/${companyId}`); + + } } catch (error) { - if (error instanceof Error) showErrorToast(error.message); + if (error instanceof Error) + + showErrorToast(error.message); + console.log(error) } }; diff --git a/src/components/ui/myPageSelection/myAnswer.tsx b/src/components/ui/myPageSelection/myAnswer.tsx index 6a727474..9d460c41 100644 --- a/src/components/ui/myPageSelection/myAnswer.tsx +++ b/src/components/ui/myPageSelection/myAnswer.tsx @@ -80,7 +80,7 @@ export default function MyAnswer({ className="question-item" key={q.answerId} onClick={() => - navigate(`/company-info/${q.companyId}/${q.questionId}`) + navigate(`/company-info/${q.companyId}/${q.questionId}`,{state:{questionId: q.questionId}}) } >
diff --git a/src/components/ui/myPageSelection/myQuestion.tsx b/src/components/ui/myPageSelection/myQuestion.tsx index b4052959..f616e44e 100644 --- a/src/components/ui/myPageSelection/myQuestion.tsx +++ b/src/components/ui/myPageSelection/myQuestion.tsx @@ -85,7 +85,7 @@ export default function MyQuestion({ className="answer-item" key={q.questionId} onClick={() => - navigate(`/company-info/${q.companyId}/${q.questionId}`) + navigate(`/company-info/${q.companyId}/${q.questionId}`, {state:{questionId: q.questionId}}) } >
{q.companyName}