incidents table stores all incident reports submitted by guests or staff members. Each incident is assigned to an area and tracks its resolution status.
Table Name
incidents
Schema Fields
Primary key, automatically generated
Brief title of the incident (e.g., “Aire no enfría”)
Detailed description of the problem
Priority level for the incidentAllowed values:
baja- Low prioritymedia- Medium priorityalta- High priority
Current status of the incidentCommon values:
pendiente- Awaiting assignmentrecibida- Accepted by staffen_progreso- Being worked onresuelta- Resolved
Foreign key reference to
areas.id. Determines which department handles this incident.Foreign key reference to
rooms.id. Indicates where the incident occurred.Foreign key reference to
profiles.id. The staff member assigned to resolve this incident.Automatically set when the incident is created
Automatically updated when the incident is modified
Relationships
- areas: Many-to-one relationship via
area_id - rooms: Many-to-one relationship via
room_id - profiles: Many-to-one relationship via
assigned_to - incident_resolutions: One-to-many relationship
- incident_evidence: One-to-many relationship
Query Examples
Create New Incident
Guests create incidents when reporting problems:The
status field defaults to "pendiente" if not specified.Fetch Incidents for a Room
Retrieve all incidents reported from a specific room:mobile/components/MyIncidentsView.tsx:106
Assign Incident to Staff
When a staff member accepts an incident:mobile/app/(guest)/incidents/[id].tsx:147
Update Incident Status
Progress an incident from “recibida” to “en_progreso”:mobile/app/(guest)/incidents/[id].tsx:232
Load Area-Specific Incidents
Staff members see incidents for their assigned area:mobile/components/EmpleadoBuzonIncidents.tsx:207
Fetch Incident Details
Retrieve complete incident information including resolutions and evidence:mobile/app/(guest)/incidents/[id].tsx:84
Mark Incident as Resolved
mobile/components/ResolveIncidentBottomSheet.tsx:201
Status Workflow
The incident status follows this typical workflow:Priority Levels
Color: Green (#10B981)Non-urgent issues that can be handled during regular maintenance
Color: Amber (#F59E0B)Issues requiring attention but not immediately critical
Color: Red (#EF4444)Critical issues requiring immediate attention
Related Tables
Incident Resolutions
Resolution details when incidents are completed
Areas
Department assignments for incidents
Rooms
Room location data
Users
Staff member assignments