import { useState, useEffect } from "react"; import { X, Image, MousePointerClick } from "lucide-react"; import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import type { Creative } from "@/lib/types/api"; interface CreativeMediaItem { media_type: string; media_file_id: string; position: number; s3_url?: string | null; } interface CreativeButton { text: string; url: string; } interface CreativeSelectDialogProps { open: boolean; onOpenChange: (open: boolean) => void; creatives: { id: string; name: string; text: string; media_items: CreativeMediaItem[]; buttons: CreativeButton[]; }[]; onSelect: (creative: { id: string; name: string; thumbnail_url?: string | null }) => void; onClear: (() => void) | null; currentCreativeId: string | null | undefined; } function CreativeCard({ creative, isSelected, onClick, }: { creative: { id: string; name: string; text: string; media_items: CreativeMediaItem[]; buttons: CreativeButton[]; }; isSelected: boolean; onClick: () => void; }) { const thumbnailUrl = creative.media_items?.[0]?.s3_url; const imagesCount = creative.media_items?.length || 0; const buttonsCount = creative.buttons?.length || 0; const cleanText = creative.text?.replace(/<[^>]+>/g, '') || ''; const truncatedText = cleanText.substring(0, 80) + (cleanText.length > 80 ? '...' : ''); return (
{truncatedText || 'Без текста'}