diff --git a/replit.md b/replit.md index 242dc7c..c1edd98 100644 --- a/replit.md +++ b/replit.md @@ -28,7 +28,7 @@ VigilanzaTurni is a professional 24/7 shift management system for security compa - **Componenti**: Shadcn UI with an operational design. ### Database Schema -The database includes tables for `users`, `guards`, `certifications`, `sites`, `shifts`, `shift_assignments`, `notifications`, `customers`, and various tables for advanced scheduling and constraints (`guard_constraints`, `site_preferences`, `contract_parameters`, `training_courses`, `holidays`, `holiday_assignments`, `absences`, `absence_affected_shifts`). Service types include specialized parameters like `fixedPostHours`, `patrolPassages`, `inspectionFrequency`, and `responseTimeMinutes`. Sites support multi-location (`location` field) and contract management (`contractReference`, `contractStartDate`, `contractEndDate`). +The database includes tables for `users`, `guards`, `certifications`, `sites`, `shifts`, `shift_assignments`, `notifications`, `customers`, `service_types`, and various tables for advanced scheduling and constraints (`guard_constraints`, `site_preferences`, `contract_parameters`, `training_courses`, `holidays`, `holiday_assignments`, `absences`, `absence_affected_shifts`). Service types include specialized parameters like `fixedPostHours`, `patrolPassages`, `inspectionFrequency`, and `responseTimeMinutes`. Sites support multi-location (`location` field), contract management (`contractReference`, `contractStartDate`, `contractEndDate`), and service type association (`serviceTypeId` FK to `service_types.id`). ### Core Features - **Multi-Sede Operational Planning**: Location-first approach for shift planning, filtering sites, guards, and vehicles by selected branch. @@ -39,7 +39,7 @@ The database includes tables for `users`, `guards`, `certifications`, `sites`, ` - **Customer-Centric Reports**: New reports aggregating data by customer, replacing site-based billing, with specific counters for fixed posts (hours), patrols (passages), inspections, and interventions. CSV export is supported. - **Dashboard Operativa**: Live KPIs and real-time shift status. - **Gestione Guardie**: Complete profiles with skill matrix, certification management, and unique badge numbers. -- **Gestione Siti/Commesse**: Service types with specialized parameters and minimum requirements. Sites include service schedule, contract management, and location assignment. +- **Gestione Siti/Commesse**: Sites are associated with service types from the `service_types` table via `serviceTypeId` (FK). Service types are managed in the "Tipologie Servizi" page and include specialized parameters. Sites include service schedule, contract management, location assignment, and customer assignment (`customerId` FK to `customers.id`). - **Pianificazione Turni**: 24/7 calendar, manual guard assignment, basic constraints, and shift statuses. - **Advanced Planning**: Management of guard constraints, site preferences, contract parameters, training courses, holidays, and absences. @@ -52,6 +52,16 @@ The database includes tables for `users`, `guards`, `certifications`, `sites`, ` ### Critical Date/Timezone Handling To prevent timezone-related bugs, especially when assigning shifts, dates should always be constructed from components (`new Date(year, month-1, day)`) and never parsed from ISO strings directly using `parseISO()` or `new Date(string ISO)`. Date validation should use regex instead of `parseISO()`. +## Recent Changes (October 2025) +### Sites Form Fix - ServiceTypeId Integration +- **Issue**: Sites form used hardcoded `shiftType` enum values instead of dynamic service types from the database +- **Solution**: + - Changed Sites form to use `serviceTypeId` (FK to `service_types.id`) instead of deprecated `shiftType` field + - Added dynamic service type dropdown loading from `/api/service-types` endpoint + - Updated both create and edit forms to properly handle service type selection + - Card display now shows service type label from database instead of hardcoded labels +- **Impact**: Sites now correctly reference service types configured in "Tipologie Servizi" page, ensuring consistency across the system + ## External Dependencies - **Replit Auth**: For OpenID Connect (OIDC) based authentication. - **Neon**: Managed PostgreSQL database service.