From fefca6304eefea94f41057f9f934b0e19ceb54bb Mon Sep 17 00:00:00 2001
From: 0-Zz-ang <s1998319@gmail.com>
Date: Fri, 22 Aug 2025 13:47:37 +0900
Subject: (박서영)Compliance 설문/응답 리스트 생성
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../compliance-question-delete-dialog.tsx          | 107 +++++++++++++++++++++
 1 file changed, 107 insertions(+)
 create mode 100644 lib/compliance/questions/compliance-question-delete-dialog.tsx

(limited to 'lib/compliance/questions/compliance-question-delete-dialog.tsx')

diff --git a/lib/compliance/questions/compliance-question-delete-dialog.tsx b/lib/compliance/questions/compliance-question-delete-dialog.tsx
new file mode 100644
index 00000000..997721db
--- /dev/null
+++ b/lib/compliance/questions/compliance-question-delete-dialog.tsx
@@ -0,0 +1,107 @@
+"use client";
+
+import * as React from "react";
+import { Button } from "@/components/ui/button";
+import {
+  Dialog,
+  DialogContent,
+  DialogDescription,
+  DialogFooter,
+  DialogHeader,
+  DialogTitle,
+  DialogTrigger,
+} from "@/components/ui/dialog";
+import { Trash2 } from "lucide-react";
+import { deleteComplianceQuestion } from "@/lib/compliance/services";
+import { toast } from "sonner";
+import { useRouter } from "next/navigation";
+import { complianceQuestions } from "@/db/schema/compliance";
+
+interface ComplianceQuestionDeleteDialogProps {
+  question: typeof complianceQuestions.$inferSelect;
+  onSuccess?: () => void;
+}
+
+export function ComplianceQuestionDeleteDialog({ 
+  question, 
+  onSuccess 
+}: ComplianceQuestionDeleteDialogProps) {
+  const [open, setOpen] = React.useState(false);
+  const [isLoading, setIsLoading] = React.useState(false);
+  const router = useRouter();
+
+  const handleDelete = async () => {
+    try {
+      setIsLoading(true);
+      
+      await deleteComplianceQuestion(question.id);
+
+      toast.success("질문이 성공적으로 삭제되었습니다.");
+      setOpen(false);
+      
+      // 페이지 새로고침
+      router.refresh();
+      
+      if (onSuccess) {
+        onSuccess();
+      }
+    } catch (error) {
+      console.error("Error deleting question:", error);
+      toast.error("질문 삭제 중 오류가 발생했습니다.");
+    } finally {
+      setIsLoading(false);
+    }
+  };
+
+  return (
+    <Dialog open={open} onOpenChange={setOpen}>
+      <DialogTrigger asChild>
+        <Button variant="ghost" size="sm">
+          <Trash2 className="h-4 w-4" />
+        </Button>
+      </DialogTrigger>
+      <DialogContent>
+        <DialogHeader>
+          <DialogTitle>질문 삭제</DialogTitle>
+          <DialogDescription>
+            이 질문을 삭제하시겠습니까? 이 작업은 되돌릴 수 없습니다.
+          </DialogDescription>
+        </DialogHeader>
+        
+        <div className="py-4">
+          <div className="bg-muted p-4 rounded-lg">
+            <h4 className="font-medium mb-2">삭제될 질문:</h4>
+            <p className="text-sm text-muted-foreground">
+              <strong>질문 번호:</strong> {question.questionNumber}
+            </p>
+            <p className="text-sm text-muted-foreground">
+              <strong>질문 내용:</strong> {question.questionText}
+            </p>
+            <p className="text-sm text-muted-foreground">
+              <strong>질문 유형:</strong> {question.questionType}
+            </p>
+          </div>
+        </div>
+
+        <DialogFooter>
+          <Button 
+            type="button" 
+            variant="outline" 
+            onClick={() => setOpen(false)}
+            disabled={isLoading}
+          >
+            취소
+          </Button>
+          <Button 
+            type="button" 
+            variant="destructive" 
+            onClick={handleDelete}
+            disabled={isLoading}
+          >
+            {isLoading ? "삭제 중..." : "질문 삭제"}
+          </Button>
+        </DialogFooter>
+      </DialogContent>
+    </Dialog>
+  );
+}
-- 
cgit v1.2.3

