Skip to content

Commit

Permalink
(#285)feat: 삭제로직 추가했습니다.
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJayleee committed May 8, 2024
1 parent 683fcbd commit 4164b5e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions src/components/pages/postPage/questionDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/myPageSelection/myAnswer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}})
}
>
<div className="question-text">
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/myPageSelection/myQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}})
}
>
<div className="answer-item-title">{q.companyName}</div>
Expand Down

0 comments on commit 4164b5e

Please sign in to comment.