diff --git a/apps/frontend/components/chat/chat-media-compose-dialog.tsx b/apps/frontend/components/chat/chat-media-compose-dialog.tsx index ed4b13f..e2fb733 100644 --- a/apps/frontend/components/chat/chat-media-compose-dialog.tsx +++ b/apps/frontend/components/chat/chat-media-compose-dialog.tsx @@ -6,13 +6,14 @@ import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { createFilePreviewUrl, isCompressibleImageFile, readImageDimensions } from '@/lib/chat-image-compress'; -import { formatFileSize } from '@/lib/chat-media'; +import { formatFileSize, getComposeDialogTitle, getComposeMediaKind, type ComposeMediaKind } from '@/lib/chat-media'; import { cn } from '@/lib/utils'; export interface ChatMediaComposeItem { id: string; file: File; previewUrl: string | null; + mediaKind: ComposeMediaKind; sendAsFile: boolean; width?: number; height?: number; @@ -25,6 +26,7 @@ function createComposeItem(file: File, sendAsFile = false): ChatMediaComposeItem id: crypto.randomUUID(), file, previewUrl: createFilePreviewUrl(file), + mediaKind: getComposeMediaKind(file), sendAsFile }; } @@ -159,32 +161,21 @@ export function ChatMediaComposeDialog({ }: ChatMediaComposeDialogProps) { const addInputRef = useRef(null); const activePreview = items[0] ?? null; + const dialogTitle = getComposeDialogTitle(items.map((item) => item.file)); return ( !next && onClose()}>
- {items.length > 1 ? `Отправить ${items.length} файла` : 'Отправить изображение'} + {dialogTitle}
{activePreview ? (
- {activePreview.previewUrl ? ( - // eslint-disable-next-line @next/next/no-img-element - {activePreview.file.name} - ) : ( -
-

{activePreview.file.name}

-

{formatFileSize(activePreview.file.size)}

-
- )} + ))}
- ) : activePreview?.previewUrl ? ( + ) : activePreview?.mediaKind === 'image' && activePreview.previewUrl ? (

Для редактирования нажмите на изображение

+ ) : activePreview?.mediaKind === 'video' ? ( +

Проверьте видео перед отправкой

) : null} {hasImages ? ( @@ -314,6 +302,43 @@ export function ChatMediaDropOverlay({ visible, onDropCompressed, onDropAsFile } ); } +function ComposeMediaPreview({ + item, + className, + thumbnail = false +}: { + item: ChatMediaComposeItem; + className?: string; + thumbnail?: boolean; +}) { + if (item.mediaKind === 'video' && item.previewUrl) { + return ( +