[as] feat: UploadedFileChip 컴포넌트 props 추가(onDownload)
This commit is contained in:
@@ -6,6 +6,7 @@ import { UploadedFileChip } from "./uploaded-file-chip";
|
||||
interface AttachmentFileFieldItem {
|
||||
fileKey: string;
|
||||
fileName: string;
|
||||
onDownload?: () => void;
|
||||
}
|
||||
|
||||
interface AttachmentFileFieldProps {
|
||||
@@ -41,6 +42,7 @@ function AttachmentFileField({
|
||||
fileName={file.fileName}
|
||||
isUploading={isUploadingByKey[file.fileKey] ?? false}
|
||||
onRemove={onRemove ? () => onRemove(index) : undefined}
|
||||
onDownload={file.onDownload}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -8,15 +8,36 @@ interface UploadedFileChipProps {
|
||||
fileName: string;
|
||||
isUploading?: boolean;
|
||||
onRemove?: () => void;
|
||||
onDownload?: () => void;
|
||||
}
|
||||
|
||||
function UploadedFileChip({ fileName, isUploading = false, onRemove }: UploadedFileChipProps) {
|
||||
function UploadedFileChip({
|
||||
fileName,
|
||||
isUploading = false,
|
||||
onRemove,
|
||||
onDownload,
|
||||
}: UploadedFileChipProps) {
|
||||
const canDownload = Boolean(onDownload) && !isUploading;
|
||||
|
||||
return (
|
||||
<div className="inline-flex items-center justify-between gap-2 rounded-sm border bg-accent px-3 py-2">
|
||||
<Paperclip className="size-5 shrink-0" />
|
||||
<TextShimmer className="text-xl" active={isUploading}>
|
||||
{fileName}
|
||||
</TextShimmer>
|
||||
{canDownload ? (
|
||||
<button
|
||||
type="button"
|
||||
className="cursor-pointer text-left hover:underline"
|
||||
aria-label={`${fileName} 다운로드`}
|
||||
onClick={onDownload}
|
||||
>
|
||||
<TextShimmer className="text-xl" active={isUploading}>
|
||||
{fileName}
|
||||
</TextShimmer>
|
||||
</button>
|
||||
) : (
|
||||
<TextShimmer className="text-xl" active={isUploading}>
|
||||
{fileName}
|
||||
</TextShimmer>
|
||||
)}
|
||||
{onRemove ? (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user