"use client"; import MediaPreviewModal from "@/components/shared/MediaPreviewModal"; import { Modal } from "@/components/ui"; import type { RequestAttachmentPreview } from "@/hooks/useRequestsPage"; import { getMediaKind } from "@/lib/media"; import { useAuthenticatedFileUrl } from "@/hooks/useAuthenticatedFileUrl"; import { FileSignature } from "lucide-react"; type RequestAttachmentPreviewModalProps = { onClose: () => void; preview: RequestAttachmentPreview | null; }; export function RequestAttachmentPreviewModal({ onClose, preview, }: RequestAttachmentPreviewModalProps) { const { url: previewUrl, error } = useAuthenticatedFileUrl( preview?.url || "", ); if (!preview) return null; if (!previewUrl) { return ( {error || "Загрузка вложения…"} ); } const mediaKind = getMediaKind({ fileName: preview.name || preview.url }); if (mediaKind === "image" || mediaKind === "video") { return ( ); } return ( Скачать } > {mediaKind === "audio" ? ( ) : ( {preview.name} Скачать файл )} ); }
{error || "Загрузка вложения…"}
{preview.name}