'use client' import { useState, useEffect } from 'react' import { Button } from '@/components/ui/button' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { BookingConfirmation } from '@/components/kiosk/BookingConfirmation' import { WalkInFlow } from '@/components/kiosk/WalkInFlow' import { Calendar, UserPlus, MapPin, Clock } from 'lucide-react' /** * @description Kiosk interface component for location-based check-in confirmations and walk-in booking creation * @param {Object} params - Route parameters containing the locationId * @param {string} params.locationId - The UUID of the salon location this kiosk serves * @returns {JSX.Element} Interactive kiosk interface with authentication, clock, and action cards * @audit BUSINESS RULE: Kiosk enables customer self-service for check-in and walk-in bookings * @audit BUSINESS RULE: Real-time clock displays in location's timezone for customer reference * @audit SECURITY: Device authentication via API key required before any operations * @audit SECURITY: Kiosk mode has no user authentication - relies on device-level security * @audit Validate: Location must be active and have associated kiosk device registered * @audit PERFORMANCE: Single-page app with view-based rendering (no page reloads) * @audit AUDIT: Kiosk operations logged for security and operational monitoring */ export default function KioskPage({ params }: { params: { locationId: string } }) { const [apiKey, setApiKey] = useState(null) const [location, setLocation] = useState(null) const [currentView, setCurrentView] = useState<'home' | 'confirm' | 'walkin'>('home') const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const [currentTime, setCurrentTime] = useState(new Date()) useEffect(() => { const timer = setInterval(() => { setCurrentTime(new Date()) }, 1000) return () => clearInterval(timer) }, []) useEffect(() => { const authenticateKiosk = async () => { setLoading(true) setError(null) try { const response = await fetch('/api/kiosk/authenticate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ api_key: process.env.NEXT_PUBLIC_KIOSK_API_KEY || 'demo-api-key-64-characters-long-enough' }) }) const data = await response.json() if (!response.ok) { throw new Error(data.error || 'Authentication failed') } setApiKey(data.kiosk.device_name) setLocation(data.kiosk.location) } catch (err) { setError(err instanceof Error ? err.message : 'Error de autenticación del kiosko') } finally { setLoading(false) } } authenticateKiosk() }, []) const formatDateTime = (date: Date) => { return new Intl.DateTimeFormat('es-MX', { dateStyle: 'full', timeStyle: 'short', timeZone: location?.timezone || 'America/Monterrey' }).format(date) } if (loading) { return (

Iniciando kiosko...

) } if (error) { return (
Error de Conexión
{error}
) } if (currentView === 'confirm') { return (
{ setCurrentView('home') }} onCancel={() => setCurrentView('home')} />
) } if (currentView === 'walkin') { return (
{ setCurrentView('home') }} onCancel={() => setCurrentView('home')} />
) } return (

{location?.name || 'Kiosko'}

Kiosko Principal
{formatDateTime(currentTime)}

ID del Kiosko

{apiKey || 'N/A'}

setCurrentView('confirm')} >
Confirmar Cita Confirma tu llegada ingresando el código de tu cita
setCurrentView('walkin')} >
Reserva Inmediata Crea una reserva sin cita previa (Walk-in)
Instrucciones

Confirmar Cita

  1. Selecciona "Confirmar Cita"
  2. Ingresa el código de 6 caracteres de tu reserva
  3. Verifica los detalles de tu cita
  4. Confirma tu llegada

Reserva Inmediata

  1. Selecciona "Reserva Inmediata"
  2. Elige el servicio que deseas
  3. Ingresa tus datos personales
  4. Confirma la reserva
) }