diff options
Diffstat (limited to 'lib/b-rfq/attachment/revision-dialog.tsx')
| -rw-r--r-- | lib/b-rfq/attachment/revision-dialog.tsx | 196 |
1 files changed, 0 insertions, 196 deletions
diff --git a/lib/b-rfq/attachment/revision-dialog.tsx b/lib/b-rfq/attachment/revision-dialog.tsx deleted file mode 100644 index d26abedb..00000000 --- a/lib/b-rfq/attachment/revision-dialog.tsx +++ /dev/null @@ -1,196 +0,0 @@ -"use client" - -import * as React from "react" -import { Badge } from "@/components/ui/badge" -import { Button } from "@/components/ui/button" -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@/components/ui/dialog" -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table" -import { History, Download, Upload } from "lucide-react" -import { formatDate, formatBytes } from "@/lib/utils" -import { getAttachmentRevisions } from "../service" -import { AddRevisionDialog } from "./add-revision-dialog" - -interface RevisionDialogProps { - attachmentId: number - currentRevision: string - originalFileName: string -} - -export function RevisionDialog({ - attachmentId, - currentRevision, - originalFileName -}: RevisionDialogProps) { - const [open, setOpen] = React.useState(false) - const [revisions, setRevisions] = React.useState<any[]>([]) - const [isLoading, setIsLoading] = React.useState(false) - const [isAddRevisionOpen, setIsAddRevisionOpen] = React.useState(false) - - // 리비전 목록 로드 - const loadRevisions = async () => { - setIsLoading(true) - try { - const result = await getAttachmentRevisions(attachmentId) - - if (result.success) { - setRevisions(result.revisions) - } else { - console.error("Failed to load revisions:", result.message) - } - } catch (error) { - console.error("Failed to load revisions:", error) - } finally { - setIsLoading(false) - } - } - - React.useEffect(() => { - if (open) { - loadRevisions() - } - }, [open, attachmentId]) - - return ( - <> - <Dialog open={open} onOpenChange={setOpen}> - <DialogTrigger asChild> - <Button variant="ghost" size="sm" className="gap-2"> - <History className="h-4 w-4" /> - {currentRevision} - </Button> - </DialogTrigger> - - <DialogContent className="sm:max-w-[800px]" style={{maxWidth:800}}> - <DialogHeader> - <DialogTitle className="flex items-center gap-2"> - <History className="h-5 w-5" /> - 리비전 히스토리: {originalFileName} - </DialogTitle> - <DialogDescription> - 이 문서의 모든 버전을 확인하고 관리할 수 있습니다. - </DialogDescription> - </DialogHeader> - - <div className="space-y-4"> - {/* 새 리비전 추가 버튼 */} - <div className="flex justify-end"> - <Button - onClick={() => setIsAddRevisionOpen(true)} - className="gap-2" - > - <Upload className="h-4 w-4" /> - 새 리비전 추가 - </Button> - </div> - - {/* 리비전 목록 */} - {isLoading ? ( - <div className="text-center py-8">리비전을 불러오는 중...</div> - ) : ( - <div className="border rounded-lg"> - <Table> - <TableHeader> - <TableRow> - <TableHead>리비전</TableHead> - <TableHead>파일명</TableHead> - <TableHead>크기</TableHead> - <TableHead>업로드 일시</TableHead> - <TableHead>업로드자</TableHead> - <TableHead>코멘트</TableHead> - <TableHead>액션</TableHead> - </TableRow> - </TableHeader> - <TableBody> - {revisions.map((revision) => ( - <TableRow key={revision.id}> - <TableCell> - <div className="flex items-center gap-2"> - <Badge - variant={revision.isLatest ? "default" : "outline"} - > - {revision.revisionNo} - </Badge> - {revision.isLatest && ( - <Badge variant="secondary" className="text-xs"> - 최신 - </Badge> - )} - </div> - </TableCell> - - <TableCell> - <div> - <div className="font-medium">{revision.originalFileName}</div> - </div> - </TableCell> - - <TableCell> - {formatBytes(revision.fileSize)} - </TableCell> - - <TableCell> - {formatDate(revision.createdAt, "KR")} - </TableCell> - - <TableCell> - {revision.createdByName || "-"} - </TableCell> - - <TableCell> - <div className="max-w-[200px] truncate" title={revision.revisionComment}> - {revision.revisionComment || "-"} - </div> - </TableCell> - - <TableCell> - <Button - variant="ghost" - size="sm" - className="gap-2" - onClick={() => { - // 파일 다운로드 - window.open(revision.filePath, '_blank') - }} - > - <Download className="h-4 w-4" /> - 다운로드 - </Button> - </TableCell> - </TableRow> - ))} - </TableBody> - </Table> - </div> - )} - </div> - </DialogContent> - </Dialog> - - {/* 새 리비전 추가 다이얼로그 */} - <AddRevisionDialog - open={isAddRevisionOpen} - onOpenChange={setIsAddRevisionOpen} - attachmentId={attachmentId} - currentRevision={currentRevision} - originalFileName={originalFileName} - onSuccess={() => { - loadRevisions() // 리비전 목록 새로고침 - }} - /> - </> - ) - }
\ No newline at end of file |
