import React, { useState } from 'react' import { Modal, ModalRadioGroup, ModalSection, ModalDestinationButton, ModalInput, ModalTextarea, ModalSelect, ModalCheckbox, ModalLink, ModalDateTimeGroup, ModalButton, ModalButtonGroup, ModalPlatformCard } from '@shared/components' import { MdVideocam, MdVideoLibrary, MdAdd, MdImage, MdAutoAwesome, MdArrowBack } from 'react-icons/md' import { FaYoutube, FaFacebook, FaLinkedin, FaTwitch, FaInstagram, FaKickstarterK } from 'react-icons/fa' import { FaXTwitter } from 'react-icons/fa6' import { BsInfoCircle } from 'react-icons/bs' import styles from './NewTransmissionModal.module.css' import type { Transmission } from '../types' interface Props { open: boolean onClose: () => void onCreate: (t: Transmission) => void } interface DestinationData { id: string platform: string icon: React.ReactNode badge?: React.ReactNode } const NewTransmissionModal: React.FC = ({ open, onClose, onCreate }) => { const [view, setView] = useState<'main' | 'add-destination'>('main') const [source, setSource] = useState('studio') const [destinations, setDestinations] = useState([ { id: 'yt_1', platform: 'YouTube', icon: , badge: } ]) const [selectedDestination, setSelectedDestination] = useState(null) // Blank stream const [blankTitle, setBlankTitle] = useState('') // Form fields const [title, setTitle] = useState('') const [description, setDescription] = useState('') const [privacy, setPrivacy] = useState('Pública') const [category, setCategory] = useState('') const [addReferral, setAddReferral] = useState(true) const [scheduleForLater, setScheduleForLater] = useState(false) // Scheduled date/time const [scheduledDate, setScheduledDate] = useState('') const [scheduledHour, setScheduledHour] = useState('01') const [scheduledMinute, setScheduledMinute] = useState('10') const generateId = () => `t_${Date.now()}_${Math.floor(Math.random()*1000)}` const handleAddDestination = () => { setView('add-destination') } const handleBackToMain = () => { setView('main') } const handleSkipForNow = () => { setSelectedDestination('blank') } const handlePlatformSelect = (platform: string) => { const platformData: Record = { 'YouTube': { icon: , color: '#FF0000' }, 'Facebook': { icon: , color: '#1877F2' }, 'LinkedIn': { icon: , color: '#0A66C2' }, 'X (Twitter)': { icon: , color: '#000000' }, 'Twitch': { icon: , color: '#9146FF' }, 'Instagram Live': { icon: , color: '#E4405F' }, 'Kick': { icon: , color: '#53FC18' }, 'Brightcove': { icon:
B
, color: '#000000' } } const newDest: DestinationData = { id: `dest_${Date.now()}`, platform, icon: platformData[platform]?.icon || , badge: platform === 'YouTube' ? : undefined } setDestinations([...destinations, newDest]) setView('main') } const handleDestinationClick = (destId: string) => { // Si el destino ya está seleccionado, deseleccionarlo if (selectedDestination === destId) { setSelectedDestination(null) } else { setSelectedDestination(destId) } } const handleCreate = () => { if (!selectedDestination) { alert('Por favor selecciona un destino de transmisión') return } // Si es transmisión en blanco, usar el título del formulario blanco if (selectedDestination === 'blank') { // Por el momento solo cierra el modal // TODO: navegar a studio con título blankTitle onClose() return } const t: Transmission = { id: generateId(), title: title || 'Nueva transmisión', platform: destinations.find(d => d.id === selectedDestination)?.platform || 'YouTube', scheduled: '' } onCreate(t) // Reset form setView('main') setSource('studio') setSelectedDestination(null) setTitle('') setDescription('') setPrivacy('Pública') setCategory('') setAddReferral(true) setScheduleForLater(false) setScheduledDate('') setScheduledHour('01') setScheduledMinute('10') setBlankTitle('') } const modalTitle = view === 'add-destination' ? 'Agregar destino' : 'Crear transmisión en vivo' const showBackButton = view === 'add-destination' return ( {showBackButton && ( )} {view === 'main' && ( <>
} name="source" value={source} onChange={setSource} options={[ { value: 'studio', label: 'Estudio', icon: }, { value: 'prerecorded', label: 'Video pregrabado', icon: } ]} />
{destinations.map((dest) => (
handleDestinationClick(dest.id)} title={dest.platform} />
))} } label="" onClick={handleAddDestination} title="Agregar destino" /> {!selectedDestination && (
Omitir por ahora
)}
{selectedDestination && selectedDestination !== 'blank' && ( <> } subtext="Gana $25 en crédito por cada referencia exitosa." /> {scheduleForLater && ( <> } dateValue={scheduledDate} hourValue={scheduledHour} minuteValue={scheduledMinute} onDateChange={setScheduledDate} onHourChange={setScheduledHour} onMinuteChange={setScheduledMinute} timezone="GMT-7" /> } > Subir imagen en miniatura } > Crear con IA )} )} {selectedDestination === 'blank' && (

Empezarás una transmisión en el estudio sin configurar ningún destino. Podrás agregar destinos más tarde desde el estudio.

)}
{selectedDestination && selectedDestination !== 'blank' && (

Esta transmisión no se grabará en StreamYard. Para grabar, tendrás que{' '} pasarte a un plan superior.

)}
)} {view === 'add-destination' && (
} label="YouTube" onClick={() => handlePlatformSelect('YouTube')} /> } label="Facebook" onClick={() => handlePlatformSelect('Facebook')} /> } label="LinkedIn" onClick={() => handlePlatformSelect('LinkedIn')} /> } label="X (Twitter)" onClick={() => handlePlatformSelect('X (Twitter)')} /> } label="Twitch" onClick={() => handlePlatformSelect('Twitch')} /> } label="Instagram Live" onClick={() => handlePlatformSelect('Instagram Live')} /> } label="Kick" onClick={() => handlePlatformSelect('Kick')} badge="pro" /> B
} label="Brightcove" onClick={() => handlePlatformSelect('Brightcove')} /> RTMP} label="Otras plataformas" onClick={() => handlePlatformSelect('RTMP')} badge="pro" /> )}
) } export default NewTransmissionModal