mirror of
https://github.com/marcogll/AnchorOS.git
synced 2026-03-15 11:24:26 +00:00
## Sistema de Kiosko ✅ - Nuevo rol 'kiosk' en enum user_role - Tabla kiosks con autenticación por API key (64 caracteres) - Funciones SQL: generate_kiosk_api_key(), is_kiosk(), get_available_resources_with_priority() - API Routes: authenticate, bookings (GET/POST), confirm, resources/available, walkin - Componentes UI: BookingConfirmation, WalkInFlow, ResourceAssignment - Página kiosko: /kiosk/[locationId]/page.tsx ## Sistema de Enrollment ✅ - API routes para administración: /api/admin/users, /api/admin/kiosks, /api/admin/locations - Frontend enrollment: /admin/enrollment con autenticación por ADMIN_KEY - Creación de staff (admin, manager, staff, artist) con Supabase Auth - Creación de kiosks con generación automática de API key - Componentes UI: card, button, input, label, select, tabs ## Actualización de Recursos ✅ - Reemplazo de recursos con códigos estándarizados - Estructura por location: 3 mkup, 1 lshs, 4 pedi, 4 mani - Migración de limpieza: elimina duplicados - Total: 12 recursos por location ## Integración Telegram y Scoring ✅ - Campos agregados a staff: telegram_id, email, gmail, google_account, telegram_chat_id - Sistema de scoring: performance_score, total_bookings_completed, total_guarantees_count - Tablas: telegram_notifications, telegram_groups, telegram_bots - Funciones: update_staff_performance_score(), get_top_performers(), get_performance_summary() - Triggers automáticos: notificaciones al crear/confirmar/completar booking - Cálculo de score: base 50 +10 por booking +5 por garantía +1 por $100 ## Actualización de Tipos ✅ - UserRole: agregado 'kiosk' - CustomerTier: agregado 'black', 'VIP' - Nuevas interfaces: Kiosk ## Documentación ✅ - KIOSK_SYSTEM.md: Documentación completa del sistema - KIOSK_IMPLEMENTATION.md: Guía rápida - ENROLLMENT_SYSTEM.md: Sistema de enrollment - RESOURCES_UPDATE.md: Actualización de recursos - PROJECT_UPDATE_JAN_2026.md: Resumen de proyecto ## Componentes UI (7) - button.tsx, card.tsx, input.tsx, label.tsx, select.tsx, tabs.tsx ## Migraciones SQL (4) - 20260116000000_add_kiosk_system.sql - 20260116010000_update_resources.sql - 20260116020000_cleanup_and_fix_resources.sql - 20260116030000_telegram_integration.sql ## Métricas - ~7,500 líneas de código - 32 archivos creados/modificados - 7 componentes UI - 10 API routes - 4 migraciones SQL
149 lines
5.4 KiB
SQL
149 lines
5.4 KiB
SQL
-- ============================================
|
|
-- LIMPIEZA Y REESTRUCTURACIÓN DE RECURSOS
|
|
-- Elimina duplicados y establece formato estándar
|
|
-- ============================================
|
|
|
|
-- 1. OBTENER INFORMACIÓN DE LO QUE SERÁ ELIMINADO
|
|
DO $$
|
|
DECLARE
|
|
resources_count INTEGER;
|
|
locations_count INTEGER;
|
|
bookings_count INTEGER;
|
|
BEGIN
|
|
SELECT COUNT(*) INTO resources_count FROM resources;
|
|
SELECT COUNT(*) INTO locations_count FROM locations WHERE is_active = true;
|
|
SELECT COUNT(*) INTO bookings_count FROM bookings;
|
|
|
|
RAISE NOTICE '==========================================';
|
|
RAISE NOTICE 'ANTES DE LA MIGRACIÓN:';
|
|
RAISE NOTICE '==========================================';
|
|
RAISE NOTICE 'Resources existentes: %', resources_count;
|
|
RAISE NOTICE 'Locations activas: %', locations_count;
|
|
RAISE NOTICE 'Bookings activos: %', bookings_count;
|
|
RAISE NOTICE '==========================================';
|
|
RAISE NOTICE 'ADVERTENCIA: Todos estos recursos';
|
|
RAISE NOTICE 'serán eliminados.';
|
|
RAISE NOTICE '==========================================';
|
|
END
|
|
$$;
|
|
|
|
-- 2. ELIMINAR TODOS LOS RECURSOS EXISTENTES
|
|
DELETE FROM resources;
|
|
|
|
-- 3. CREAR NUEVOS RECURSOS PARA CADA LOCATION ACTIVA
|
|
DO $$
|
|
DECLARE
|
|
location_record RECORD;
|
|
i INTEGER;
|
|
resource_name TEXT;
|
|
BEGIN
|
|
FOR location_record IN SELECT id, name FROM locations WHERE is_active = true LOOP
|
|
|
|
RAISE NOTICE 'Creando recursos para: %', location_record.name;
|
|
|
|
-- 3 Estaciones de Maquillaje (mkup)
|
|
FOR i IN 1..3 LOOP
|
|
resource_name := 'mkup-' || LPAD(i::TEXT, 2, '0');
|
|
INSERT INTO resources (location_id, name, type, capacity, is_active)
|
|
VALUES (
|
|
location_record.id,
|
|
resource_name,
|
|
'station',
|
|
1,
|
|
true
|
|
);
|
|
RAISE NOTICE ' - Creado: %', resource_name;
|
|
END LOOP;
|
|
|
|
-- 1 Cama de Pestañas (lshs)
|
|
resource_name := 'lshs-01';
|
|
INSERT INTO resources (location_id, name, type, capacity, is_active)
|
|
VALUES (
|
|
location_record.id,
|
|
resource_name,
|
|
'station',
|
|
1,
|
|
true
|
|
);
|
|
RAISE NOTICE ' - Creado: %', resource_name;
|
|
|
|
-- 4 Estaciones de Pedicure (pedi)
|
|
FOR i IN 1..4 LOOP
|
|
resource_name := 'pedi-' || LPAD(i::TEXT, 2, '0');
|
|
INSERT INTO resources (location_id, name, type, capacity, is_active)
|
|
VALUES (
|
|
location_record.id,
|
|
resource_name,
|
|
'station',
|
|
1,
|
|
true
|
|
);
|
|
RAISE NOTICE ' - Creado: %', resource_name;
|
|
END LOOP;
|
|
|
|
-- 4 Estaciones de Manicure (mani)
|
|
FOR i IN 1..4 LOOP
|
|
resource_name := 'mani-' || LPAD(i::TEXT, 2, '0');
|
|
INSERT INTO resources (location_id, name, type, capacity, is_active)
|
|
VALUES (
|
|
location_record.id,
|
|
resource_name,
|
|
'station',
|
|
1,
|
|
true
|
|
);
|
|
RAISE NOTICE ' - Creado: %', resource_name;
|
|
END LOOP;
|
|
|
|
RAISE NOTICE 'Completado para location: %', location_record.name;
|
|
RAISE NOTICE '==========================================';
|
|
END LOOP;
|
|
END $$;
|
|
|
|
-- 4. VERIFICACIÓN Y RESUMEN
|
|
DO $$
|
|
DECLARE
|
|
total_resources INTEGER;
|
|
total_locations INTEGER;
|
|
location_record RECORD;
|
|
BEGIN
|
|
SELECT COUNT(*) INTO total_resources FROM resources;
|
|
SELECT COUNT(*) INTO total_locations FROM locations WHERE is_active = true;
|
|
|
|
RAISE NOTICE '==========================================';
|
|
RAISE NOTICE 'MIGRACIÓN DE RECURSOS COMPLETADA';
|
|
RAISE NOTICE '==========================================';
|
|
RAISE NOTICE 'Total de Resources: %', total_resources;
|
|
RAISE NOTICE 'Total de Locations: %', total_locations;
|
|
RAISE NOTICE '==========================================';
|
|
RAISE NOTICE 'Recursos por tipo (global):';
|
|
RAISE NOTICE ' - mkup (Maquillaje): %', (SELECT COUNT(*) FROM resources WHERE name LIKE 'mkup-%');
|
|
RAISE NOTICE ' - lshs (Pestañas): %', (SELECT COUNT(*) FROM resources WHERE name LIKE 'lshs-%');
|
|
RAISE NOTICE ' - pedi (Pedicure): %', (SELECT COUNT(*) FROM resources WHERE name LIKE 'pedi-%');
|
|
RAISE NOTICE ' - mani (Manicure): %', (SELECT COUNT(*) FROM resources WHERE name LIKE 'mani-%');
|
|
RAISE NOTICE '==========================================';
|
|
RAISE NOTICE 'Recursos por location:';
|
|
|
|
FOR location_record IN
|
|
SELECT l.id, l.name, COUNT(r.id) as resource_count
|
|
FROM locations l
|
|
JOIN resources r ON r.location_id = l.id
|
|
WHERE l.is_active = true
|
|
GROUP BY l.id, l.name
|
|
ORDER BY l.name
|
|
LOOP
|
|
RAISE NOTICE ' % (% recursos)', location_record.name, location_record.resource_count;
|
|
END LOOP;
|
|
|
|
RAISE NOTICE '==========================================';
|
|
RAISE NOTICE 'FORMATO DE NOMBRES:';
|
|
RAISE NOTICE ' Maquillaje: mkup-01, mkup-02, mkup-03';
|
|
RAISE NOTICE ' Pestañas: lshs-01';
|
|
RAISE NOTICE ' Pedicure: pedi-01, pedi-02, pedi-03, pedi-04';
|
|
RAISE NOTICE ' Manicure: mani-01, mani-02, mani-03, mani-04';
|
|
RAISE NOTICE '==========================================';
|
|
RAISE NOTICE 'ESTADO: Listo para usar';
|
|
RAISE NOTICE '==========================================';
|
|
END
|
|
$$;
|