import React, { useState } from 'react' import { motion, AnimatePresence } from 'framer-motion' import { HiX, HiPlus, HiOutlineLink, HiOutlineUpload } from 'react-icons/hi' import classNames from 'classnames' export interface MediaItem { id: string type: 'image' | 'video' url: string file?: File } interface MediaManagerProps { media: MediaItem[] onChange: (media: MediaItem[]) => void onClose: () => void } const MediaManager: React.FC = ({ media, onChange, onClose }) => { const [activeTab, setActiveTab] = useState<'upload' | 'url'>('upload') const [urlInput, setUrlInput] = useState('') const [mediaType, setMediaType] = useState<'image' | 'video'>('image') const handleFileSelect = (e: React.ChangeEvent) => { const files = e.target.files if (!files) return const newMedia: MediaItem[] = Array.from(files).map((file) => ({ id: Math.random().toString(36).substr(2, 9), type: file.type.startsWith('video/') ? 'video' : 'image', url: URL.createObjectURL(file), file })) onChange([...media, ...newMedia]) e.target.value = '' } const handleUrlAdd = () => { if (!urlInput.trim()) return const newMedia: MediaItem = { id: Math.random().toString(36).substr(2, 9), type: mediaType, url: urlInput } onChange([...media, newMedia]) setUrlInput('') } const removeMedia = (id: string) => { onChange(media.filter((m) => m.id !== id)) } return (
{/* Header */}

Medya Ekle

{/* Tabs */}
{/* Content */}
{activeTab === 'upload' ? (
) : (
setUrlInput(e.target.value)} onKeyPress={(e) => e.key === 'Enter' && handleUrlAdd()} placeholder={`${mediaType === 'image' ? 'Resim' : 'Video'} URL'si girin`} className="flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500" />
)} {/* Media Preview */} {media.length > 0 && (

Eklenen Medyalar ({media.length})

{media.map((item) => (
{item.type === 'image' ? ( Media preview ) : (
)}
{item.type === 'image' ? '📷' : '🎥'}
))}
)}
{/* Footer */}
) } export default MediaManager