Skip to content

Commit 4d5e95e

Browse files
committed
feat: integrate DeleteConfirmModal for question and reply deletion
1 parent 4c25b16 commit 4d5e95e

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

apps/client/src/components/qna/QuestionItem.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
import { useToastStore } from '@/features/toast';
2121

2222
import { Button, CreateQuestionModal } from '@/components';
23+
import DeleteConfirmModal from '@/components/modal/DeleteConfirmModal';
2324

2425
interface QuestionItemProps {
2526
question: Question;
@@ -31,9 +32,8 @@ function QuestionItem({ question, onQuestionSelect }: QuestionItemProps) {
3132

3233
const { addToast } = useToastStore();
3334

34-
const { Modal, openModal } = useModal(
35-
<CreateQuestionModal question={question} />,
36-
);
35+
const { Modal: CreateQuestion, openModal: openCreateQuestionModal } =
36+
useModal(<CreateQuestionModal question={question} />);
3737

3838
const {
3939
sessionToken,
@@ -208,6 +208,10 @@ function QuestionItem({ question, onQuestionSelect }: QuestionItemProps) {
208208
});
209209
};
210210

211+
const { Modal: DeleteConfirm, openModal: openDeleteConfirmModal } = useModal(
212+
<DeleteConfirmModal onConfirm={handleDelete} />,
213+
);
214+
211215
return (
212216
<>
213217
<div
@@ -289,7 +293,7 @@ function QuestionItem({ question, onQuestionSelect }: QuestionItemProps) {
289293
question.replies.length === 0 && (
290294
<Button
291295
className='bg-gray-200/25 font-medium text-gray-500 hover:bg-gray-200/50 hover:transition-all'
292-
onClick={openModal}
296+
onClick={openCreateQuestionModal}
293297
>
294298
<FiEdit2 />
295299
</Button>
@@ -300,7 +304,7 @@ function QuestionItem({ question, onQuestionSelect }: QuestionItemProps) {
300304
question.replies.length === 0)) && (
301305
<Button
302306
className='bg-red-200/25 text-red-600 hover:bg-red-200/50 hover:transition-all'
303-
onClick={handleDelete}
307+
onClick={openDeleteConfirmModal}
304308
>
305309
<GrClose />
306310
</Button>
@@ -310,7 +314,8 @@ function QuestionItem({ question, onQuestionSelect }: QuestionItemProps) {
310314
</div>
311315
</div>
312316
</div>
313-
{Modal}
317+
{CreateQuestion}
318+
{DeleteConfirm}
314319
</>
315320
);
316321
}

apps/client/src/components/qna/ReplyItem.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { useToastStore } from '@/features/toast';
1717

1818
import { Button, CreateReplyModal } from '@/components';
19+
import DeleteConfirmModal from '@/components/modal/DeleteConfirmModal';
1920

2021
interface ReplyItemProps {
2122
question: Question;
@@ -28,7 +29,7 @@ function ReplyItem({ question, reply }: ReplyItemProps) {
2829
const { sessionId, sessionToken, isHost, expired, updateReply } =
2930
useSessionStore();
3031

31-
const { Modal, openModal } = useModal(
32+
const { Modal: CreateReply, openModal: openCreateReplyModal } = useModal(
3233
<CreateReplyModal question={question} reply={reply} />,
3334
);
3435

@@ -116,6 +117,10 @@ function ReplyItem({ question, reply }: ReplyItemProps) {
116117
});
117118
};
118119

120+
const { Modal: DeleteModal, openModal: openDeleteModal } = useModal(
121+
<DeleteConfirmModal onConfirm={() => handleDelete()} />,
122+
);
123+
119124
return (
120125
<>
121126
<div className='flex shrink basis-0 flex-col items-start justify-start gap-4 self-stretch px-12'>
@@ -155,15 +160,15 @@ function ReplyItem({ question, reply }: ReplyItemProps) {
155160
{reply.isOwner && (
156161
<Button
157162
className='bg-gray-200/25 hover:bg-gray-200/50 hover:transition-all'
158-
onClick={openModal}
163+
onClick={openCreateReplyModal}
159164
>
160165
<FiEdit2 />
161166
</Button>
162167
)}
163168
{(isHost || reply.isOwner) && (
164169
<Button
165170
className='bg-red-200/25 text-red-600 hover:bg-red-200/50 hover:transition-all'
166-
onClick={handleDelete}
171+
onClick={openDeleteModal}
167172
>
168173
<GrClose />
169174
</Button>
@@ -174,7 +179,8 @@ function ReplyItem({ question, reply }: ReplyItemProps) {
174179
</div>
175180
</div>
176181
</div>
177-
{Modal}
182+
{CreateReply}
183+
{DeleteModal}
178184
</>
179185
);
180186
}

0 commit comments

Comments
 (0)