'use client' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import { Clock, MapPin } from 'lucide-react' interface ResourceAssignmentProps { resources: Array<{ resource_id: string resource_name: string resource_type: string capacity: number priority: number }> start_time: string end_time: string } /** * ResourceAssignment component that displays available resources for booking. */ export function ResourceAssignment({ resources, start_time, end_time }: ResourceAssignmentProps) { const formatDateTime = (dateTime: string) => { const date = new Date(dateTime) return new Intl.DateTimeFormat('es-MX', { dateStyle: 'full', timeStyle: 'short', timeZone: 'America/Monterrey' }).format(date) } const getPriorityColor = (priority: number) => { switch (priority) { case 1: return 'bg-green-100 text-green-700 border-green-300' case 2: return 'bg-blue-100 text-blue-700 border-blue-300' case 3: return 'bg-gray-100 text-gray-700 border-gray-300' default: return 'bg-gray-100 text-gray-700 border-gray-300' } } const getPriorityLabel = (priority: number) => { switch (priority) { case 1: return 'Alta' case 2: return 'Media' case 3: return 'Baja' default: return 'Normal' } } const getTypeLabel = (type: string) => { switch (type) { case 'station': return 'Estación' case 'room': return 'Sala' case 'equipment': return 'Equipo' default: return type } } const getRecommendedResource = () => { return resources.length > 0 ? resources[0] : null } const recommended = getRecommendedResource() return ( Espacios Disponibles {formatDateTime(start_time)} - {new Date(end_time).toLocaleTimeString('es-MX', { timeZone: 'America/Monterrey' })} {resources.length === 0 ? (

No hay espacios disponibles para este horario

) : ( <> {recommended && (
Recomendado

{recommended.resource_name}

{getPriorityLabel(recommended.priority)}
{getTypeLabel(recommended.resource_type)}
Capacidad: {recommended.capacity} persona(s)
)} {resources.length > 1 && ( <>

Otros espacios disponibles:

{resources.slice(1).map((resource, index) => (

{resource.resource_name}

{getTypeLabel(resource.resource_type)} • Capacidad: {resource.capacity}

{getPriorityLabel(resource.priority)}
))}
)}

Prioridad de asignación:

  • 1. Estaciones (prioridad alta)
  • 2. Salas (prioridad media)
  • 3. Equipo (prioridad baja)
)}
) }