diff options
| author | rlaks5757 <rlaks5757@gmail.com> | 2025-03-27 17:48:36 +0900 |
|---|---|---|
| committer | rlaks5757 <rlaks5757@gmail.com> | 2025-03-27 17:48:36 +0900 |
| commit | 773918229ccb14c0d00798fbbf2b2be0130a8251 (patch) | |
| tree | ab9e200e65cc471ec139cd8482bde70a3b0a105f /lib/rfqs/vendor-table/comments-sheet.tsx | |
| parent | 92ddb4f13d48cbf344dc2bf63df4457b3c713608 (diff) | |
| parent | 34bbeb86c1a8d24b5f526710889b5e54d699cfd0 (diff) | |
merge complete
Diffstat (limited to 'lib/rfqs/vendor-table/comments-sheet.tsx')
| -rw-r--r-- | lib/rfqs/vendor-table/comments-sheet.tsx | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/rfqs/vendor-table/comments-sheet.tsx b/lib/rfqs/vendor-table/comments-sheet.tsx index 644869c6..3a2a9353 100644 --- a/lib/rfqs/vendor-table/comments-sheet.tsx +++ b/lib/rfqs/vendor-table/comments-sheet.tsx @@ -4,7 +4,7 @@ import * as React from "react" import { useForm, useFieldArray } from "react-hook-form" import { z } from "zod" import { zodResolver } from "@hookform/resolvers/zod" -import { Loader, Download, X } from "lucide-react" +import { Download, X, Loader2 } from "lucide-react" import prettyBytes from "pretty-bytes" import { toast } from "sonner" @@ -52,6 +52,7 @@ export interface MatchedVendorComment { id: number commentText: string commentedBy?: number + commentedByEmail?: string createdAt?: Date attachments?: { id: number @@ -67,6 +68,7 @@ interface CommentSheetProps extends React.ComponentPropsWithRef<typeof Sheet> { rfqId: number vendorId: number onCommentsUpdated?: (comments: MatchedVendorComment[]) => void + isLoading?: boolean // New prop } // 2) 폼 스키마 @@ -84,8 +86,12 @@ export function CommentSheet({ initialComments = [], currentUserId, onCommentsUpdated, + isLoading = false, // Default to false ...props }: CommentSheetProps) { + + console.log(initialComments) + const [comments, setComments] = React.useState<MatchedVendorComment[]>(initialComments) const [isPending, startTransition] = React.useTransition() @@ -108,6 +114,16 @@ export function CommentSheet({ // (A) 기존 코멘트 렌더링 function renderExistingComments() { + + if (isLoading) { + return ( + <div className="flex justify-center items-center h-32"> + <Loader2 className="h-4 w-4 animate-spin text-muted-foreground" /> + <span className="ml-2 text-sm text-muted-foreground">Loading comments...</span> + </div> + ) + } + if (comments.length === 0) { return <p className="text-sm text-muted-foreground">No comments yet</p> } @@ -134,7 +150,7 @@ export function CommentSheet({ {c.attachments.map((att) => ( <div key={att.id} className="flex items-center gap-2"> <a - href={att.filePath} + href={`/api/rfq-download?path=${encodeURIComponent(att.filePath)}`} download target="_blank" rel="noreferrer" @@ -149,7 +165,7 @@ export function CommentSheet({ )} </TableCell> <TableCell> { c.createdAt ? formatDate(c.createdAt): "-"}</TableCell> - <TableCell>{c.commentedBy ?? "-"}</TableCell> + <TableCell>{c.commentedByEmail ?? "-"}</TableCell> </TableRow> ))} </TableBody> @@ -173,6 +189,7 @@ export function CommentSheet({ commentText: data.commentText, commentedBy: currentUserId, evaluationId: null, + cbeId: null, files: data.newFiles, }) @@ -291,7 +308,7 @@ export function CommentSheet({ </Button> </SheetClose> <Button disabled={isPending}> - {isPending && <Loader className="mr-2 h-4 w-4 animate-spin" />} + {isPending && <Loader2 className="mr-2 h-4 w-4 animate-spin" />} Save </Button> </SheetFooter> |
