From cf8dac0c6490469dab88a560004b0c07dbd48612 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 18 Sep 2025 00:23:40 +0000 Subject: (대표님) rfq, 계약, 서명 등 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/shi-signature/signature-list.tsx | 149 +++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 lib/shi-signature/signature-list.tsx (limited to 'lib/shi-signature/signature-list.tsx') diff --git a/lib/shi-signature/signature-list.tsx b/lib/shi-signature/signature-list.tsx new file mode 100644 index 00000000..93cd3dbe --- /dev/null +++ b/lib/shi-signature/signature-list.tsx @@ -0,0 +1,149 @@ +'use client'; + +import { useState } from 'react'; +import { BuyerSignature } from '@/db/schemae'; +import { setActiveSignature, deleteSignature } from './buyer-signature'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { Button } from '@/components/ui/button'; +import { Badge } from '@/components/ui/badge'; +import { Trash2, CheckCircle, Circle,Loader2 } from 'lucide-react'; +import { toast } from 'sonner'; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from '@/components/ui/alert-dialog'; + +interface SignatureListProps { + signatures: BuyerSignature[]; +} + +export function SignatureList({ signatures }: SignatureListProps) { + const [isUpdating, setIsUpdating] = useState(null); + + const handleSetActive = async (id: number) => { + setIsUpdating(id); + try { + const result = await setActiveSignature(id); + if (result.success) { + toast.success('활성 서명이 변경되었습니다.'); + } else { + toast.error(result.error || '변경에 실패했습니다.'); + } + } catch (error) { + toast.error('오류가 발생했습니다.'); + } finally { + setIsUpdating(null); + } + }; + + const handleDelete = async (id: number) => { + try { + const result = await deleteSignature(id); + if (result.success) { + toast.success('서명이 삭제되었습니다.'); + } else { + toast.error(result.error || '삭제에 실패했습니다.'); + } + } catch (error) { + toast.error('오류가 발생했습니다.'); + } + }; + + if (signatures.length === 0) { + return ( + + + 아직 업로드된 서명이 없습니다. + + + ); + } + + return ( + + + 서명 목록 + + + {signatures.map((signature) => ( +
+
+ 서명 +
+
+ {signature.name} + {signature.isActive && ( + + 활성 + + )} +
+

+ {new Date(signature.createdAt).toLocaleDateString()} +

+
+
+ +
+ {!signature.isActive && ( + + )} + + + + + + + + 서명 삭제 + + 이 서명을 삭제하시겠습니까? 이 작업은 취소할 수 없습니다. + + + + 취소 + handleDelete(signature.id)}> + 삭제 + + + + +
+
+ ))} +
+
+ ); +} \ No newline at end of file -- cgit v1.2.3